addressing mode of 8051 micro-controller
what is addressing mode?
CPU access data from memory,register,immediate value.These various way to access data are called addressing mode.
The 8051 micro-controller are five addressing mode.
- immediate
- register
- direct
- register indirect
- index
- in this addressing mode source operand is constant.
- it's come after op code in instruction.
- it must be preceded by "#" .
- its used to load data into register.
- examples:
- MOV A,#32H ;Load 32h into A register.
- MOV DPTR,#1234H ;Load 1234h into DPTR.
- In this mode registers are used to hold data to be manipulated.
- Size of destination register and source register are always equal.
- the data between to registers Rn(n=0 to 7) and Rn(n=0 to7) do not transfer.
- examples:
- MOV A,R0 ;copy content of R0 into A.
- MOV R0,R1 ;not possible because data to be processed in some memory location of RAM.
- to access data directly form RAM location.
- using this mode we can access 128Byte RAM directly.
- in this data is in a RAM memory location whose address is known.
- the difference between immediate and direct addressing mode is "#"sign.in this mode this sign is absent.
- examples:
- MOV R0,30H ;save content of RAM location 30h into R0.
- MOV 7,2 ;invalid (it means copy content of R2 into R7).
- in this register used as pointer to the data.
- only register R0 and R1 used in this mode.
- R0 and R1 hold address of RAM location.
- both register must be preceded by "@"sign.
- looping is easily used in this mode.
- drawback of this mode is we can used two register R0 & R1 only.
- examples:
- MOV A,@R0 ;move content of RAM location whose address stored in R0.
- MOV @R1,A ;move content of A into RAM location whose address stored in R1.
- in this mode data access from look up table entire located in the program memory ROM space of 8051.
- register A and DPTR used in this addressing mode.
- here instruction MOVC used instead of MOV because C indicate Code memory(ROM).
- examples:
- MOVC A,@A+DPTR;
0 comments:
Post a Comment