SlideShare a Scribd company logo
1 of 17
INSTRUCTION SET SUMMARY 8051
-1-
CHAPTER 3
INSTRUCTION SET SUMMARY
Structure of Assembly Language
[label:] Mnemonic [operands] [;comment]
LOOP: MOV A,#01H ; Write 1 to Acc
MOV R7,A ;(R7) οƒŸ (A)
[PC] op code [operands] [ ]
8000H 74H 01H
8002H FFH
Figure 3.1 Structure of Assembly Language
Symbol Interpretation
οƒŸ Is replaced by ….
( ) The contents of …
(( )) The data pointed at by ….
rrr One of 8 register; 000 = R0, 001 = R1, 010=R2,..etc
dddddddd Data bits
aaaaaaaa Address bits (byte address)
bbbbbbbb Address of a bit (bit address)
i Indirect addressing using R0 or R1
eeeeeeee 8-bit relative address (or offset)
Assembler
INSTRUCTION SET SUMMARY 8051
-2-
ADDRESSING MODES
Eight types addressing modes
β€’ Register
β€’ Direct
β€’ Indirect
β€’ Immediate
β€’ Relative
β€’ Absolute
β€’ Long
β€’ Indexed
Register Addressing
The 8051 assembly language indicates register addressing with the symbol Rn
where n is from 0 to 7.
Opcode n
Register Addressing
Examples:-
MOVRn,A ORL A,Rn
Bytes: 1 Bytes: 1
Cycle: 1 Cycle: 1
Encoding: 11111rrr Encoding: 01001rrr
Operation: (Rn) οƒŸ (A) Operation: (A) οƒŸ (A) OR (Rn)
Example: MOV R3,A Example: ORL A,R5
Encoding: 11111011 or FBH Encoding: 01001101 or 4DH
INSTRUCTION SET SUMMARY 8051
-3-
For instruction using register addressing, either the source or destination
operand contains a register.
Example
MOVA,R7
Bytes : 1
Cycles : 1
Encoding : 11101rrr
Operation : (A) οƒŸ (Rn)
EFH. This instruction moves the 8-bit content of register 7 to the
accumulator.
There are 4 β€œbanks” of working register –, address 00 οƒ  1FH, but only one
is active at a time.
For Example:-
MOV PSW,#00011000B
PSW
BIT 7 BIT 0
Carry Aux. C Flag0 R.Bank 1 R. Bank 0 Overflow Reserved Even. P
CY AC F0 RS1 RS0 0V - P
RS1 RS0
0 0 bank 0; addresses 00H - 07H
0 1 bank 1: addresses 08H - 0FH
1 0 bank 2: addresses 10H - 17H
1 1 bank 3: addresses 18H – 1FH
Activates register bank 3 by setting the register bank select bits (RS1 and
RS0) in PSW bit positions 4 and 3.
Some instructions are specific to a certain register so address bits are not
needed. The opcode itself indicates the register.
For Example:-
INC DPTR ;(DPTR) οƒŸ (DPTR) + 1
INSTRUCTION SET SUMMARY 8051
-4-
Is a 1-byte instruction that adds 1 to the 16-bit data pointer.
Example3-2
What is the opcode for the following instruction?
What does it do?
MUL AB
Opcode = A4H
Operation : (B) οƒŸ HIGHBYTE OF (A) x (B)
(A) οƒŸ LOWBYTE OF (A) x (B)
Direct Addressing
Direct addressing can access any on-chip variable or hardware register. An
additional byte is appended to the opcode specifying the location to be
used. Only internal RAM and SFRs can be directly accessed.
OPCODE
Direct address
Example:-
MOV P1,A ; (direct) οƒŸ (A).
Opcode = 11110101
Direct Address = aaaaaaaa
Transfer the content of Acc to Port 1.
Using Appendix C as a reference the complete encoding of this instruction
is
11110101 – 1st
byte (opcode)
10010000 – 2nd
byte (address of P1)
INSTRUCTION SET SUMMARY 8051
-5-
Examples:-
MOV direct,A DEC direct
Bytes: 2 Bytes: 2
Cycle: 1 Cycle: 1
Encoding: 11110101 aaaaaaaa Encoding: 00010101 aaaaaaaa
Operation: (direct) οƒŸ (A) Operation: (direct) οƒŸ (direct) - 1
Example: MOV 20H,A Example: DEC B ; B is at 0F0H
Encoding: F5H 20H Encoding: 15H F0H
Moving data
MOV R5,A ; (R5) οƒŸ (A)
MOV A,R0 ; (A) οƒŸ (R0)
Logical operations
ANL A,R5 ; (A) οƒŸ (A) AND (R5)
XRL R5,A ; (R5) οƒŸ (R5) exOR (A)
Arithmetic Operation
ADD A,R3 ; (A) οƒŸ (A) + (R3)
ADDC A,R3 ; (A) οƒŸ (A) + (R3) + C
INSTRUCTION SET SUMMARY 8051
-6-
Indirect Addressing
The instruction specifies a register which contains the address of the
operand.
Opcode i
Examples:-
MOVX @Ri,A ADD A,@Ri
Bytes: 1 Bytes: 1
Cycle: 2 Cycle: 1
Encoding: 1111001i Encoding: 0010011i
Operation: ((Rn)) οƒŸ (A) Operation: (A) οƒŸ (A) OR ((Ri))
Example: MOVX @R0,A Example: ADD A,@R1
Encoding: F2H Encoding: 27H
Example:-
MOV A,@R0
The Source is the memory location pointed by R0, the contents of which
are copied into the Accumulator which is the destination register.
MOV @R1,A
The Accumulator is the source and its contents are copied into the
destination which is the memory location pointed by R1.
Example:-
(a) What is the opcode for the following instruction?
(b) What does this instruction do?
MOV A,@R0
INSTRUCTION SET SUMMARY 8051
-7-
Solution
(a) E6H
(b) The instruction moves a byte of data from internal RAM to the
Accumulator. The data are moved from the location whose address is
in R0.
Examples:-
MOVX A,@DPTR MOVX @DPTR,A
Bytes: 1 Bytes: 1
Cycle: 2 Cycle: 2
Encoding: 1110000 Encoding: 11110000
Operation: (A) οƒŸ ((DPTR)) Operation: ((DPTR)) οƒŸ (A)
Example:-
Moving data
MOV @R1,A ((R1)) οƒŸ (A)
MOV A,@R1 (A) οƒŸ ((R0))
Logical Operation
ORL A,@R0 (A) οƒŸ (A) OR ((R0))
XRL @R1,A ((R1)) οƒŸ ((R1)) exOR (A)
Arithmetic Operation
ADD A,@R0 (A) οƒŸ (A) + ((R0))
ADDC A,@R1 (A) οƒŸ (A) + ((R1)) + C
Immediate Addressing
The destination register is loaded with a constant value immediately.
Opcode
Immediate
data
INSTRUCTION SET SUMMARY 8051
-8-
Examples:-
ANL A,#data MOV DPTR,#DATA16
Bytes: 2 Bytes: 3
Cycle: 1 Cycle: 2
Encoding: 01010100 dddddddd Encoding: 10010000 dddddddd dddddddd
Operation: (A) οƒŸ (A) AND #data Operation: (DPTR) οƒŸ #data16
Example: ANL A,#0F0H Example: MOV DPTR,#2800H
Encoding: 54H F0H Encoding: 90H 28H 00H
Example:-
MOV A,#12
Loads the value of 12 into the Accumulator.
Moving data
MOV A,#F1H ; (A) οƒŸ F1H
MOV R3,#C1H ; (R3) οƒŸ 1CH
Arithmetic Operation
ADD A,#10H ; (A)οƒŸ (A) + 10H
ADDC A,#10H ; (A)οƒŸ (A) + 10H + C
Logical operation
ORL A,#33H ; (A)οƒŸ (A) OR 33H
ANL A,88H ; (15H) οƒŸ (15H) AND 88H
INSTRUCTION SET SUMMARY 8051
-9-
Relative Addressing
Relative Addressing is used only with certain jump instruction. A relative
address or offset is an 8-bit signed value, which is added to the program
counter to form the address of the next instruction executed. Range -128 to
+127 locations.
Opcode
Relative
Offset
Example :- SJMP THERE
THERE: MOV A,R1
ADD A,@R0
:
:
SJMP THERE
010A
0109
0108
0107 Relative offset from
Address 0102H
is β€œ5”
0101 05 SJMP
0100 80 0107H
00FF
Code
Memory
SJMP is in memory location 0100H and
Offset is in the memory location 0101H.
Destination = PC + offset
= 0102 + 5
INSTRUCTION SET SUMMARY 8051
-10-
= 0107H
Example:-
The instruction SJMP 9030H is in the memory location
9000H and 9001H. What are the machine language bytes for this
instruction?
80H, 2EH
Destination = 9030H = PC + offset
Therefore, offset = destination – PC
= 9030H – 9002H
= 2EH
Example:-
JZ rel JB bit,rel
Bytes: 2 Bytes: 3
Cycle: 2 Cycle: 2
Encoding: 01100000 eeeeeeee Encoding: 00100000 bbbbbbbb eeeeeeee
Operation: Operation:
(PC) οƒŸ (PC) + 2 (PC) οƒŸ (PC) + 3
IF (A) = 0 IF (bit) = 1
Then (PC) οƒŸ (PC) + byte_2 Then (PC) οƒŸ (PC) + byte_3
Example:-
LABEL: MOV A,P1
ANL A,#1
JZ LABEL
MOV P0,P1
……
INSTRUCTION SET SUMMARY 8051
-11-
Absolute Addressing
This type of addressing mode is used only with ACALL and AJMP instruction.
These 2-byte instructions allow branching within the current 2K page of code
memory by providing the 11 least-significant bits of the destination address in
the opcode (A10-A8) and byte 2 of the instruction (A7-A0).
A10 – A8 Opcode
A7 A6 A5 A4 A3 A2 A1 A0
2 K page 31
:
:
:
2 K page 2
2 K page 1
2 K page 0
FFFFH
F800H
Within any
2 K page only
the lower 11
bits change OFFFH
0800H
07FFH
0000
INSTRUCTION SET SUMMARY 8051
-12-
Offers the advantage of short (2-byte) instructions, but has the
disadvantages of limiting the range for the destination and providing
position-dependent code.
If the label THERE represents an instruction at address 0F46H, and the
instruction
AJMP THERE
is in memory locations 0900H and 0901H, the assembler will encode the
instruction as
111 00001 - 1st
byte (A10 – A8 + opcode)
01000110 - 2nd
byte (A7 – A0)
0F46H = 0000 1111 0100 1110B
Example:-
An ACALL instruction is in memory locations 1024H and 1025H. The
subroutine to which the call is directed begins in memory location 17A6H.
What are the machine language bytes for the ACALL instruction?
Encoding for ACALL: aaa10001 aaaaaaaa
A15A14A13A12 A11A10A9A8 A7A6A5A4 A3A2A1A0
17A6H = 0 0 0 1 0 1 1 1 1 0 1 0 0 1 1 0
Therefore, 11110001 10100110 = F1H, A6H
INSTRUCTION SET SUMMARY 8051
-13-
Long Addressing
Long addressing is used only with the LCALL and LJMP instructions.
These 3-byte instruction include a full 16-bit destination address as bytes 2
and 3 of the instruction.
The 1st
byte – Opcode
2nd
and 3rd
- Destination Address.
Opcode
A15–A8
High byte add.
A7–A0
Low byte add.
The advantage is that the full 64K code space may be used, but the
disadvantage is that the instructions are 3 byte long and are position-
dependent.
Example:-
LJMP addr16 LCALL addr16
Bytes: 3 Bytes: 3
Cycle: 2 Cycle: 2
Encoding: Encoding:
00000010 aaaaaaaa aaaaaaaa 00010010 aaaaaaaa aaaaaaaa
Operation: Operation:
(PC) οƒŸ addr16 (PC) οƒŸ (PC) + 3,
(SP) οƒŸ (SP) + 1, ((SP)) οƒŸ (PCL),
(SP) οƒŸ (SP) + 1, ((SP)) οƒŸ (PCH),
(PC) οƒŸ addr16
Example:-
What are the machine language bytes for the following instruction?
LJMP 8AF2H
Opcode High Byte Add. Low Byte Add.
Encoding :- 00000010 aaaaaaaa aaaaaaaa
Hence, the machine language bytes are 02H, 8AH,F2H
INSTRUCTION SET SUMMARY 8051
-14-
Indexed Addressing
Indexed Addressing uses a base register(either the PC or the data pointer)
and an offset(Accumulator) in forming the effective address for a JMP or
MOVC instruction.
Opcode
Jump tables or look-up tables are easily created using indexed addressing.
Examples:-
MOVC A,@A+<base-reg>
and
JMP @A+DPTR
Example: What is the opcode for the following instruction?
MOVC A,@A+DPTR
Solution: 93 H
Example:-
REL_PC: INC A ;(A) <- (A) + 1
MOVC A,@A+PC
RET
DB 66H
DB 77H
DB 88H
DB 99H
If The subroutine is called with the accumulator equal to 01H, it returns
with 77H in the accumulator. See Appendix C page 273 for further
information.
INSTRUCTION SET SUMMARY 8051
-15-
Example:-
Write a program to display 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 continuously through
Port1. Insert some delay between each displayed digit.
Display Common-Anode Display Common-Anode
0 C0H A 88H
1 F9H b 83H
2 A4H C C6H
3 B0H d A1H
4 99H E 86H
5 92H F 8EH
6 82H
7 F8H
8 80H
9 98H
INSTRUCTION SET SUMMARY 8051
-16-
ORG 0H
ULANG: MOV P1,#0C0H
LCALL DELAY
MOV P1,#0F9H
LCALL DELAY
MOV P1,#0A4H
LCALL DELAY
-
-
-
SJMP ULANG
DELAY: MOV R5,#20H
AGAIN: MOV R6,#255
LOOP1: MOV R7,#0F0H
LOOP: DJNZ R7,LOOP
DJNZ R6,LOOP1
DJNZ R5,AGAIN
RET
END
OR
INSTRUCTION SET SUMMARY 8051
-17-
ORG 0000H
ULANG: CLR A
MOV R0,A
MOV DPTR,#NOMBO
TAMBAH: MOV A,R0
MOVC A,@A+DPTR
MOV P1,A
LCALL DELAY
INC R0
CJNE R0,#11,TAMBAH
SJMP ULANG
DELAY: MOV R5,#10
LOOP2: MOV R6,#255
LOOP1: MOV R7,#255
LOOP: DJNZ R7,LOOP
DJNZ R6,LOOP1
DJNZ R5,LOOP2
RET
NOMBO: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,98H
END

More Related Content

What's hot

The 8051 microcontroller
The 8051  microcontroller The 8051  microcontroller
The 8051 microcontroller Avinash Mishra
Β 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly languagehemant meena
Β 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01bvenkanna
Β 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction setShail Modi
Β 
8085 instruction set (detailed)
8085 instruction set (detailed)8085 instruction set (detailed)
8085 instruction set (detailed)Ravi Anand
Β 
1347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 80511347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 8051techbed
Β 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction setSaumitra Rukmangad
Β 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
Β 
Instruction Set 8085
Instruction Set 8085Instruction Set 8085
Instruction Set 8085Stupidsid.com
Β 
Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)Safin Biswas
Β 
Logical instruction of 8085
Logical instruction of 8085Logical instruction of 8085
Logical instruction of 8085vishalgohel12195
Β 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
Β 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructionsRavi Anand
Β 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085shiji v r
Β 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modesghoshshweta
Β 

What's hot (18)

The 8051 microcontroller
The 8051  microcontroller The 8051  microcontroller
The 8051 microcontroller
Β 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly language
Β 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
Β 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction set
Β 
8085 instruction set (detailed)
8085 instruction set (detailed)8085 instruction set (detailed)
8085 instruction set (detailed)
Β 
1347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 80511347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 8051
Β 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
Β 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
Β 
8085 alp programs
8085 alp programs8085 alp programs
8085 alp programs
Β 
Instruction Set 8085
Instruction Set 8085Instruction Set 8085
Instruction Set 8085
Β 
Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)
Β 
Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
Β 
Logical instruction of 8085
Logical instruction of 8085Logical instruction of 8085
Logical instruction of 8085
Β 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
Β 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructions
Β 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085
Β 
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
Β 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modes
Β 

Viewers also liked

Electromagnetic wave radiation and antennas
 Electromagnetic wave radiation and antennas Electromagnetic wave radiation and antennas
Electromagnetic wave radiation and antennasjanicetiong
Β 
The basics of antenna arrays
The basics of antenna arraysThe basics of antenna arrays
The basics of antenna arraysjanicetiong
Β 
48270042 biology-stpm-lower-6-chapter-1
48270042 biology-stpm-lower-6-chapter-148270042 biology-stpm-lower-6-chapter-1
48270042 biology-stpm-lower-6-chapter-1janicetiong
Β 
Dynamics of multiple degree of freedom linear systems
Dynamics of multiple degree of freedom linear systemsDynamics of multiple degree of freedom linear systems
Dynamics of multiple degree of freedom linear systemsUniversity of Glasgow
Β 
Solution of skill Assessment Control Systems Engineering By Norman S.Nise 6t...
Solution of skill Assessment  Control Systems Engineering By Norman S.Nise 6t...Solution of skill Assessment  Control Systems Engineering By Norman S.Nise 6t...
Solution of skill Assessment Control Systems Engineering By Norman S.Nise 6t...janicetiong
Β 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller NotesDr.YNM
Β 
Mechanical Vibrations all slides
Mechanical Vibrations all slidesMechanical Vibrations all slides
Mechanical Vibrations all slidesEbrahim Hanash
Β 

Viewers also liked (8)

Electromagnetic wave radiation and antennas
 Electromagnetic wave radiation and antennas Electromagnetic wave radiation and antennas
Electromagnetic wave radiation and antennas
Β 
The basics of antenna arrays
The basics of antenna arraysThe basics of antenna arrays
The basics of antenna arrays
Β 
48270042 biology-stpm-lower-6-chapter-1
48270042 biology-stpm-lower-6-chapter-148270042 biology-stpm-lower-6-chapter-1
48270042 biology-stpm-lower-6-chapter-1
Β 
Dynamics of multiple degree of freedom linear systems
Dynamics of multiple degree of freedom linear systemsDynamics of multiple degree of freedom linear systems
Dynamics of multiple degree of freedom linear systems
Β 
Solution of skill Assessment Control Systems Engineering By Norman S.Nise 6t...
Solution of skill Assessment  Control Systems Engineering By Norman S.Nise 6t...Solution of skill Assessment  Control Systems Engineering By Norman S.Nise 6t...
Solution of skill Assessment Control Systems Engineering By Norman S.Nise 6t...
Β 
Control chap2
Control chap2Control chap2
Control chap2
Β 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
Β 
Mechanical Vibrations all slides
Mechanical Vibrations all slidesMechanical Vibrations all slides
Mechanical Vibrations all slides
Β 

Similar to Instruction set summary

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.pptsteffydean
Β 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008 vijaydeepakg
Β 
Emb day2 8051
Emb day2 8051Emb day2 8051
Emb day2 8051shivamarya55
Β 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptManju Badiger
Β 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent vijaydeepakg
Β 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01cairo university
Β 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsSreenivas Hanumandla
Β 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Vijay Kumar
Β 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)AmitPaliwal20
Β 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerjokersclown57
Β 
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfDhilibanSwaminathan
Β 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTSssuser2b759d
Β 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086sravanithonta79
Β 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Shubham Singh
Β 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 softbaluusa8
Β 
2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptx2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptxISMT College
Β 

Similar to Instruction set summary (20)

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
Β 
Addressing modes
Addressing modesAddressing modes
Addressing modes
Β 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
Β 
Emb day2 8051
Emb day2 8051Emb day2 8051
Emb day2 8051
Β 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
Β 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
Β 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01
Β 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller ppts
Β 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Β 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
Β 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
Β 
Microcontroller .pptx
Microcontroller .pptxMicrocontroller .pptx
Microcontroller .pptx
Β 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
Β 
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdf
Β 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTS
Β 
8085 Architecture
8085 Architecture8085 Architecture
8085 Architecture
Β 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
Β 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085
Β 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
Β 
2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptx2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptx
Β 

Recently uploaded

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
Β 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
Β 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
Β 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
Β 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
Β 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
Β 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoΓ£o Esperancinha
Β 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
Β 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
Β 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
Β 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
Β 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
Β 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
Β 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
Β 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
Β 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
Β 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
Β 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
Β 

Recently uploaded (20)

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Β 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
Β 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
Β 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
Β 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
Β 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
Β 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Β 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
Β 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
Β 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
Β 
young call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Service
young call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Serviceyoung call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Service
young call girls in Rajiv ChowkπŸ” 9953056974 πŸ” Delhi escort Service
Β 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
Β 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
Β 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
Β 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
Β 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Β 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
Β 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
Β 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
Β 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
Β 

Instruction set summary

  • 1. INSTRUCTION SET SUMMARY 8051 -1- CHAPTER 3 INSTRUCTION SET SUMMARY Structure of Assembly Language [label:] Mnemonic [operands] [;comment] LOOP: MOV A,#01H ; Write 1 to Acc MOV R7,A ;(R7) οƒŸ (A) [PC] op code [operands] [ ] 8000H 74H 01H 8002H FFH Figure 3.1 Structure of Assembly Language Symbol Interpretation οƒŸ Is replaced by …. ( ) The contents of … (( )) The data pointed at by …. rrr One of 8 register; 000 = R0, 001 = R1, 010=R2,..etc dddddddd Data bits aaaaaaaa Address bits (byte address) bbbbbbbb Address of a bit (bit address) i Indirect addressing using R0 or R1 eeeeeeee 8-bit relative address (or offset) Assembler
  • 2. INSTRUCTION SET SUMMARY 8051 -2- ADDRESSING MODES Eight types addressing modes β€’ Register β€’ Direct β€’ Indirect β€’ Immediate β€’ Relative β€’ Absolute β€’ Long β€’ Indexed Register Addressing The 8051 assembly language indicates register addressing with the symbol Rn where n is from 0 to 7. Opcode n Register Addressing Examples:- MOVRn,A ORL A,Rn Bytes: 1 Bytes: 1 Cycle: 1 Cycle: 1 Encoding: 11111rrr Encoding: 01001rrr Operation: (Rn) οƒŸ (A) Operation: (A) οƒŸ (A) OR (Rn) Example: MOV R3,A Example: ORL A,R5 Encoding: 11111011 or FBH Encoding: 01001101 or 4DH
  • 3. INSTRUCTION SET SUMMARY 8051 -3- For instruction using register addressing, either the source or destination operand contains a register. Example MOVA,R7 Bytes : 1 Cycles : 1 Encoding : 11101rrr Operation : (A) οƒŸ (Rn) EFH. This instruction moves the 8-bit content of register 7 to the accumulator. There are 4 β€œbanks” of working register –, address 00 οƒ  1FH, but only one is active at a time. For Example:- MOV PSW,#00011000B PSW BIT 7 BIT 0 Carry Aux. C Flag0 R.Bank 1 R. Bank 0 Overflow Reserved Even. P CY AC F0 RS1 RS0 0V - P RS1 RS0 0 0 bank 0; addresses 00H - 07H 0 1 bank 1: addresses 08H - 0FH 1 0 bank 2: addresses 10H - 17H 1 1 bank 3: addresses 18H – 1FH Activates register bank 3 by setting the register bank select bits (RS1 and RS0) in PSW bit positions 4 and 3. Some instructions are specific to a certain register so address bits are not needed. The opcode itself indicates the register. For Example:- INC DPTR ;(DPTR) οƒŸ (DPTR) + 1
  • 4. INSTRUCTION SET SUMMARY 8051 -4- Is a 1-byte instruction that adds 1 to the 16-bit data pointer. Example3-2 What is the opcode for the following instruction? What does it do? MUL AB Opcode = A4H Operation : (B) οƒŸ HIGHBYTE OF (A) x (B) (A) οƒŸ LOWBYTE OF (A) x (B) Direct Addressing Direct addressing can access any on-chip variable or hardware register. An additional byte is appended to the opcode specifying the location to be used. Only internal RAM and SFRs can be directly accessed. OPCODE Direct address Example:- MOV P1,A ; (direct) οƒŸ (A). Opcode = 11110101 Direct Address = aaaaaaaa Transfer the content of Acc to Port 1. Using Appendix C as a reference the complete encoding of this instruction is 11110101 – 1st byte (opcode) 10010000 – 2nd byte (address of P1)
  • 5. INSTRUCTION SET SUMMARY 8051 -5- Examples:- MOV direct,A DEC direct Bytes: 2 Bytes: 2 Cycle: 1 Cycle: 1 Encoding: 11110101 aaaaaaaa Encoding: 00010101 aaaaaaaa Operation: (direct) οƒŸ (A) Operation: (direct) οƒŸ (direct) - 1 Example: MOV 20H,A Example: DEC B ; B is at 0F0H Encoding: F5H 20H Encoding: 15H F0H Moving data MOV R5,A ; (R5) οƒŸ (A) MOV A,R0 ; (A) οƒŸ (R0) Logical operations ANL A,R5 ; (A) οƒŸ (A) AND (R5) XRL R5,A ; (R5) οƒŸ (R5) exOR (A) Arithmetic Operation ADD A,R3 ; (A) οƒŸ (A) + (R3) ADDC A,R3 ; (A) οƒŸ (A) + (R3) + C
  • 6. INSTRUCTION SET SUMMARY 8051 -6- Indirect Addressing The instruction specifies a register which contains the address of the operand. Opcode i Examples:- MOVX @Ri,A ADD A,@Ri Bytes: 1 Bytes: 1 Cycle: 2 Cycle: 1 Encoding: 1111001i Encoding: 0010011i Operation: ((Rn)) οƒŸ (A) Operation: (A) οƒŸ (A) OR ((Ri)) Example: MOVX @R0,A Example: ADD A,@R1 Encoding: F2H Encoding: 27H Example:- MOV A,@R0 The Source is the memory location pointed by R0, the contents of which are copied into the Accumulator which is the destination register. MOV @R1,A The Accumulator is the source and its contents are copied into the destination which is the memory location pointed by R1. Example:- (a) What is the opcode for the following instruction? (b) What does this instruction do? MOV A,@R0
  • 7. INSTRUCTION SET SUMMARY 8051 -7- Solution (a) E6H (b) The instruction moves a byte of data from internal RAM to the Accumulator. The data are moved from the location whose address is in R0. Examples:- MOVX A,@DPTR MOVX @DPTR,A Bytes: 1 Bytes: 1 Cycle: 2 Cycle: 2 Encoding: 1110000 Encoding: 11110000 Operation: (A) οƒŸ ((DPTR)) Operation: ((DPTR)) οƒŸ (A) Example:- Moving data MOV @R1,A ((R1)) οƒŸ (A) MOV A,@R1 (A) οƒŸ ((R0)) Logical Operation ORL A,@R0 (A) οƒŸ (A) OR ((R0)) XRL @R1,A ((R1)) οƒŸ ((R1)) exOR (A) Arithmetic Operation ADD A,@R0 (A) οƒŸ (A) + ((R0)) ADDC A,@R1 (A) οƒŸ (A) + ((R1)) + C Immediate Addressing The destination register is loaded with a constant value immediately. Opcode Immediate data
  • 8. INSTRUCTION SET SUMMARY 8051 -8- Examples:- ANL A,#data MOV DPTR,#DATA16 Bytes: 2 Bytes: 3 Cycle: 1 Cycle: 2 Encoding: 01010100 dddddddd Encoding: 10010000 dddddddd dddddddd Operation: (A) οƒŸ (A) AND #data Operation: (DPTR) οƒŸ #data16 Example: ANL A,#0F0H Example: MOV DPTR,#2800H Encoding: 54H F0H Encoding: 90H 28H 00H Example:- MOV A,#12 Loads the value of 12 into the Accumulator. Moving data MOV A,#F1H ; (A) οƒŸ F1H MOV R3,#C1H ; (R3) οƒŸ 1CH Arithmetic Operation ADD A,#10H ; (A)οƒŸ (A) + 10H ADDC A,#10H ; (A)οƒŸ (A) + 10H + C Logical operation ORL A,#33H ; (A)οƒŸ (A) OR 33H ANL A,88H ; (15H) οƒŸ (15H) AND 88H
  • 9. INSTRUCTION SET SUMMARY 8051 -9- Relative Addressing Relative Addressing is used only with certain jump instruction. A relative address or offset is an 8-bit signed value, which is added to the program counter to form the address of the next instruction executed. Range -128 to +127 locations. Opcode Relative Offset Example :- SJMP THERE THERE: MOV A,R1 ADD A,@R0 : : SJMP THERE 010A 0109 0108 0107 Relative offset from Address 0102H is β€œ5” 0101 05 SJMP 0100 80 0107H 00FF Code Memory SJMP is in memory location 0100H and Offset is in the memory location 0101H. Destination = PC + offset = 0102 + 5
  • 10. INSTRUCTION SET SUMMARY 8051 -10- = 0107H Example:- The instruction SJMP 9030H is in the memory location 9000H and 9001H. What are the machine language bytes for this instruction? 80H, 2EH Destination = 9030H = PC + offset Therefore, offset = destination – PC = 9030H – 9002H = 2EH Example:- JZ rel JB bit,rel Bytes: 2 Bytes: 3 Cycle: 2 Cycle: 2 Encoding: 01100000 eeeeeeee Encoding: 00100000 bbbbbbbb eeeeeeee Operation: Operation: (PC) οƒŸ (PC) + 2 (PC) οƒŸ (PC) + 3 IF (A) = 0 IF (bit) = 1 Then (PC) οƒŸ (PC) + byte_2 Then (PC) οƒŸ (PC) + byte_3 Example:- LABEL: MOV A,P1 ANL A,#1 JZ LABEL MOV P0,P1 ……
  • 11. INSTRUCTION SET SUMMARY 8051 -11- Absolute Addressing This type of addressing mode is used only with ACALL and AJMP instruction. These 2-byte instructions allow branching within the current 2K page of code memory by providing the 11 least-significant bits of the destination address in the opcode (A10-A8) and byte 2 of the instruction (A7-A0). A10 – A8 Opcode A7 A6 A5 A4 A3 A2 A1 A0 2 K page 31 : : : 2 K page 2 2 K page 1 2 K page 0 FFFFH F800H Within any 2 K page only the lower 11 bits change OFFFH 0800H 07FFH 0000
  • 12. INSTRUCTION SET SUMMARY 8051 -12- Offers the advantage of short (2-byte) instructions, but has the disadvantages of limiting the range for the destination and providing position-dependent code. If the label THERE represents an instruction at address 0F46H, and the instruction AJMP THERE is in memory locations 0900H and 0901H, the assembler will encode the instruction as 111 00001 - 1st byte (A10 – A8 + opcode) 01000110 - 2nd byte (A7 – A0) 0F46H = 0000 1111 0100 1110B Example:- An ACALL instruction is in memory locations 1024H and 1025H. The subroutine to which the call is directed begins in memory location 17A6H. What are the machine language bytes for the ACALL instruction? Encoding for ACALL: aaa10001 aaaaaaaa A15A14A13A12 A11A10A9A8 A7A6A5A4 A3A2A1A0 17A6H = 0 0 0 1 0 1 1 1 1 0 1 0 0 1 1 0 Therefore, 11110001 10100110 = F1H, A6H
  • 13. INSTRUCTION SET SUMMARY 8051 -13- Long Addressing Long addressing is used only with the LCALL and LJMP instructions. These 3-byte instruction include a full 16-bit destination address as bytes 2 and 3 of the instruction. The 1st byte – Opcode 2nd and 3rd - Destination Address. Opcode A15–A8 High byte add. A7–A0 Low byte add. The advantage is that the full 64K code space may be used, but the disadvantage is that the instructions are 3 byte long and are position- dependent. Example:- LJMP addr16 LCALL addr16 Bytes: 3 Bytes: 3 Cycle: 2 Cycle: 2 Encoding: Encoding: 00000010 aaaaaaaa aaaaaaaa 00010010 aaaaaaaa aaaaaaaa Operation: Operation: (PC) οƒŸ addr16 (PC) οƒŸ (PC) + 3, (SP) οƒŸ (SP) + 1, ((SP)) οƒŸ (PCL), (SP) οƒŸ (SP) + 1, ((SP)) οƒŸ (PCH), (PC) οƒŸ addr16 Example:- What are the machine language bytes for the following instruction? LJMP 8AF2H Opcode High Byte Add. Low Byte Add. Encoding :- 00000010 aaaaaaaa aaaaaaaa Hence, the machine language bytes are 02H, 8AH,F2H
  • 14. INSTRUCTION SET SUMMARY 8051 -14- Indexed Addressing Indexed Addressing uses a base register(either the PC or the data pointer) and an offset(Accumulator) in forming the effective address for a JMP or MOVC instruction. Opcode Jump tables or look-up tables are easily created using indexed addressing. Examples:- MOVC A,@A+<base-reg> and JMP @A+DPTR Example: What is the opcode for the following instruction? MOVC A,@A+DPTR Solution: 93 H Example:- REL_PC: INC A ;(A) <- (A) + 1 MOVC A,@A+PC RET DB 66H DB 77H DB 88H DB 99H If The subroutine is called with the accumulator equal to 01H, it returns with 77H in the accumulator. See Appendix C page 273 for further information.
  • 15. INSTRUCTION SET SUMMARY 8051 -15- Example:- Write a program to display 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 continuously through Port1. Insert some delay between each displayed digit. Display Common-Anode Display Common-Anode 0 C0H A 88H 1 F9H b 83H 2 A4H C C6H 3 B0H d A1H 4 99H E 86H 5 92H F 8EH 6 82H 7 F8H 8 80H 9 98H
  • 16. INSTRUCTION SET SUMMARY 8051 -16- ORG 0H ULANG: MOV P1,#0C0H LCALL DELAY MOV P1,#0F9H LCALL DELAY MOV P1,#0A4H LCALL DELAY - - - SJMP ULANG DELAY: MOV R5,#20H AGAIN: MOV R6,#255 LOOP1: MOV R7,#0F0H LOOP: DJNZ R7,LOOP DJNZ R6,LOOP1 DJNZ R5,AGAIN RET END OR
  • 17. INSTRUCTION SET SUMMARY 8051 -17- ORG 0000H ULANG: CLR A MOV R0,A MOV DPTR,#NOMBO TAMBAH: MOV A,R0 MOVC A,@A+DPTR MOV P1,A LCALL DELAY INC R0 CJNE R0,#11,TAMBAH SJMP ULANG DELAY: MOV R5,#10 LOOP2: MOV R6,#255 LOOP1: MOV R7,#255 LOOP: DJNZ R7,LOOP DJNZ R6,LOOP1 DJNZ R5,LOOP2 RET NOMBO: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,98H END