Professional Documents
Culture Documents
FALLSEM2021-22 ECE3003 ETH VL2021220101798 Reference Material I 17-08-2021 Addressing Modes and Instruction Set
FALLSEM2021-22 ECE3003 ETH VL2021220101798 Reference Material I 17-08-2021 Addressing Modes and Instruction Set
OPCODE OPERAND
OPERAND
OPCODE
MOV A, R0
OPERAND
OPCODE
ADDRESSING MODES
MOV DPTR,#1000H (DPTR-16 bit register named as “Data Pointer” = Holds address of ROM)
Rules:
Ex)
R1 content will be 02
Rules:
Rules:
MOV R1,#03H
MOV A,R1
MOV R0,A
END
Ex)
Example Program:
Rules:
Ex)
Instruction Set
1. Data Transfer Instructions :
a) Move Instructions:
(n- 8 bit data; Rr = R0 to R7; nn-16 bit data; Rp = R0 &
R0)
MOV A,#n
MOV Rr,#n
Ex) MOV R0,# 03H
MOV Rr, A
Ex) MOV A,#06h; A <= 06
MOV R0,A ;R0<=06;A=06H
MOV A,Rr
MOV Add1,Add2
Ex)MOV 07h,03H
b) Exchange Instructions:
XCH A,Rr
EX) MOV A,#23H
MOV R0,#55H
XCH A,R0
END
A<= 55H; R0 <=23H
XCH A, ADD
-Exchanges contents of A with specified
address
XCH A,Rp
XCH A,@Rp
Ex)
MOV R0,#30H
MOV 30H,#55H (Since RAM address range 00h-7FH)
MOV A,#44H
XCH A,@R0
END
- 30 H< = 44H ; A<= 55H
- XCHD A,@RP
1
Ex) FF FF
+ FF FF
_______________
1 FF FE
_______________
MOV A,#0FFH
ADD A,#0FFH (FF+FF =>1FE ;FE=>A &CY <= 1)
MOV R0,A (R0 <= FE)
MOV A,#0FFH
ADDC A,#0FFH ; ( (A)+FF+CY) (A<= FF & CY <=1)
END
Final Result ; (A) = FF;(R0) = FE;(CY) =1
Ex)
MOV A,#03H
ADD A,#08H
DA A ; A <=11
END
NOTE:
DA A instruction must be used only after ADD
instruction
EX)
MOV A,#32H
DA A ----------- It won’t work (before DA A we
have to use ADD instruction)
5. Branching Instruction
Relative jump = 127d to -128d(- Indicates
backward dir)
Ex) DJNZ,JNC….
Absolute range = 2K
Ex) AJMP,ACALL….
Long Range = within 64KB
Ex) LJMP,LCALL….
Note:
1. JZ,JNZ,JC,JNC Used Only with A register
2. JZ,JNZ,JC,JNC demands an ALU instruction must be
executed before using these instructions.
Ex)
MOV A,#23H
JNC ,XX
MOV B,#32H
XX: END
JNC Won’t work since MOV A,#23H is not an ALU
Instruction
MOV A,#23H
ADD A,#32H
JNC ,XX
MOV B,#32H
XX: END
Now JNC Will work
1. Let R5 = 90
CJNE R5,#80,XX ( Internally 90-80 =+sign so no carry)
XX: JNC
2. Let R5 = 70
CJNE R5,#80,XX( Internally 70-80 = -sign so there is a
carry)
XX: JC
3. Let R5 = 80
CJNE R5,#80,XX (Condition Fails so no jump)
-