Echelon Neuron Bedienungsanleitung

Stöbern Sie online oder laden Sie Bedienungsanleitung nach Hardware Echelon Neuron herunter. Echelon Neuron User Manual Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 237
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen

Inhaltsverzeichnis

Seite 1 - Language Reference

078-0399-01BDevelop assembly language functions using the Neuron® Assembly Language.Neuron Assembly Language Reference Guide

Seite 2

_sub16s (Subtract Signed, 16 Bit) ... 193 _xor16 (Exclusive OR, 16 Bit) ...

Seite 3 - Related Documentation

MUL (Multiply) The MUL instruction performs integer multiplication. The MUL instruction uses the implicit addressing mode. The instruct

Seite 4

NOP (No Operation) The NOP instruction performs no operation. The NOP instruction uses the implicit addressing mode. This instruction is a one-byt

Seite 5 - Table of Contents

NOT (Not) The NOT instruction performs a logical NOT operation on the value in TOS. The NOT instruction uses the implicit addressing mode. This ins

Seite 6

OR (Or) The OR instruction performs a logical OR for two numbers. The OR instruction uses one of two addressing modes: • In implicit addressing mo

Seite 7

OR_R (Or and Return) The OR_R instruction performs a logical OR for two numbers and performs a return-from-call operation. The OR_R instruction uses

Seite 8

POP (Pop from Stack) The POP instruction pops a value from the data stack to a specified location. The POP instruction uses one of the following ad

Seite 9

POP [2][offset] POP [3][offset] POP [0][TOS] POP [1][TOS] POP [2][TOS] POP [3][TOS] POP FLAGS POP RS

Seite 10

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag POP [3][offset] DB 2 7 None POP [0][TOS] DC 1

Seite 11 - Introduction

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag POP !15 CF 1 4 None POP !16 D0 1 4 None POP

Seite 12

xch ; ( n, 0 ) pop !tos ; ( n ) drop_r tos ; return to caller Neuron Assembly Language

Seite 13 - Neuron Assembler Tools

1 Introduction This chapter introduces the Neuron assembly language and the Neuron Assembler. Neuron Assembly Language Reference 1

Seite 14 - NAS Command Switches

POPD (Pop Pointer Direct) The POPD instruction pops the two bytes from TOS and NEXT on the data stack into the specified pointer register. The POPD

Seite 15 - Neuron Librarian Tool

POPPUSH (Pop from Data Stack and Push onto Return Stack) The POPPUSH instruction pops TOS from the data stack and pushes the value onto the return s

Seite 16 - Naming Convention

PUSH (Push onto Stack) The PUSH instructions push a value from a specified location onto the data stack. The PUSH instruction uses one of the follow

Seite 17 - Output Files

base page register (BP) into NEXT on the data stack. This instruction modifies NEXT but preserves TOS. The PUSH instruction applies to Series 3100,

Seite 18

PUSH [RSP] PUSH !TOS The number sign or hash (#) is required to specify the immediate value for the PUSH #number instruction. The e

Seite 19 - Assembly Instructions

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag PUSH address B7 3 7 None PUSH TOS A4 1 3 No

Seite 20 - Literal Constants

Examples: The following example assumes that the stack contains two 16-bit elements, A and B, with A nearest to the top of the stack. The example pla

Seite 21 - Expressions

PUSHD (Push Pointer Direct) The PUSHD instruction pushes two bytes from the specified location into TOS and NEXT on the data stack. The PUSHD instr

Seite 22

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag PUSHD [3] B3 1 6 None PUSHD #expression B5 3 6

Seite 23 - Constant Expressions

PUSHPOP (Pop from Return Stack and Push onto Data Stack) The PUSHPOP instruction pops the byte from the top of the return stack and pushes it into T

Seite 24 - Assembler Directives

Introduction An application program for a LONWORKS device that runs on a Series 3100, Series 5000, or Series 6000 Neuron Chip or Smart Transceiver use

Seite 25 - Assembly Programming

PUSHS (Push Short) The PUSHS instruction pushes the value of the specified operand number into TOS. The PUSHS instruction uses the immediate address

Seite 26 - Neuron Architecture

RET (Return from Call) The RET instruction performs a return-from-call operation. The RET instruction uses the implicit addressing mode. The RET in

Seite 27 - CPU Registers

ROLC (Rotate Left through Carry) The ROLC instruction rotates the byte in TOS one bit to the left, using the Carry flag as an input bit. The ROLC

Seite 28 - General-Purpose Registers

RORC (Rotate Right through Carry) The RORC instruction rotates the byte in TOS one bit to the right, using the Carry flag as an input bit. The RORC

Seite 29 - Pointer Registers

SBC (Subtract with Carry) The SBC instruction subtracts two numbers, and uses the value of the Carry flag as input to the subtrahend. The SBC instru

Seite 30

SBR (Short Branch) The SBR instruction performs an unconditional branch. The SBR instruction uses the (short) relative addressing mode. The SBR in

Seite 31 - Instruction Pointer

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag SBR *+10 29 1 1 None SBR *+11 2A 1 1 None SB

Seite 32 - Data Stack

SBRNZ (Short Branch If Not Zero) The SBRNZ instruction performs a conditional branch if TOS is not zero. The SBRNZ instruction uses the (short) rel

Seite 33 - Return Stack

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag SBRNZ *+10 69 1 3 None SBRNZ *+11 6A 1 3 Non

Seite 34 - Stack Manipulation

SBRZ (Short Branch If Zero) The SBRZ instruction performs a conditional branch if TOS is zero. The SBRZ instruction uses the (short) relative addre

Seite 35 - Segments

• Chapter 8, System-Provided Functions, describes system-provided functions for various arithmetical or logical operations or for stack management.

Seite 36 - Chips with Off-Chip Memory

Instruction Hexadecimal Opcode Instruction Size (Bytes) CPU Cycles Required Affect on Carry Flag SBRZ *+10 49 1 3 None SBRZ *+11 4A 1 3 None

Seite 37

SHL (Shift Left) The SHL instruction shifts the byte in TOS one bit to the left. The SHL instruction uses the implicit addressing mode. This instr

Seite 38

SHLA (Shift Left Arithmetically) The SHLA instruction shifts the byte in TOS one bit to the left arithmetically. The SHLA instruction uses the impli

Seite 39 - Chips with Auto-tuned Memory

SHR (Shift Right) The SHR instruction shifts the byte in TOS one bit to the right. The SHR instruction uses the implicit addressing mode. This ins

Seite 40 - Absolute

SHRA (Shift Right Arithmetically) The SHRA instruction shifts the byte in TOS one bit to the right arithmetically. The SHRA instruction uses the imp

Seite 41 - Indirect Relative

SUB (Subtract) The SUB instruction subtracts two numbers. The SUB instruction uses the direct addressing mode, in two forms, subtract NEXT from TOS

Seite 42 - DSP Relative

The value of TOS after the first subtraction is 1 because 3-2 = 1. In this case, the value of the Carry flag is cleared because the unsigned subtract

Seite 43 - Relative

XCH (Exchange) The XCH instruction exchanges the contents of TOS and NEXT on the data stack. The XCH instruction uses the implicit addressing mode.

Seite 44

XOR (Exclusive Or) The XOR instruction performs a logical exclusive OR (XOR) for two numbers. The OR instruction uses one of two addressing modes: •

Seite 45 - Function

XOR_R (Exclusive Or and Return) The XOR_R instruction performs a logical exclusive OR (XOR) for two numbers and performs a return-from-call operatio

Seite 46

where –switches define any optional command-line switches (see NAS Command Switches) and file.ns specifies the source input file to assemble. The com

Seite 48

7 Neuron Assembler Directives The Neuron Assembler provides various directives to control the inclusion of additional source files, to control co

Seite 49

Overview of the Assembler Directives An assembler directive provides information to the Neuron Assembler to control or affect the processing of the re

Seite 50

RADIX Specify default numeric base RESOURCE Control resource (compiler generated) The directives have syntax analogous to the assembly instructions

Seite 51 - Conditional Values

APEXP (Application Symbol Export) The APEXP directive is used to export symbols that interface with the Neuron C application. An exported symbol must

Seite 52 - Integrating the Program

DATA.B (Reserve Initialized Memory) The DATA.B directive is used to reserve memory and initialize the reserved memory to specific values. See also

Seite 53 - Assembling the Program

%lookupTable DATA.B h’12,h’2C,h’39 The following example defines a constant string “Hello, World!” and includes a terminating zero byte:

Seite 54 - Debugging the Program

ELSE (Conditional Assembly) The Neuron assembler provides the following directives for conditional control of the assembly of blocks of source lines

Seite 55

END (Assembly Control) The END directive instructs the Neuron assembler to stop reading the current file and stop compiling. This directive is optio

Seite 56

ENDIF (Conditional Assembly) The Neuron assembler provides the following directives for conditional control of the assembly of blocks of source line

Seite 57 - Application

Table 1. Command Switches for the nas Command Command Switch Description Long Form Short Form --autotrunc -a Auto-truncate literals for byte-immedi

Seite 58 - Function Parameters

EQU (Equate Symbol) The EQU directive assigns the value of a constant expression to a symbol. The assembler treats subsequent occurrences of the sym

Seite 59 - Calling Conventions

ERROR (Conditional Assembly) The ERROR directive causes the Neuron Assembler to display a user-defined error message. This error leads to an assemb

Seite 60

EXPORT (Export Symbol) The EXPORT directive is used to export symbols that interface with other Neuron Assembly modules. An exported symbol must be d

Seite 61 - Data Representation

IF (Conditional Assembly) The Neuron assembler provides the following directives for conditional control of the assembly of blocks of source lines:

Seite 62 - Bitfields

IFDEF (Conditional Assembly) The Neuron assembler provides the following directives for conditional control of the assembly of blocks of source lines

Seite 63

IFNDEF (Conditional Assembly) The Neuron assembler provides the following directives for conditional control of the assembly of blocks of source lin

Seite 64

IMPORT (Import External Symbol) The IMPORT directive is used to import symbols from other Neuron Assembly modules or a Neuron C application. An impor

Seite 65

INCLUDE (Assembly Control) The INCLUDE directive is used to include additional assembly source-code modules in the compilation of the current file.

Seite 66

LIBRARY (Include Library) The LIBRARY directive is used to instruct the linker to use a specific function library when linking an application conta

Seite 67

Example: The following example advises the Neuron Linker to include the Echelon provided CENELEC library when linking an application that uses the cu

Seite 68

The Neuron Librarian, available from the command line as NLIB.EXE, allows you to create and manage libraries, or add and remove individual object file

Seite 69 - Instruction Statements

LIST (Listing Control) The LIST and NOLIST directives control whether assembly source statements are included in a listing file (produced by specifyi

Seite 70

NOLIST (Listing Control) The LIST and NOLIST directives control whether assembly source statements are included in a listing file (produced by speci

Seite 71

ORG (Segment Control) The ORG directive closes the currently open and active segment, and opens a new segment of the same type. When a segment is cl

Seite 72

PAGE (Listing Control) The PAGE directive begins a new page in an assembly listing file (produced by specifying the --listing keyword on the command

Seite 73

RADIX (Default Radix) The RADIX directive sets the default radix (numeric base) used for constant numeric expressions until another RADIX directive i

Seite 74 - ADC (Add with Carry)

RES (Reserve Uninitialized Memory) The RES directive reserves a block of memory for uninitialized data. See also DATA.B (Reserve Initialized Memor

Seite 75 - ADD (Add)

RESOURCE (Resource Control) The RESOURCE directive is used by the Neuron C compiler to specify various preferences and requirements to its companion

Seite 76 - ADD_R (Add and Return)

SEG (Segment Control) The SEG directive controls the currently open segment type. Any of the supported segment types (including the one that is cur

Seite 77 - ALLOC (Allocate)

SUBHEAD (Listing Control) The SUBHEAD directive specifies the text for the subheading line of the assembly listing file (produced by specifying the -

Seite 78 - AND (And)

8 System-Provided Functions This chapter describes the system-provided functions that are used by the Neuron C compiler. Neuron Assembly Language

Seite 79 - AND_R (And and Return)

recommended. If no file name extension is provided on the command line, the Neuron Assembler assumes an .ns extension. A file that is used with the

Seite 80 - BR (Branch)

Overview of the Functions The Neuron firmware provides certain functions for common programming tasks that can make Neuron assembly language programmi

Seite 81 - BRC (Branch If Carry)

_abs8 (Absolute Value, 8 Bit) This function returns the absolute value of a signed integer. Stack Transformation: (a -- |a|) Location: Near Regist

Seite 82 - BRF (Branch Far)

_add_8_16f (Add Fast, 8 Bit to 16 Bit) This function adds an 8-bit value to a 16-bit value. The “f” stands for “fast” in that if there is no carry, o

Seite 83 - BRNC (Branch If Not Carry)

This example causes 13 bytes of zeroes to be pushed onto the data stack. push #d’13 ; (13) call _alloc ; (0(13)) _

Seite 84 - BRNEQ (Branch If Not Equal)

Stack Transformation: (value(2) -- value(2)-1) Location: Near Registers Affected: None Example: This example decrements 300. pushd #d’300

Seite 85

_div8 (Divide, 8 Bit) This function divides two integers to produce an integer result. The result of dividing by zero is zero and a software error i

Seite 86 - BRNZ (Branch If Not Zero)

call _drop_n ; () _drop_n_preserve_1 (Drop N Bytes from Stack and Preserve NEXT) This function preserves NEXT and removes the next N i

Seite 87 - BRZ (Branch If Zero)

Example: This example drops 3 bytes from the stack and returns to the caller of LocalFunction. callr LocalFunction ; (a, b, c, d) ;

Seite 88 - CALL (Call Near)

call _equal16 ; (0) _equal8 (Equality Test, 8 Bit) This function returns true if two 8-bit values are equal. The native XOR instructio

Seite 89 - CALLF (Call Far)

Example: This example determines if d’10 >= d’20. push #d’20 ; (d’20) push #d’10 ; (d’10, d’20) call

Seite 90 - CALLR (Call Relative)

The object output file contains assembled code, ready for the Neuron Linker. Typically, the object output file has the same name as the input source

Seite 91

Registers Affected: None Example: This example increments 300. pushd #d’300 ; (44, 1) call _inc16 ; (45, 1) io_iacc

Seite 92

watchdog timer reset. A Neuron C application can use the #pragma deadlock_is_infinite compiler directive to avoid the watchdog timer reset. Do not

Seite 93

This example acquires the semaphore, then modifies a global variable, then releases the semaphore. import io_iaccess, io_irelease

Seite 94 - DEC (Decrement)

Registers Affected: None Example: This example shifts 16 left 2. pushs #d’2 ; (d’2) push #d’16 ; (d’16, d’2)

Seite 95 - DIV (Divide)

Location: Near Registers Affected: P0 is modified and contains address(2) Example: This example loads two bytes from address h’f000, which for this

Seite 96 - DROP (Drop from Stack)

Stack Transformation: (a, b -- a<b) Location: Near Registers Affected: None Example: This example determines if d’10 < d’20. push

Seite 97

Stack Transformation: (a – a?1:0) Location: Near Registers Affected: None Example: This example returns the logical value for 5. pushs #

Seite 98 - INC (Increment)

_lshift16_add16 (Left Shift and Add, 16 Bit) This function takes a 16-bit index, shifts it left n times, and adds the result to a base value. Stack

Seite 99 - Done

Registers Affected: None Example: This example uses a base of h’efe3 and an index of 10. pushd #h’efe3 ; (h’e3, h’ef)

Seite 100 - MUL (Multiply)

Stack Transformation: (a(2), b(2) -- max(a(2),b(2))) Location: Near Registers Affected: None Example: This example gets the maximum of -8 and 2.

Seite 101 - NOP (No Operation)

• label is an optional identifier, followed by white space • keyword is a reserved name for an assembly instruction or Assembler directive • The

Seite 102 - NOT (Not)

_memcpy (Copy Memory) This function performs the equivalent of a memcpy() function for a non-zero amount of data. len cannot be 0. Also, _memcpy doe

Seite 103 - OR (Or)

Example: This example initializes four bytes at h’eff0 to 33. pushs #d’4 ; (d’4) push #d’33 ; (d’33, d’4)

Seite 104 - OR_R (Or and Return)

Location: Near Registers Affected: None Example: This example gets the minimum of -8 and 2. pushd #d’2 ; (d’2, 0) pushd

Seite 105 - POP (Pop from Stack)

Stack Transformation: (a(2) -- -a(2)) Location: Near Registers Affected: None Example: This example negates 2. pushd #d’2 ; (d’

Seite 106 - ] D9 2 7 None

Stack Transformation: (a(2), b(2) -- a(2)*b(2)) Location: Near Registers Affected: R0, P0, P3 Example: This example multiplies 50 times 40.

Seite 107 - ] DB 2 7 None

_mul8s (Multiply Signed, 8 Bit) This function multiplies two signed integers to produce an integer result. Stack Transformation: (a, b -- a*b) Loca

Seite 108

push #d’40 ; (d’40, d’50, 0) call _muls_8_16 ; (d’208, 7) _mul8l (Multiply, 8 Bit with 16 Bit Result) This function mul

Seite 109

pushd #d’8 ; (d’8, 0) call _not16 ; (d’247, d’255) _or16 (Or, 16 Bit) This function returns the bitwise OR of two

Seite 110 - POPD (Pop Pointer Direct)

Example: This example does the equivalent of a POP [DSP][-9]. ; (a, b, c, d, …, h, i, j, k) pushs #7

Seite 111 - Return Stack)

_push (Push from Offset to TOS) This function is used to fetch a location from the stack. It can be thought of as an extension to the instruction PU

Seite 112 - PUSH (Push onto Stack)

Echelon, LONWORKS, LONMARK, NodeBuilder, LonTalk, Neuron, 3120, 3150, ShortStack, LonMaker, and the Echelon logo are trademarks of Echelon Corporation

Seite 113 - PUSH [1][offset]

See Chapter 6, Neuron Assembly Language Instruction Statements, for a description of all supported instructions. Operands Many Neuron assembly instruc

Seite 114 - ] 9B 2 7 None

Example: ; (a, b, c, d) call _push4 ; (a, b, c, d, a, b, c ,d) _pushd (Push from Offset to TOS and NEXT,

Seite 115

Stack Transformation: (a(2), b -- a(2)>>b) Location: Near Registers Affected: None Example: This example shifts 16 right 2. pushs

Seite 116

Stack Transformation: (a -- a>>n) Location: Near Registers Affected: None Example: This example shifts 16 right 3. push #d’16

Seite 117 - PUSHD (Push Pointer Direct)

_sign_extend16 (Convert 8 Bit to 16 Bit, Preserve Sign) This function sign extends an 8-bit value. If the most-significant byte (MSB) of the value i

Seite 118

pushd #d’50 ; (d’50, 0, d’44, 1) call _sub16s ; (d’250, 0) _xor16 (Exclusive OR, 16 Bit) This function returns the bi

Seite 119 - Data Stack)

A Neuron Assembly Instructions Listed by Mnemonic This appendix lists the Neuron assembly instructions by mnemonic. Neuron Assembly Language Refere

Seite 120 - PUSHS (Push Short)

Instructions by Mnemonic Table 62 lists the Neuron assembly language instructions, ordered by mnemonic. The table also summarizes the operation perfo

Seite 121 - RET (Return from Call)

Mnemonic Operand Operation Description ALLOC #literal [DSP+1] = TOS DSP = DSP + literal IP = IP+1 Move DSP by literal. Literal range is 1 to 8.

Seite 122

Mnemonic Operand Operation Description BRZ label IF [TOS]=0 IP = IP+SD TOS = [DSP--] IP = IP+2 Drop TOS, branch if TOS was zero. The IP-rela

Seite 123

Mnemonic Operand Operation Description DIV TEMP = int([DSP] ÷ TOS) TOS = int([DSP] % TOS) [DSP] = TEMP IP++ Divide unsigned integer in NEXT by

Seite 124 - SBC (Subtract with Carry)

Symbols A symbol is one or more consecutive alphanumeric characters. A symbol can comprise either lower or upper case letters a..z or A..Z, the digi

Seite 125 - SBR (Short Branch)

Mnemonic Operand Operation Description NOP IP = IP + 1 No operation is done. NOT TOS = NOT TOS C = 0 IP = IP+1 Change TOS to its one's

Seite 126

Mnemonic Operand Operation Description POP [DSP][D] [BP + DSP + D]= TOS TOS = [DSP--] IP = IP+1 Pop DSP relative with displacement D. Negative

Seite 127

Mnemonic Operand Operation Description PUSH [PTR] [D] [++DSP] = TOS TOS = [[BP+(PTR*2)]+D] IP = IP+2 Pushes 8-bit value at address held in 2-byte

Seite 128

Mnemonic Operand Operation Description ROLC C = TOS MSB TOS = TOS << 1 TOS LSB = OLD C IP = IP+1 Rotate TOS left through CARRY by one. RO

Seite 129 - SBRZ (Short Branch If Zero)

Mnemonic Operand Operation Description SHL TOS = TOS <<1 TOS LSB = 0 C = 0 IP = IP+1 Logical shift TOS left by one. SHLA C = TOS MSB T

Seite 130

Mnemonic Operand Operation Description XOR TOS = TOS ^ [DSP--] C = 0 IP = IP+1 Bitwise XOR of TOS and NEXT. Drop NEXT. XOR #literal TOS =

Seite 132

B Neuron Assembly Instructions Listed by Hexadecimal Opcode This appendix lists the Neuron assembly instructions by opcode. Neuron Assembly Languag

Seite 133 - SHR (Shift Right)

Instructions by Opcode Table 63 lists the Neuron assembly language instructions, ordered by hexadecimal opcode. The table also summarizes the number

Seite 134

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles 13 CALL 1 2 6 14 CALL 1 2 6 15 CALL 1 2 6 16 CALL 1

Seite 135 - SUB (Subtract)

Table 2. Unary Operators Operator Description - Two’s-complement arithmetic negation ~ One’s-complement bitwise negation Binary operators are symb

Seite 136

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles 2B SBR 0 1 1 2C SBR 0 1 1 2D SBR 0 1 1 2E SBR 0 1 1

Seite 137 - XCH (Exchange)

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles 43 SBRZ 0 1 3 44 SBRZ 0 1 3 45 SBRZ 0 1 3 46 SBRZ 0

Seite 138 - XOR (Exclusive Or)

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles 5B XOR #number 1 2 3 5C ADD_R 0 1 7 5D AND_R 0 1 7 5E O

Seite 139

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles 73 BRZ 1 2 4 74 CALLR 1 2 5 75 BRF 2 3 4 76 BRNEQ 2

Seite 140

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles 8B PUSH !11 0 1 4 8C PUSH !12 0 1 4 8D PUSH !13 0 1 4 8E

Seite 141 - Neuron Assembler Directives

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles A3 PUSH DSP 0 1 4 A4 PUSH TOS 0 1 3 A5 PUSH NEXT 0 1 4

Seite 142

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles BB PUSH DSP[-5] 0 1 5 BC PUSH DSP[-4] 0 1 5 BD PUSH DSP[-3]

Seite 143

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles D3 POP !19 0 1 4 D4 POP !20 0 1 4 D5 POP !21 0 1 4 D6

Seite 144

Hexadecimal OpCode Mnemonic Number of Operands Instruction Size Number of Cycles EB - - - - EC MUL 0 1 14 ED DIV 0 1 14 EE - - - - EF

Seite 145

C Reserved Keywords This appendix lists the keywords that are reserved to the Neuron Assembler or the Neuron C compiler. Neuron Assembly Language

Seite 146

Table 5. Special Operator Functions Function Description LB Extracts the low byte of the expression HB Extracts the high byte of the expression (l

Seite 147 - ELSE (Conditional Assembly)

Keywords Table 64 lists the reserved keywords for the Neuron Assembler or the Neuron C compiler. Not all of the keywords are available to the program

Seite 148 - END (Assembly Control)

Index # #pragma include_assembly_file, 39, 42 _ _abs16 function, 160 _abs8 function, 161 _add_8_16 function, 162 _add_8_16f function, 162 _add16 func

Seite 149 - ENDIF (Conditional Assembly)

add16s function, 161 address expression, 14 addressing mode absolute, 30 BP indexed, 33 BP relative, 32 direct, 30 DSP relative, 32 immediate, 30 impl

Seite 150 - EQU (Equate Symbol)

EXPORT directive, 142 expression address, 14 constant, 13 general, 11 F file format, 7 naming convention, 6 output, 7 source, 6 FLAGS register, 21 fo

Seite 151 - ERROR (Conditional Assembly)

gequ8s function, 169 get_sp function, 169 global data, 29 H hardware resources, 17 I IF directive, 143 IFDEF directive, 144 IFNDEF directive, 145 imme

Seite 152 - EXPORT (Export Symbol)

M max16 function, 178 max16s function, 178 max8 function, 179 max8s function, 179 memcpy function, 179 memcpy1 function, 180 memory map, 26 memset fu

Seite 153 - IF (Conditional Assembly)

SEG directive, 157 segment, 25 SHL instruction, 121 SHLA instruction, 122 SHR instruction, 123 SHRA instruction, 124 sign_extend16 function, 192 speci

Seite 155

Displacements A displacement is a relative address value. A displacement can be interpreted as a signed or unsigned number, depending on the instruct

Seite 156

2 Neuron Architecture for Neuron Assembly Programming This chapter describes elements of the Neuron architecture that apply to writing a function i

Seite 157 - INCLUDE (Assembly Control)

Neuron Architecture For Series 3100 devices, the architecture of a Neuron Chip or Smart Transceiver includes three independent processors that share a

Seite 158 - LIBRARY (Include Library)

A Neuron Chip or Smart Transceiver is a big-endian device, that is, the most-significant byte (MSB) of an address or a 16-bit scalar is at a lower me

Seite 159

General-Purpose Registers The Neuron architecture defines 16 hardware memory locations that the Neuron Assembler uses as general-purpose registers, ty

Seite 160 - LIST (Listing Control)

A scratch register is one that can be used for temporary data storage by multiple programs or functions. Although some operations support a special

Seite 161 - NOLIST (Listing Control)

Welcome Echelon’s Neuron® assembly language is the symbolic programming language for Series 3100, Series 5000, and Series 6000 Neuron Chips and Smart

Seite 162 - ORG (Segment Control)

Table 7. Pointer Registers Pointer Register Description P0 Scratch register. A function can use this register as needed. Assume that any call to t

Seite 163 - PAGE (Listing Control)

P0 EQU 0 P1 EQU 1 P2 EQU 2 P3 EQU 3 Finally, note that the mnemonics are user-defined symbols. Unlike pre-defined re

Seite 164 - RADIX (Default Radix)

...lsb(ret)msb(ret)NEXT...GPR0x00000xFFFFBPDSP+RSP+TOSDSP -1DSP -8-1..-8+(DSP-relative addressing mode) 256 Bytes msb P0lsb P0msb P1lsb P1lsb P3R0R1R1

Seite 165

DSP TOS 1 2 3 4 5 Low High NEXT Figure 3. The Data Stack after a Push For two-byte quantities, a two-byte push places the most-significant byte (MSB)

Seite 166 - RESOURCE (Resource Control)

RSP = old RSP - 2HighLow2501??Address of next sequential instruction after call Figure 4. The Return Stack Stack Manipulation The Neuron assembly lan

Seite 167 - SEG (Segment Control)

• POPPUSH to remove the TOS element of the data stack and place it onto the top of the return stack • DROP [RSP] to drop the top of the return stac

Seite 168 - SUBHEAD (Listing Control)

Segment Name Usage INITDATA For initialization data. Used by the Neuron C compiler. RAMCODE For code and constant data that resides in off-chip RAM

Seite 169 - System-Provided Functions

For the Neuron 3150 Chip and the FT 3150 Smart Transceiver, off-chip memory on these chips consists of one or more of ROM, RAM, EEPROM, NVRAM, or fla

Seite 170 - Overview of the Functions

ReservedMandatory EEPROMOn-Chip RAMExtended Memory(Configurable as: Extended RAM or Non-volatile memory)On-Chip ROM0x0000 to 0x3FFF0x4000 to 0xE7FF0xE

Seite 171 - _add16s (Add Signed, 16 Bit)

Figure 7. Memory Maps for Neuron Chips without Off-Chip Memory Chips with Auto-tuned Memory Series 6000 Neuron Chips and Smart Transceivers support

Seite 172 - -- value(2)+offset)

• Introduction to the LONWORKS Platform (078-0391-01A). This manual provides an introduction to the ISO/IEC 14908 (ANSI/CEA-709.1 and EN14908) Contr

Seite 173 - _dec16 (Decrement, 16 Bit)

Instead of relying on the developer to specify these memory areas, the Neuron Linker automatically determines the amount of memory required for each t

Seite 174 - _div16 (Divide, 16 Bit)

Direct In the direct addressing mode, the instruction operand is a register name or an expression that resolves to a name of a register. In contrast

Seite 175 - _div8 (Divide, 8 Bit)

Example: push [P0][12] ; ( ) pop [P3][4] ; ([P3][4], ...) The push [P0][12] instruction pushes th

Seite 176

BP Relative In the BP-relative addressing mode, the instruction argument is a general-purpose register (R0 to R15). The register name is prefixed by

Seite 177

instruction pointer IP. Some instructions that use relative addressing support signed distances (that is, support branching in both directions), whil

Seite 178

3 Writing a Neuron Assembly Utility Function This chapter describes general guidelines for writing a utility function in Neuron assembly language.

Seite 179 - _inc16 (Increment, 16 Bit)

Overview of Stack-Oriented Programming Neuron assembly language is a stack-oriented programming language, which means that the data stack is the prima

Seite 180

more compact code; see PUSHS (Push Short) for a description of the PUSHS instruction. Note that the stacks and all data registers are 8 bits wide. O

Seite 181

• For the value pi (π), you can use the following approximation: 355/113 (3.1415929203…), which has an error relative to pi of 8.5 * 10-8. • To mul

Seite 182

pushd [SCRATCH16] ; (r(2), piDiv(2)) pushd [SCRATCH16] ; (r(2), r(2), piDiv(2)) ; push the “second half” of pi: pushd #PIFACT

Seite 183

Table of Contents Welcome ... iii Audience ...

Seite 184 - _less8 (Less Than, 8 Bit)

the device’s hardware template), the interrupts run on the application processor, and share stacks and common registers with the Neuron C application.

Seite 185 - _log8 (Logical Value, 8 Bit)

Stack-Effect Comments In general, the data stack is documented as a set of ordered values from left to right, with TOS in the first (left-most) posit

Seite 186

the code element might still be on the stack (if the equality test fails), or might no longer be on the stack (if the equality test succeeds):

Seite 187 - Converts 8 Bits to 16 Bits)

Neuron C compiler to copy the contents of a Neuron assembly file as-is into the assembly-language output for the program, as shown in Figure 8. Compi

Seite 188

Copyright (c) Echelon Corporation 1992-2009 0 warning(s), 0 error(s) The --listing option causes the Assembler to generate a listing file. The Neuro

Seite 189 - _max8 (Maximum Value, 8 Bit)

} In addition, you can add a callback function to the test application, and modify the assembly source to call the Neuron C callback function. This

Seite 191 - _memset1 (Set Memory at P0)

4 Interfacing with a Neuron C Application This chapter describes the conventions and interface requirements for a Neuron assembly function to w

Seite 192 - _min8 (minimum Value, 8 Bit)

Overview Typically, you use Neuron assembly language to create utilities that can be used with an application that is written in Neuron C. The Neuron

Seite 193 - _mul16 (Multiply, 16 Bit)

In typical C-language implementations of such functions, the caller is responsible for removing the arguments from the stack after the function compl

Seite 194 - _mul8 (Multiply, 8 Bit)

Implicit ... 31 Pointer Direct...

Seite 195

This optimization is leads to more efficient code (as the called function might consume its arguments rather than working on copies), and leads to mor

Seite 196 - _not16 (Not, 16 Bit)

also supports a string format, but does not automatically include the terminating zero-byte. An alternative declaration would have been _%MYDEVICE

Seite 197 - _or16 (Or, 16 Bit)

Arrays The Neuron Chip and Smart Transceiver hardware has no data alignment requirement, beyond the natural byte alignment. Thus, arrays are consecut

Seite 198 - Offset, 16 Bit)

4. Call the function. 5. Process optional function results and clear the stack frame. 6. Restore general-purpose registers saved. Example: The fo

Seite 199 - -- value, …, value, …)

next instructions, but this alternative implementation would use one more byte of code. In this example, it is assumed that the value for the remainin

Seite 200 - NEXT, 16 Bit)

5 Exploring an Example Function in Neuron Assembly This chapter describes an example function written in Neuron assembly language. This example

Seite 201

Overview of the Checksum Example The checksum example function described in this chapter demonstrates the process of writing and testing a function i

Seite 202

value formerly held in NEXT. Using this instruction prepares for the loop construct that follows. • The POPD instruction takes two bytes from the s

Seite 203 - _sub16 (Subtract, 16 Bit)

#pragma num_alias_table_entries 0 #pragma include_assembly_file “checksum.ns” extern unsigned Checksum(unsigned, const char*); void TestCall(void) {

Seite 204

6 Neuron Assembly Language Instruction Statements This chapter describes the Neuron assembly language instruction statements that are supported b

Seite 205 - Listed by Mnemonic

BRNC (Branch If Not Carry) ... 73 BRNEQ (Branch If Not Equal) ...

Seite 206 - Instructions by Mnemonic

Overview of the Assembly Language Instructions The Neuron assembly language provides instruction statements that control the functionality of the func

Seite 207

Shift and Rotate Operations ROLC Rotate left through carry RORC Rotate right through carry SHL Shift left SHLA Shift left arithmetically SHR Shi

Seite 208

BRZ Branch if zero DBRNZ Decrement and branch if not zero SBRNZ Short branch if not zero SBRZ Short branch if zero Unconditional Program Control O

Seite 209

program memory. The size includes both the opcode and the instruction’s data, if any. • The number of CPU cycles required to execute the instructio

Seite 210

ADC (Add with Carry) The ADC instruction adds two numbers with the value of the Carry flag. The ADC instruction uses the implicit addressing mode.

Seite 211

ADD (Add) The ADD instruction adds two numbers. The ADD instruction uses one of two addressing modes: • In implicit addressing mode, the ADD instr

Seite 212

ADD_R (Add and Return) The ADD_R instruction adds two numbers and performs a return-from-call operation. The ADD_R instruction uses the implicit add

Seite 213

ALLOC (Allocate) The ALLOC instruction allocates a specified number of bytes on the data stack. The specified number of bytes must be in the range

Seite 214

AND (And) The AND instruction performs a logical AND for two numbers. The AND instruction uses one of two addressing modes: • In implicit addressi

Seite 215

AND_R (And and Return) The AND_R instruction performs a logical AND for two numbers and performs a return-from-call operation. The AND_R instructio

Seite 216

IFNDEF (Conditional Assembly) ... 145 IMPORT (Import External Symbol) ...

Seite 217 - Listed by Hexadecimal Opcode

BR (Branch) The BR instruction performs an unconditional branch. The BR instruction uses the relative addressing mode. The BR instruction branches

Seite 218 - Instructions by Opcode

BRC (Branch If Carry) The BRC instruction performs a conditional branch if the Carry flag is set. The BRC instruction uses the relative addressing

Seite 219

BRF (Branch Far) The BRF instruction performs an unconditional branch. The BRF instruction uses the relative addressing mode. The

Seite 220

BRNC (Branch If Not Carry) The BRNC instruction performs a conditional branch if the Carry flag is not set. The BRNC instruction uses the relative

Seite 221

BRNEQ (Branch If Not Equal) The BRNEQ instruction compares TOS with a specified number and performs a conditional branch if they are not equal. The

Seite 222

testA brneq #d’65,testB ; ({argument}) callr do_a ; ( ) br exit testB brneq #d’66,testC ; ({argument})

Seite 223

BRNZ (Branch If Not Zero) The BRNZ instruction performs a conditional branch if TOS is not zero. The BRNZ instruction uses one of two addressing mod

Seite 224 - 1 2 7

BRZ (Branch If Zero) The BRZ instruction performs a conditional branch if TOS is zero. The BRZ instruction uses the relative addressing mode. The

Seite 225

CALL (Call Near) The CALL instruction calls a function at the specified near address. The CALL instruction uses the (short) absolute addressing mode

Seite 226

CALLF (Call Far) The CALLF instruction calls a function at the specified absolute address. The CALLF instruction uses the a

Seite 227

_less16s (Less Than Signed, 16 Bit) ... 174 _less8 (Less Than, 8 Bit) ...

Seite 228

CALLR (Call Relative) The CALLR instruction calls a function at the specified forward or backward signed relative displacement of -126 to +129 bytes.

Seite 229 - Reserved Keywords

DBRNZ (Decrement and Branch If Not Zero) The DBRNZ instruction performs two functions: it decrements the unsigned 8-bit value on the t

Seite 230 - Keywords

DEALLOC (Deallocate and Return) The DEALLOC instruction deallocates a specified number of bytes from the data stack, and performs a return from call

Seite 231

myFunction alloc #2 ; ((2)) ... ; function body dealloc #2 ; ( -- ) Neuron Assembly La

Seite 232

DEC (Decrement) The DEC instruction decrements the TOS value. The DEC instruction uses the implicit addressing mode. If the TOS value is zero prio

Seite 233

DIV (Divide) The DIV instruction performs integer division. The DIV instruction uses the implicit addressing mode. The instruction divid

Seite 234

DROP (Drop from Stack) The DROP instruction drops a value from one of the stacks: • The DROP [RSP] instruction drops the top of the return stack •

Seite 235

DROP_R (Drop from Stack and Return) The DROP_R instructions drop a value from the data stack and perform a return from call operation: • The DROP

Seite 236

INC (Increment) The INC instruction can increment the TOS value or the value of a specified pointer register. The INC instruction uses the pointer

Seite 237

Done ... ret ; return to caller Neuron Assembly Language Reference 89

Kommentare zu diesen Handbüchern

Keine Kommentare