0% found this document useful (0 votes)
30 views16 pages

LAB 4 8051 Assembler Directives

Uploaded by

tanveer1111110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views16 pages

LAB 4 8051 Assembler Directives

Uploaded by

tanveer1111110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

LAB 4

8051 ASSEMBLER
DIRECTIVES
INTRODUCTION

These directives change the state of the assembler,


define user symbols, and add information to the
object file.

1. Address Control
2. Symbol Definition
3. Memory Initialization
4. Others
ASSEMBLER DIRECTIVES
1. Address Control
 ORG, USING
2. Symbol Definition
 Generic Symbols: EQU, SET
 Address Symbols: BIT, DATA, XDATA
 SFR Symbols: sfr, sbit

3. Memory Initialization
 DB, DW, DD
4. Others
 END
EQU & SET DIRECTIVES - EXAMPLES
 LIMIT EQU 1200
 VALUE EQU LIMIT – 200
 SERIAL EQU SBUF

 ACCU EQU A
 COUNT EQU R5
 VALUE SET 100
 COUNTER SET R1

 TEMP SET COUNTER


 TEMP SET VALUE * VALUE
EQU & SET DIRECTIVES
 Symbols defined with EQU may not have been
previously defined by EQU and may not be redefined by
any means (EQU/SET).
• The SET directive allows later redefinition of
symbols.
EQU & SET DIRECTIVES

x equ 10h
x set 45h ;error
x equ 45h ;error
counter set r1
counter set r2
counter equ r2
BIT, DATA, AND XDATA

 The BIT, DATA and XDATA directives assigns


an address value to the specified symbol.
 Symbols defined with the BIT, DATA and
XDATA directives may not be changed or
redefined.
FORMAT
 symbol BIT bit_address defines a BIT symbol
 symbol DATA data_address defines a DATA symbol
 symbol XDATA xdata_address defines a XDATA symbol
TERMS EXPLANATION
 symbol is the name of the symbol to define. The
symbol name can be used anywhere an address of
this memory class is valid.
 bit_address is the address of a bit in internal data
memory in the area20H .. 2FH
 data_address is a data memory address in the
range 0 to 127 or a special function register (SFR)
address in the range 128 .. 255.
 xdata_address is an xdata memory address in the
range 0 to 65535.
ASSEMBLER DIRECTIVES
 DATA
 Used to define a name for memory locations
SP DATA 0x81 ;special function registers
MY_VAL DATA 0x44 ;RAM location

Address, number, Arithmetic expression


 EQU
 Used to create symbols that can be used to represent
registers, numbers, and addresses
LIMIT EQU 2000
VALUE EQU LIMIT – 200 + 'A'
SERIAL EQU SBUF
COUNT EQU R5
MY_VAL EQU 0x44
Registers, addresses, numbers,
Arithmetic expression
SFR SBIT
 sfr sfr_symbol = address;
 sbit sfr_symbol = bit-address;

 sfr_symbol is the name of the special function


register (SFR) symbol to define.
 address is an SFR address in the range 0x80 –
0xFF.
 bit-address is address of an SFR bit in the format
address ^ bitpos or sfr_symbol ^ bitpos. address or
sfr_symbol refers to an bit- addressable SFR and
bitpos specifies the bit position of the SFR bit in
the range 0 – 7.
EXAMPLES
 sfr P0 = 0x80;
 sfr P1 = 0x90;

 sbit P0_0 = P0^0;

 sbit P1_1 = 0x90^1;


ASSEMBLER DIRECTIVE - EXAMPLE
Org 0
limit equ 10h
symbol Set 20h
x bit 0
y data 30h
sbit P_Sensor= P0.0

mov y,#limit
mov y,#symbol
setb x
mov p0,#0
setb P_Sensor
clr P_Sensor

end
MEMORY INITIALIZATION
The memory initialization directives are
used to initialize code or constant space
in byte units.
DB DIRECTIVE
 The DB directive initializes code memory with
8-bit (1 byte) values. The DB directive has the following
format:
 label: DB expression , expression …

where
 label is the symbol that is given the address of the
initialized memory.
 expression is a byte value. Each expression may be a
symbol, a character string, or an expression.
DB DIRECTIVE - EXAMPLES

Org 10h
DB 1,2,3,4,5,6

Org 100h
REQ: DB 1,2,3,4,5,6
TABLE: DB 0,1,8,'A','0', ';'
ZERO: DB 0, '‘ ''

You might also like