3. Assembly Language
• Low-level programming
• Specific to physical computer architecture
Assembly Language structure
• [Header]
• [Program Instructions]
• [END Instruction]
MCS51 Instruction 32 April 2016
4. Assembly Language Sample
ORG 00H
MOV A, #45H
ANL A, P1 ; Get status from sensors and process
MOV R0, P2 ; Get setting
Loop:
MOV P3, A ; Send Output to Display unit
DJNZ R0, Loop
END
MCS51 Instruction 42 April 2016
5. • Appendix 2: MCS-51 Instruction set
2 April 2016 MCS51 Instruction 5
6. Instruction set
• MCS51 is 8 bit microcontroller, there for 28 or
256 difference instructions possible for CPU.
• Types of instructions
– Data Transfer Instruction
– Logical Instruction
– Arithmetic Instruction
– Branch Instruction
– Bit Operation Instruction
MCS51 Instruction 62 April 2016
8. Description of MCS51 instruction’s
parameter
• A
• Rn
• Ri
• Rx (Ry)
• Address
• #X
• #X16
• Rel
• Bit
• C
MCS51 Instruction 82 April 2016
9. Data Transfer Instructions
• These instructions move the content of one register to
another one. The register which content is moved
remains unchanged. If they have the suffix “X” (MOVX),
the data is exchanged with external memory.
• MOV
• MOVC
• MOVX
• PUSH
• POP
• XCH
MCS51 Instruction 92 April 2016
10. MOV A, Rn
• MOV A, R3
• MOV A, 03h
MCS51 Instruction 102 April 2016
11. MOV A, #X
• MOV A, #78H
• MOV A, #00101010B
MCS51 Instruction 112 April 2016
20. XCHD A, @Ri
1 5
0001
0002
0003
0004
0005
0006
0 5
Ri
Acc
Data Memory
Ri is R0 or R1 register
MCS51 Instruction 202 April 2016
3 5
7 E
6 8
E E
3 F
E 2