Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INTRODUCTION
Load the accumulator A with the data byte 82H (the letter
H indicates hexadecimal number), and save the data in
register B.
Instructions: MVI A, 82H,
MOV B,A
The first instruction is a 2-byte instruction that loads the
accumulator with the data byte 82H, and the second
instruction MOV B,A copies the contents of the
accumulator in register B without changing the contents
of the accumulator.
EXAMPLES
PROBLEM STATEMENT
Write a program to do the following:
Load the number 30H in register B and 39H in register C.
Subtract 39H from 30H.
Display the answer at PORT I.
Illustrative Program: Subtraction of Two Numbers
Illustrative Program: Subtraction of Two Numbers
PROGRAM DESCRIPTION
Registers B and C are loaded with 30H and 39H, respectively.
The instruction MOV A,B copies 30H into the accumulator
(shown as register contents).
Illustrative Program: Subtraction of Two Numbers
To execute the instruction SUB C the microprocessor
performs the following steps internally:
Illustrative Program: Subtraction of Two Numbers
PROGRAM DESCRIPTION
The number F7H is a 2’s complement of the magnitude (39H-
30H)=09H.
This ‘Cy’ flag is set, indicating the answer is in 2’s complement.
The instruction OUT displays F7 at PORT1.
NOT
The CMA instruction (2FH in machine language), one’s-
complements the contents of the accumulator.
PROBLEM STATEMENT
Two input port with eight switches (each port) at address
00H and OIH (Figure 6.9) is connected to the
microcomputer to control the same appliances and lights
from the bedroom as well as from the kitchen.
PROBLEM ANALYSIS
To turn on the appliances from any one of the input ports, the
microprocessor needs to read the switches at both ports and logically
OR the switch positions.
Assume that the switch positions in one input port (located in the
bedroom) correspond to the data byte 9lH and the switch positions
in the second port (located in the kitchen) correspond to the data
byte A8H.
The person in the bedroom wants to turn on the air conditioner, the
radio, and the bedroom light; and the person in the kitchen wants to
turn on the air-conditioner, the coffeepot, and the kitchen light.
By ORing these two data bytes, the MPU can turn ON the necessary
appliances.
Illustrative Program: ORing Data from Two Input
Ports
Exclusive OR (XOR)
ROTATE INSTRUCTIONS
SUMMARY
P= 0 Odd parity
Subtract with Borrow
Subtract with Borrow
Example
Suppose that the number in the DE pair must be subtracted from
the BC pair. The least significant is operated on first. Once the
difference of C and E is found, the D register is subtracted from
the B register with a borrow. The subtraction with borrow
effectively propagates the borrow through the most significant
byte of the result.