Chapter 3 jump, loop and call instructions Outlines Loop instructions
Yüklə
2,37 Mb.
tarix
07.11.2018
ölçüsü
2,37 Mb.
#78720
Chapter 3 JUMP,
LOOP and CALL
Instructions
Outlines
Loop instructions
Conditional jump instructions
Conditions determining conditional jump
Unconditional long & short jumps
Calculate target addresses for jumps
Subroutines
Using stack in subroutines
Crystal frequency vs.
machine cycle
Code programs to generate time delay
Looping
Loop inside a Loop (Nested Loop)
8051
Conditional Jump Instructions
Conditional Jump Example
Conditional Jump Example
Unconditional Jump Instructions
All conditional jumps are short jumps
Target address within -128 to +127 of PC
LJMP (long jump): 3-byte instruction
2-byte target address: 0000 to FFFFH
Original 8051 has only 4KB on-chip ROM
SJMP (short jump): 2-byte instruction
1-byte relative address: -128 to +127
Call Instructions
LCALL (long call): 3-byte instruction
2-byte address
Target address within 64K-byte range
ACALL (absolute call): 2-byte instruction
11-bit address
Target address within 2K-byte range
LCALL
CALL Instruction & Role of Stack
CALL Instruction & Role of Stack
Calling Subroutines
Calling Subroutines
ACALL (absolute call)
Programming Efficiently
Time Delay Generation & Calculation
1 instruction =
n
machine cycle
1 machine cycle = 12 clock cycles
Delay Calculation
Delay Calculation Example
Delay Calculation Example
Increasing Delay Using NOP
Large Delay Using Nested Loop
Chapter 6 Arithmetic Instructions and Programs
Outlines
Range of numbers in 8051 unsigned data
Addition & subtraction
instructions for unsigned data
BCD system of data representation
Packed and unpacked BCD data
Addition & subtraction on BCD data
Range of numbers in 8051 signed data
Signed data arithmetic instructions
Carry & overflow problems & corrections
Addition of Unsigned Numbers
ADD A, source ; A = A + source
ADDC & Addition of 16-bit Numbers
BCD Number System
Unpacked BCD: 1 byte
Packed BCD: 4 bits
Adding BCD Numbers &
DA Instruction
Subtraction of Unsigned Numbers
SUBB A, source ; A = A – source – CY
SUBB when CY = 0
Take 2’s complement of subtraend (source)
Add it to minuend
Invert carry
Example (Positive Result)
Example (Negative Result)
SUBB When CY = 1
For multibyte numbers
Multiplication of Unsigned Numbers
MUL AB ; A B, place 16-bit result in B and A
Division of Unsigned Numbers
DIV AB ; divide A by B
Example ( 1 of 2 )
Example ( 2 of 2 )
Signed 8-bit Operands
Covert to 2’s
complement
Write magnitude of number in 8-bit binary (no sign)
Invert each bit
Add 1 to it
Example
Example
Example
Byte-sized Signed Numbers Ranges
Overflow in Signed Number Operations
When Is the OV Flag Set?
Either: there is a carry from D6 to D7 but no carry out of D7 (CY = 0)
Or: there is a carry from D7 out (CY = 1) but no carry from D6 to D7
Example
Example
Example
Chapter 7 LOGIC INSTRUCTIONS AND PROGRAMS
Outlines
Define the truth tables for logic functions AND, OR, XOR
Code 8051 Assembly language logic function instructions
Use 8051 logic instructions for bit manipulation
Use compare and jump instructions for program control
Code 8051
rotate and swap instructions
Code 8051 programs for ASCII and BCD data conversion
AND
ANL destination, source ;dest = dest AND source
OR
XOR
XOR
XOR
CPL (complement accumulator)
Compare instruction
Rotating the bits of A right and left
Rotating through the carry
SWAP A
BCD AND ASCII APPLICATION PROGRAM
Packed BCD to ASCII conversion
ASCII
to packed BCD conversion
Chapter 8 SINGLE-BIT INSTRUCTIONS AND PROGRAMMING
Outlines
List the 8051 Assembly language instructions for bit manipulation
Code 8051 instructions for bit manipulation of ports
Explain which 8051 registers are bit-addressable
Describe which portions of the 8051 RAM are bit-addressable
Discuss bit manipulation of the carry flag
Describe the carry flag bit-related instructions of the 8051
Single-bit instructions
I/O ports and bit-addressability
Checking
an input bit
Registers and bit-addressability
Bit-addressable RAM
Single-bit operations with CY
Instructions for reading input port
Reading latch for output port
Yüklə
2,37 Mb.
Dostları ilə paylaş:
Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət
Ana səhifə
Psixologiya