Beruflich Dokumente
Kultur Dokumente
1) Register addressing,
2) Direct addressing,
3) Indirect addressing,
5) Immediate addressing,
4) Add the contents of register R3 and R4 from bank 2 . Store the result in A
MOV PSW, 00010000 B : Select register Bank 2
MOV A, R3 : Copy the content R3 to A
ADD A, R4 : Add content A and R4. Store the result in A.
Invalid: MOV R1, R0
Direct Addressing
In direct addressing mode, the address of the operand is specified by
an 8-bit address in the instruction.
Using this mode one can access internal data RAM and SFRs,
directly. Internal RAM uses addresses from 00H to 7FH to
address each byte. The SFR addresses exist from 80H to FFH.
For Example:
1) MOV A, 80H : Copy data from the port 0 to register A
2) MOV 80H, A : Copy data from the register A to port 0
3) MOV 0F0, 12H : Copy data from RAM location 12H to register B
4) MOV 8CH, R7 : Copy data from the resister R7 to timer 0 high byte
5) MOV 5CH, A : Copy data from register A to RAM location 5CH
6) MOV 0A8, 77H : Copy data from RAM location 77H to IE register
Disadvantages : Looping is not possible in direct addressing mode
Indirect Addressing
In indirect addressing mode instruction specifies a register which
holds address of an operand.
In this mode, only registers R0 or R1 may be used to hold the
address of one of the data location in RAM from address 00H to
FFH.
Note : The symbol used for indirect addressing is the "at" sign,
which is printed as @. @Ri means register R1 or R0
addressing internal RAM locations from 00H to FFH.
For Example :
1) MOV A, @ R0 :Copy contents of memory location, whose address
is specified in R0 of selected bank to accumulator.
2) ADD A., @ R1 : Add the contents of memory location, whose address is
specified in R1 and accumulator. Store the result in A.
3) ANL A, @ R0 : AND each bit of A with same bit of the contents of
address contained in R0. Store result in A.
4) MOVX @ DPTR, A
Indirect Addressing ( contd..)
Advantage:
It makes accessing a data dynamics rather than static or in the
case of direct addressing mode.
For examples :
MOV A, #55H MOV R1, # 06 Count
MOV 40, A MOV A, # 55H Data
MOV 41, A MOV R0, # 40 Memory Location
MOV 42, A UP MOV @ R0, A
MOV 43, A INC R0
MOV 44, A DJNZ R1, UP
MOV 45, A END
Limitation :
R0 and R1 ( 8-bit wide ) are the only registers that can be
used for pointer in register indirect addressing mode.
Register Specific Addressing
In the register specific addressing mode, the operand is
specified by certain specific register such as accumulator or
DPTR.
For Example:
1) SWAP A : SWAP nibbles within the accumulator
2) DA A : Decimal adjust accumulator
3) RR A : Rotate the contents of accumulator to the right.
Immediate Addressing
In immediate addressing mode the operand is specified within
the instruction itself. In this "data" is part of the instruction.
Note : The mnemonic for immediate data is the pound sign (#).
'#' sign is used in the instruction to indicate the
"immediate" data
For Example:
1) MOV A, # 30H : Move data 30H immediately to accumulator
2) MOV B, # 50H : Move data 50H immediately to B register
3) MOV DPTR, #0ABCDH : Move the immediate data bytes
ABCDH to the DPTR
4) MOV P1, # 00H : Move data 00H immediately to port 1.
Note : The use of leading 0 for all numbers that begin with an alphabetic
character.
Index Addressing
1) MOVC A, @ A + DPTR : Copy the code byte, found at the ROM address
formed by adding A and the DPTR, to A.
2) MOVC A, @ A + PC : Copy the code byte, found at the ROM address
formed by adding A and the PC, to A.
Physical address space in 8051
The 8051 supports several physical address spaces.