Specifications
65 www.zylogic.com.cn
The bits in these SFRs are addressed by adding
the bit position to the SFR address.
Example:
MOV 20h, 21h ; Move contents of RAM location 20h to
; RAM location 21h
MOV P1, P3 ; Move data at Port 1 Pins to Port 3 latch
SETB 7Fh ; Set bit 7Fh in Scratchpad RAM. This is
; actually MSB of the RAM location 2Fh.
MOV TR1, C ; Move carry flag contents to TR1 flag in
; TCON SFR
R
R
e
e
g
g
i
i
s
s
t
t
e
e
r
r
I
I
n
n
d
d
i
i
r
r
e
e
c
c
t
t
A
A
d
d
d
d
r
r
e
e
s
s
s
s
i
i
n
n
g
g
Register Indirect addressing mode uses the R0
and R1 registers to store the address of the se-
lected Scratchpad RAM location. By changing the
contents of R0 or R1, the same instruction will ad-
dress different RAM locations. However, this ad-
dressing mode is limited to the 128 bytes of
Scratchpad RAM only (the upper 128 bytes). Spe-
cial Function Registers (SFRs) cannot be ad-
dressed by this method.
Example:
MOV R0, #20h ; Load register R0 with 20h
MOV A, @R0 ; Move contents of RAM location 20h to
; the Accumulator
Stack operations are also examples of Register
Indirect addressing. In this case, the SFR Stack
Pointer (SP) stores the address rather than the
working registers R0 and R1. Instructions like
PUSH and POP use this mode of addressing.
Example:
PUSH TCON ; Save the contents of SFR TCON onto the
; stack
POP DPL ; Loads the SFR DPL with the data at the
; top of the stack
Data Memory may also be accessed using Regis-
ter Indirect Addressing mode. The MOVX instruc-
tions are used for this purpose. The registers R0,
R1, DPTR or DPTR1 can be used as pointers for
this purpose. When using R0 and R1 as pointers,
the lower 8-bits of the address are the contents of
R0 or R1, while the upper 8-bits of the address are
supplied by the P2 SFR. The P2 SFR must there-
fore be set to the correct value before using this
instruction. When using DPTR or DPTR1 as the
pointer, then the entire 16-bit address is taken from
the selected Data Pointer.
Example:
MOVX @R0, A ; Moves the Accumulator contents to the
; external Data Memory locations pointed to
; by R0 in the page pointed to by the P2
; SFR.
MOVX A, @DPTR ; Move data from the Data Memory pointed
: to by the selected Data Pointer, into the
: Accumulator.
I
I
m
m
m
m
e
e
d
d
i
i
a
a
t
t
e
e
A
A
d
d
d
d
r
r
e
e
s
s
s
s
i
i
n
n
g
g
Immediate addressing is used when part of the op-
code instruction is a constant. This method is most
commonly used to initialize registers and SFRs or
to perform mask operations.
Example:
MOV A, #40h ; Mov 40h to Accumulator
XRL SCON, #FFh ; Xor SCON SFR with FFh, thereby
; complementing its contents
B
B
a
a
s
s
e
e
R
R
e
e
g
g
i
i
s
s
t
t
e
e
r
r
p
p
l
l
u
u
s
s
I
I
n
n
d
d
e
e
x
x
R
R
e
e
g
g
i
i
s
s
t
t
e
e
r
r
I
I
n
n
d
d
i
i
r
r
e
e
c
c
t
t
A
A
d
d
-
-
d
d
r
r
e
e
s
s
s
s
i
i
n
n
g
g
This addressing mode provides access to a byte
from the 8032's program memory—separate from
data memory—via an indirect move. The address
of the move location is the sum of the base register
(PC or DPTR/DPTR1) and an index register (ACC).
The result is always written to the ACC, overwriting
the index value that previously resided there.
Example:
MOV DPTR, #1234h ; Data Pointer is loaded with constant
; 1234h
MOV A, #23h ; Accumulator is loaded with index
; value 23h
MOVC A, @A+DPTR ; Accumulator is loaded with byte from
; the Program Memory at location
; 1234h + 23h = 1257h
R
R
e
e
l
l
a
a
t
t
i
i
v
v
e
e
A
A
d
d
d
d
r
r
e
e
s
s
s
s
i
i
n
n
g
g
Relative Addressing is used to specify the destina-
tion address for jumps within 128 bytes of the cur-
rent program counter, common is short looping
functions.
The destination address is given in the form of a
two’s complement address offset that is added to
the PC. The relative address is one byte long, and
so the offset will vary from -128 to +127.
Example:
SJMP 20h ; Jump to a location 20h bytes after the current
; instruction. If the SJMP instruction is at
; 1010h, then the jump will be to location
; 1010h + 2h + 20h = 1032h
JZ FEh ; If the Accumulator is zero, then jump to the
; same instruction ; If the JZ instruction is at
; 2359h, then the jump will be to location
; 2359h + 2h + FEh = 2359h + 2h - 2h = 2359h