Tuesday, March 22, 2016

8051 Data Types and Directives

Data Type
8051 has only one data type. It is 8 bits. It is the programmer responsibility to break down data larger than 8 bits to be processed by the CPU. Data type can be positive or negative

Number Representation
46d ; 46 decimal
2Eh ; 2Eh is 46 decimal represented as a hex number
56o ; 56o is 46 decimal represented as an octal number
101110b ; 101110b is 46 decimal represented as a binary number.
Note a number digit must be used in the first character of a hexadecimal number. For example the hexadecimal number A5h is illegally represented and should be represented as 0A5h.

Directive
ORG (OriGinate or Origin) defines the starting address for the program in program (code) memory. Some assembler use .ORG for the origin directive.
ORG 0H; place this program at address 0H
LABEL1 :...
END; end of asm source file

ORG 200H; place this program at address 200H
LABEL1 :...
END; end of asm source file

ORG 600H; place this program at address 600H
LABEL1 :...
END; end of asm source file

EQU (equate) directive is used to define a constant without occupying a memory location. EQUate, assigns a numeric value to a symbol identifier so as to make the program more readable
COUNT   EQU   34
MOV R1, #COUNT
We can also use the EQU directive to assign addresses.
SW   EQU   P0.1
MYDATA   EQU   P2
...
MOV C, SW
MOV MYDATA, #55H
....
DB (Define Byte) directive is used to define the 8-bit data. Puts a byte number constant at this memory location.
Data1 :DB 30; Decimal
Data2 :DB 0101B; Binary
Data3 :DB 40H; Hexadecimal
Data4 :DB ‘A’; Characters
Data5 :DB “Sample”; Strings
Data6 :DB “2591”; ASCII numbers

DW (Define Word) directive is used to define the 16-bit data. Puts a word number constant at this memory location.

DBIT (Define a Bit) defines a bit constant, which is stored in the bit addressable section of the Internal RAM. The BIT directive is a widely used directive to assign the bit-addressable I/O and RAM locations. The BIT directive allows a program to assign the I/O or RAM bit at the beginning of the program, making it easier to modify them.
LED DBIT P0.1
HERE :CPL LED
LCALL DELAY
SJMP HERE

END directive indicates the end of source (asm) file. It is the last line of the program. Anything after END will be ignored by assembler. Some assembler use .END for the END directive. This is the last statement in the source file to advise the assembler to stop the assembly process.



Related topics:
8051 Assembly Programming   |   8051 Assembling a Program   |   8051 Simulator   |   8051 Instruction Set Overview   |   8051 Instruction Set Summary

List of topics: 8051

No comments:

Post a Comment