8051 Family Microcontrollers Instruction Set
Transcript of 8051 Family Microcontrollers Instruction Set
![Page 1: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/1.jpg)
8051 Family Microcontrollers 8051 Family Microcontrollers
Instruction SetInstruction Set
Chapter 4
![Page 2: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/2.jpg)
Machine code, Opcode, Operand
and Assembly Instruction
Lesson 1
![Page 3: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/3.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education3
Machine Codes
![Page 4: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/4.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education4
• Each distinct executable
instruction has a distinct byte(s)
at an address(es) and that
defines the instruction
Machine Code
![Page 5: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/5.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education5
• It defines NOP instruction
Example- 8051 Machine code
00H
• NOP means no operation; PC sets to new value and processor fetches next from 1001H.
• Let current PC = 1000H. Let 00H is stored at that address.
• Processor when fetches machine code 00H, it is interpreted as NOP.
![Page 6: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/6.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education6
• It defines MOV A, R0 instruction
Example- 8051 Machine code 68H
• MOV A,R0 means move (copy) R0 bits at R0 into A.
• Let current PC = 1001H. Let 68H be stored at that address.
• Processor when fetches machine code 68H, it interprets as MOV.
![Page 7: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/7.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education7
• Codes stored in the memory are called machine codes.
• Program consists of the machine codes that correspond to the instructions.
Machine Code
![Page 8: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/8.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education8
Assembly Mnemonics
![Page 9: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/9.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education9
• Machines codes for a
program difficult to remember
and too lengthy to write
Why Assembly Mnemonics?
![Page 10: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/10.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education10
• An assembly instruction in a program relatively easier to remember
• Eases the assembly program writing in
Assembly Mnemonics
![Page 11: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/11.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education11
• ADD A, R1 means that add into A the byte at the R1 register
Example- 8051 Assembly
Mnemonic: ADD A, R1
![Page 12: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/12.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education12
x = (a + b+ c) * d
Example- A program in high
level language
![Page 13: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/13.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education13
1. Let R0 a; R1 b; R2 c;
Same program in Assembly
language
2. Let R3 d;
3. R4 and R5 16-bits x lower and higher bits, respectively
![Page 14: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/14.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education14
MOV A, R0;
Assembly Instructions
ADD A, R1;
ADDCA, R2;
MOV B, R3;
MUL A, B
MOV R4, A
MOV R5, B
![Page 15: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/15.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education15
1000H: 68H
Same program in machine codes
1003H: 8BH, F0H
1001H: 29H Address for the code given before the colon. Code after the colon.
1002H:3AH
1005H: A4H
1006H: FCH
1007H:ADH, F0H
![Page 16: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/16.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education16
Opcode and operand in an
assembly instruction
![Page 17: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/17.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education17
Assembly instruction:
components
opcode operand(s)Next bits specify
the operands
opcode bits specify
the code for an operation
![Page 18: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/18.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education18
Assembly instruction: opcode and
operands
Next 16 bits directly specify
the addresses for two
operands
Code bits in
Memory are
85H 80H 90H
MOV 80H, 90H
First 8 bits (85H) specify the
opcode for move operation
MOV direct, direct
![Page 19: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/19.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education19
MOV A, @Ri
STEP 2
MOV A, @R1
Time
clock
cycle (s)
3 bits specifies a register, the byte
at that indirectly points and specify
the address for operand
2. Fetch 3 bits for getting the
operand address from R1 For
transferring from a pointed
address byte into A register, IR gets Code bits 11100
111 from Memory
[Sign @ means R1 is a pointer]
1. Fetch Opcode 5 bits
STEP 1
![Page 20: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/20.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education20
Summary
![Page 21: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/21.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education21
• The program is in machine codes
inside the machine (memory
associated with CPU)
• User program can be in assembly
instructions
• User program can be in high level
language such as C
We learnt
![Page 22: 8051 Family Microcontrollers Instruction Set](https://reader034.fdocuments.us/reader034/viewer/2022052214/5849a4931a28aba93a91f2a3/html5/thumbnails/22.jpg)
2011 Microcontrollers-... 2nd Ed. Raj Kamal
Pearson Education22
• Assembly instruction translates to
opcode and operand(s) for each
instruction
We learnt