0 item/s in cart
Assembly language is basically like any other language, which means that it has its words, rules and syntax. The basic elements of assembly language are:
IF (VERSION>1) LCALL Table_2 USING VERSION+1 ENDIF ...As seen, the assembly language is capable of computing some values and including them in a program code, thus using the following mathematical and logical operations:
|/||Division (with no remainder)||7/4||1|
|MOD||Remainder of division||7 MOD 4||3|
|SHR||Shift register bits to the right||1000B SHR 2||0010B|
|SHL||Shift register bits to the left||1010B SHL 2||101000B|
|NOT||Negation (first complement of number)||NOT 1||1111111111111110B|
|AND||Logical AND||1101B AND 0101B||0101B|
|OR||Logical OR||1101B OR 0101B||1101B|
|XOR||Exclusive OR||1101B XOR 0101B||1000B|
|LOW||8 low significant bits||LOW(0AADDH)||0DDH|
|HIGH||8 high significant bits||HIGH(0AADDH)||0AAH|
|EQ, =||Equal||7 EQ 4 or 7=4||0 (false)|
|NE,<>||Not equal||7 NE 4 or 7<>4||0FFFFH (true)|
|GT, >||Greater than||7 GT 4 or 7>4||0FFFFH (true)|
|GE, >=||Greater or equal||7 GE 4 or 7>=4||0FFFFH (true)|
|LT, <||Less than||7 LT 4 or 7<4||0 (false)|
|LE,<=||Less or equal||7 LE 4 or 7<=4||0 (false)|
START_ADDRESS_OF_TABLE_AND_CONSTANTS_1 START_ADDRESS_OF_TABLE_AND_CONSTANTS_2 TABLE_OF_CONSTANTS_1_START_ADDRESS TABLE_OF_CONSTANTC_2_START_ADDRESS
MAXIMUM EQU 99After using this directive, every appearance of the label “MAXIMUM” in the program will be interpreted by the assembler as the number 99 (MAXIMUM = 99). Symbols may be defined this way only once in the program. The EQU directive is mostly used at the beginning of the program therefore.
SPEED SET 45 SPEED SET 46 SPEED SET 57
TRANSMIT BIT PSW.7 ;Transmit bit (the seventh bit in PSW register) ;is assigned the name "TRANSMIT" OUTPUT BIT 6 ;Bit at address 06 is assigned the name "OUTPUT" RELAY BIT 81 ;Bit at address 81 (Port 0)is assigned the name ;"RELAY"
RESET CODE 0 ;Memory location 00h called "RESET" TABLE CODE 1024 ;Memory location 1024h called "TABLE"
TEMP12 DATA 32 ;Register at address 32 is named ;as "TEMP12" STATUS_R DATA D0h ;PSW register is assigned the name ;"STATUS_R"
TEMP22 IDATA 32 ;Register whose address is in register ;at address 32 is named as "TEMP22" TEMP33 IDATA T_ADR ;Register whose address is in ;register T_ADR is named as "TEMP33"
TABLE_1 XDATA 2048 ;Register stored in external ;memory at address 2048 is named ;as "TABLE_1"
BEGINNING ORG 100 ... ... ORG 1000h TABLE ... ...This program starts at location 100. The table containing data is to be stored at location 1024 (1000h).
USING 0 ;Bank 0 is used (registers R0-R7 at RAM-addresses 0-7) USING 1 ;Bank 1 is used (registers R0-R7 at RAM-addresses 8-15) USING 2 ,Bank 2 is used (registers R0-R7 at RAM-addresses 16-23) USING 3 ;Bank 3 is used (registers R0-R7 at RAM-addresses 24-31)
... END ;End of program
CSEG ;Indicates that the next segment refers to program memory; BSEG ;Selects bit-addressable part of RAM; DSEG ;Indicates that the next segment refers to the part of internal RAM accessed by ;direct addressing; ISEG ;Indicates that the next segment refers to the part of internal RAM accessed by ;indirect addressing using registers R0 and R1); and XSEG ;Selects external RAM memory.The CSEG segment is activated by default after enabling the assembler and remains active until a new directive is specified. Each of these memory segments has its internal address counter which is cleared every time the assembler is activated. Its value can be changed by specifying value after the mark AT. It can be a number, an arithmetical operation or a symbol. For example:
DSEG ;Next segment refers to directly accessed registers; and BSEG AT 32 ;Selects bit-addressable part of memory with address counter ;moved by 32 bit locations relative to the beginning of that ;memory segment.A dollar symbol "$" denotes current value of address counter in the currently active segment. The following two examples illustrate how this value can be used practically: Example 1:
JNB FLEG,$ ;Program will constantly execute this ;instruction (jump instruction),until ;the flag is cleared.Example 2:
MESSAGE DB ‘ALARM turn off engine’ LENGTH EQU $-MESSAGE-1These two program lines can be used for computing exact number of characters in the message “ALARM turn off engine” which is defined at the address assigned the name “MESSAGE”.
DSEG ;Select directly addressed part of RAM DS 32 ;Current value of address counter is incremented by 32 SP_BUFF DS 16 ;Reserve space for serial port buffer ;(16 bytes) IO_BUFF DS 8 ;Reserve space for I/O buffer in size of 8 bytesExample 2:
ORG 100 ;Start at address 100 DS 8 ;8 bytes are reserved LAB ......... ;Program proceeds with execution (address of this location is 108)
BSEG ;Bit-addressable part of RAM is selected IO_MAP DBIT 32 ;First 32 bits occupy space intended for I/O buffer
CSEG DB 22,33,’Alarm’,44If this directive is preceeded by a lable, then the label will point to the first element of the array. It is the number 22 in this example.
IF (VERSION>3) LCALL Table_2 LCALL Addition ENDIF ...If the program is of later date than version 3 (statement is correct), subroutines “Table 2” and “Addition” will be executed. If the statement in parentheses is not correct (VERSION<3), two instructions calling subroutines will not be compiled. Example 2: If the value of the symbol called “Model” is equal to one, the first two instructions following directive IF will be compiled and the program continues with instructions following directive ENDIF (all instructions between ELSE and ENDIF are ignored). Otherwise, if Model=0, instructions between IF and ELSE are ignored and the assembler compiles only instructions following directive ELSE.
IF (Model) MOV R0,#BUFFER MOV A,@R0 ELSE MOV R0,#EXT_BUFFER MOVX A,@R0 ENDIF ...