Different types of addressing modes in 8051.
Addressing:-The CPU
can access data in a register or in memory or be provided as an immediate
value. These various ways of accessing data are called addressing modes.
The 8051 provides a total of five distinct
addressing modes.
They are as follows:-
1) Immediate addressing modes.
2) Register addressing modes.
3) Direct addressing modes.
4) Register indirect - addressing mode.
5) Indexed addressing mode.
Let us study different modes with selective
examples:-
1) Immediate Addressing mode:-
In This
addressing mode, the source operated is a constant i.e. immediate data. Note
that the immediate data must be preceded by the pound sign"#".
Example:-
MOV A, # 82H ; load 82H into A
MOV R4, # 100 ; load the decimal value 100 in to R4
MOV B, # 40H ; load 40H in to B
MOV P1, # 55H ; load 55H directly to port 1
MOV DPTR , # 4521 H ; DPTR =4521 H
2)
Register - Addressing Mode:-
Register addressing mode involves the use of
registers to hold data to be manipulated.
Example:-
MOV A,RO ;copy the contents
of R0 in to A
MOV R2,A ;copy the contents
of A in to R2
ADD A,R5 ;Add contents of
R5 to A
MOV R7,DPL ;load R7 with
contents of DPL
3)
Direct Addressing mode:-
In direct
addressing mode the data is in a RAM Memory location whose addressing is known
and this address is given as a part of the instruction.
Although the entire 128 bytes of RAM
com be addressed Using direct addressing mode
It is most often used to access RAM
locations 30-7FH
Example:-
MOV R0, 40H ; save content of RAM location 40H in
Ro
MOV 7FH, A ; save content of A in to RAM location
7FH
MOV A,07H ;same as move A1 R7 is copies data in R7
to A
MOV 03H, 04H ; it copies data in R4 to R3
4)
Indirect addressing mode:-
In the register indirect addressing mode a
register is used as a pointer to the data .only register R0 and R1 are used for
internal RAM indirect Data transfer.
When
they hold the address of Rom locations they must be preceded by the “@” symbol.
Example :-
MOV ,A, @R0 ;move contents of Ram location
whose address is help
By R0 in to A
MOV @ R1 ,B ;move contents of B in to RAM
location whose Address is
help by R1.
5)
Indexed addressing mode :-
Indexed addressing mode
is widely used in accessing data elements of look-up table entries located in the program Rom space of the 8051.
Example :-
MOV A, @ A +
DPTR
MOV A, @ A+ PC
This comment has been removed by the author.
ReplyDeleteThank you for posting detailed and well describe information about 8051 can you please describe what is difference between raspberry pi and 8051 ic
DeleteJTAG