8051 2018 Lec3
8051 2018 Lec3
8051 2018 Lec3
ORG 100h
DB 50h, 90h ; Bytes
0100h 50h
0101h 90h
Program M
3/7/2024 2
DB
Internal Rate of the
ORG 50h Internal clock
clock divider
DB “Microprocessor” ; String
by12 pulses
0050h M
0051h i
c
r
o
p
r
o
c
e
s
s
o
005Dh r
Program M
3/7/2024 3
The instruction types of MCS-51
The ISA of MCS-51 family includes 5 types of
instructions as following:
a) Data transfer Instructions.
b) Logical operation instructions.
c) Bit-Oriented Instructions.
d) Arithmetic operation Instructions.
e) Branching Instructions.
3/7/2024 4
The Mnemonic of instructions
❑ Each instruction is known by the shortened of its
operation and called “Mnemonic” alike:
Instruction’s operation Mnemonic
Move data MOV
Increment data INC
Adding 2 data ADD
Division 2 data DIV
No operation NOP
Jump if carry is set JC
Complement CPL
3/7/2024 5
Some terminologies of the assembly of MCS-51
Instruction’s
terminology
Description Example
A The Accumulator CPL A
C The Carry flag CLR C
Bit The addressable bit SETB P1.5
Rn The Register R0 to R7 of the selected DEC R5
bank
Rx Address of any internal RAM location MOV PSW, 20H
(from 00h to FFh) or (from 0 to 255)
or the SFR’s names
@Ri Indirect 8-bit address of internal or INC @R0
external RAM location (i = 1 or 0 only)
DEC @R1
3/7/2024 6
The terminologies of ISA for MCS-51
Instruction’s
terminology
Description Example
Rel The relative address in the Again:
program memory within range -128
3/7/2024 8
Available MOV-instructions
MOV R1, 8h
MOV P3, A
3/7/2024 10
MOV 80h, #50h
3/7/2024 11
MOV A, @R1
3/7/2024 12
EXAMPLE
3/7/2024 13
The subprogram to indicate the indirect
address
3/7/2024 14
@R0
@R0
3/7/2024 15
The 16-bit Data transfer
Example MOV DPTR, #0EE44h
3/7/2024 16
The Stack
The stack is part of the RAM
Microprocessor 2017-18 17
The Stack is effected by
1- Push & Pop instructions
Microprocessor 2017-18 18
The data transfers from/to Stack
Microprocessor 2017-18 19
Pushing data-byte into the stack
PUSH 60h Source address
Bank 0
Org 0
Calling current address
1
CALL delay Return address
Delay:
-----
-----
2 -----
-----
RET
Data memory
Microprocessor 2021-22 23
The calling
address
Return
address
Example of the
execution of the
instruction “call”
(3 slides)
Microprocessor 2017-18 24
2
Calling
1
Pushing
return
address
Program
memory
RAM
Microprocessor 2017-18 25
Pop
return
address
Microprocessor 2017-18 26
Complete the following block diagram (specially the SP & PC)
during the executions of both instructions CALL and RET
sequentially.
27
28