Addressing mode of 8051

15
Nitin Ahire XIE,Mahim Prof. Nitin Ahire 1

description

Addressing mode of 8051 micro controller

Transcript of Addressing mode of 8051

Page 1: Addressing mode of 8051

Nitin Ahire

XIE,Mahim

Prof. Nitin Ahire 1

Page 2: Addressing mode of 8051

The CPU can access data various ways The data could be in a register, or

memory or as an immediate value The various ways of accessing data are

called addressing modes.

Prof. Nitin Ahire 2

Page 3: Addressing mode of 8051

1)Direct addressing mode2)Indirect addressing mode3)Register addressing4)Register specific addressing (optional)5)Immediate addressing6)External Addressing ( Index )

a) Code access b) Data access

Prof. Nitin Ahire 3

Page 4: Addressing mode of 8051

In this mode the operand is specified by an

8-bit address field In the instruction.

One can access all the 128 bytes of internal RAM locations and each SFR.

If the MSB bit = 0 then the location is within on chip internal RAM. If MSB bit = 1

then the location is SFR.Prof. Nitin Ahire 4

Page 5: Addressing mode of 8051

The location 00h to 7Fh to address the internal RAM .

SFR addresses from 80h to FF h

e.g. MOV A,40h MOV R0,14h

Prof. Nitin Ahire 5

Page 6: Addressing mode of 8051

In this addressing mode, the instruction specifics a register which contains address

of an operand i.e. the register hold the actual address

that will be used in the data move operation.

The R0 and R1 of each bank can be used as an index or pointer to memory location

Prof. Nitin Ahire 6

Page 7: Addressing mode of 8051

The sign @ indicates the register acts as a pointer to memory locations

E.g. MOV A,@ R1 Note : only register R0 and R1 can be

used for indirect addressing mode .

MOV A,@R2 invalid instruction.

Prof. Nitin Ahire 7

Page 8: Addressing mode of 8051

Each bank consist of register R0 to R7 can be used as general purpose register for selection of bank register, the user has to modify the two bits of PSW

These register can be used to stored the address or data in the register addressing mode

Prof. Nitin Ahire 8

Page 9: Addressing mode of 8051

E.g. MOV R2,A MOV A, R1 MOV A,R7

Note: MOV R2,R7 is an invalid instruction

Prof. Nitin Ahire 9

Page 10: Addressing mode of 8051

In this addressing mode the instruction refer to a specific registers such as accumulator or data pointer

Example: DA A SWAP A

Prof. Nitin Ahire 10

Page 11: Addressing mode of 8051

This method is the simplest method to get the data.

In this addressing mode the source operand is a constant rather then a variable.

As the data source is a part of instruction

The # sign indicates that the data followed is immediate operand.

Prof. Nitin Ahire 11

Page 12: Addressing mode of 8051

E.g. MOV A,#30h MOV P1,#0FF MOV DPTR, #1234h

Prof. Nitin Ahire 12

Page 13: Addressing mode of 8051

(a) Code access (ROM access) Using these instructions only program

memory can be accessed.

This addressing mode is preferred for reading look up tables in the program memory.

Either DPTR or PC can be used as pointer.

Prof. Nitin Ahire 13

Page 14: Addressing mode of 8051

E.g. MOVC A,@A+DPTR

MOVC A,@A+PC

Prof. Nitin Ahire 14

Page 15: Addressing mode of 8051

(b) Data access (RAM access)

Using this addressing mode the programmer can access the external Data memory

E.g. MOVX A,@DPTR

MOVX @R0,A

Prof. Nitin Ahire 15