beautypg.com

2 direct addressing, 3 register indirect addressing, Ddressing – Maxim Integrated High-Speed Microcontroller User Manual

Page 60: Odes, Register addressing

background image

High-Speed Microcontroller User’s Guide

Rev: 062210

60 of 176

4.4.2 Direct Addressing

Direct Addressing is the mode used to access the entire lower 128 bytes of Scratchpad RAM and the SFR
area. It is commonly used to move the value in one register to another. Two examples are shown below.

MOV

72h, 74h

;Move the value in register 74 to
;register 72.

MOV

90h, 20h

;Move the value in register 20 to
;the SFR at 90h (Port 1)

Note that there is no instruction difference between a RAM access and an SFR access. The SFRs are
simply register locations above 7Fh.

Direct Addressing also extends to bit addressing. There is a group of instructions that explicitly use bits.
The address information provided to such an instruction is the bit location, rather than the register
address. Registers between 20h and 2Fh contain bits that are individually addressable. SFRs that end in 0
or 8 are bit addressable. An example of Direct Bit Addressing is as follows.

SETB 00h

;Set bit 00 in the RAM. This is the
;LSb of the register at address 20h
;as shown in Section 4.

MOV

C, 0B7h

;Move the contents of bit B7 to the
;Carry flag. Bit B7 is the MSb of
;register B0 (Port 3).

4.4.3 Register Indirect Addressing

This mode is used to access the Scratchpad RAM locations above 7Fh. It can also be used to reach the
lower RAM (0h–7Fh) if needed. The address is supplied by the contents of the Working Register
specified in the instruction. Thus one instruction can be used to reach many values by altering the
contents of the designated Working Register. Note that in general, only R0 and R1 can be used as
pointers. An example of Register Indirect Addressing is as follows.

ANL

A, @R0

;Logical AND the Accumulator
;with the contents of the register

;pointed to by the value stored in

R0.

This mode is also used for Stack manipulation. This is because all Stack references are directed by the
value in the Stack Pointer register. The Push and Pop instructions use this method of addressing. An
example is as follows.

PUSH A

;Saves the contents of the
;accumulator on the stack.

Register Indirect Addressing is used for all off-chip data memory accesses. These involve the MOVX
instruction. The pointer registers can be R0, R1, DPTR0, and DPTR1. Both R0 and R1 reside in the
Working Register area of the Scratchpad RAM. They can be used to reference a 256-byte area of off-chip
data memory. When using this type of addressing, the upper address byte is supplied by the value in the
Port 2 latch. This value must be selected by software prior to the MOVX instruction. An example is as
follows.

MOVX @R0, A

;Write the value in the accumulator
;to the address pointed to by R0 in
;the page pointed to by P2.