Echelon Neuron Manuale Utente

Navigare online o scaricare Manuale Utente per Hardware Echelon Neuron. Echelon Neuron User Manual Manuale Utente

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 237
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti

Sommario

Pagina 1 - Language Reference

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

Pagina 2

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

Pagina 3 - Related Documentation

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

Pagina 4

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 9

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

Pagina 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

Pagina 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

Pagina 12

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

Pagina 13 - Neuron Assembler Tools

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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,

Pagina 18

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 30

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 35 - Segments

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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.

Pagina 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: •

Pagina 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

Pagina 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

Pagina 48

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

Pagina 49

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

Pagina 50

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

Pagina 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

Pagina 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

Pagina 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:

Pagina 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

Pagina 55

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

Pagina 56

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 61 - Data Representation

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

Pagina 62 - Bitfields

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

Pagina 63

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

Pagina 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

Pagina 65

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

Pagina 66

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

Pagina 67

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

Pagina 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

Pagina 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

Pagina 70

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

Pagina 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

Pagina 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

Pagina 73

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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 -

Pagina 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

Pagina 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

Pagina 80 - BR (Branch)

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

Pagina 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

Pagina 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

Pagina 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)) _

Pagina 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

Pagina 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

Pagina 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

Pagina 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) ;

Pagina 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

Pagina 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

Pagina 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

Pagina 91

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

Pagina 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

Pagina 93

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

Pagina 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)

Pagina 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

Pagina 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

Pagina 97

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

Pagina 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

Pagina 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)

Pagina 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.

Pagina 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

Pagina 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

Pagina 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)

Pagina 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

Pagina 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’

Pagina 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.

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 112 - PUSH (Push onto Stack)

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

Pagina 113 - PUSH [1][offset]

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

Pagina 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,

Pagina 115

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

Pagina 116

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

Pagina 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

Pagina 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

Pagina 119 - Data Stack)

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

Pagina 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

Pagina 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.

Pagina 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

Pagina 123

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

Pagina 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

Pagina 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

Pagina 126

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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 =

Pagina 132

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

Pagina 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

Pagina 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

Pagina 135 - SUB (Subtract)

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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]

Pagina 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

Pagina 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

Pagina 145

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 155

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

Pagina 156

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

Pagina 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

Pagina 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

Pagina 159

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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)

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 175 - _div8 (Divide, 8 Bit)

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

Pagina 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

Pagina 177

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

Pagina 178

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

Pagina 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

Pagina 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

Pagina 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

Pagina 182

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

Pagina 183

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

Pagina 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.

Pagina 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

Pagina 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):

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 194 - _mul8 (Multiply, 8 Bit)

Implicit ... 31 Pointer Direct...

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 201

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

Pagina 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

Pagina 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) {

Pagina 204

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

Pagina 205 - Listed by Mnemonic

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

Pagina 206 - Instructions by Mnemonic

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

Pagina 207

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

Pagina 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

Pagina 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

Pagina 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.

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 216

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

Pagina 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

Pagina 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

Pagina 219

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

Pagina 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

Pagina 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

Pagina 222

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

Pagina 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

Pagina 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

Pagina 225

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

Pagina 226

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

Pagina 227

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

Pagina 228

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

Pagina 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

Pagina 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

Pagina 231

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

Pagina 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

Pagina 233

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

Pagina 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 •

Pagina 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

Pagina 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

Pagina 237

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

Commenti su questo manuale

Nessun commento