Documente Academic
Documente Profesional
Documente Cultură
Step 1:
Step 2:
Step 3:
Step4:
Step 3:
Step 4:
Step 5:
Program:
Memory
Location
4100
Machine code
Label
Mnemonics
Comment
21,00,42
LXI H, 4200
4103
7E
MOV A, M
4104
4105
23
86
INX H
ADD M
4106
4107
23
77
INX H
MOV M, A
4108
3E, 00
MVI A, 00
410A
8F
ADC A
410B
410C
23
77
INX H
MOV M, A
410D
76
HLT
Augend
[4201]
8 BIT SUBTRACTION
Step 1:
Step 2:
Step 3:
Step4:
Step 3:
Step 4:
Step 5:
Program:
Memory
Location
4100
Machine code
Label
Mnemonics
Comment
21,00,42
LXI H, 4200
4103
7E
MOV A, M
4104
4105
23
96
INX H
SUB M
4106
4107
23
77
INX H
MOV M, A
4108
3E, 00
MVI A, 00
410A
8F
ADC A
410B
410C
23
77
INX H
MOV M, A
410D
76
HLT
Subtrahend
[4201]
Difference
[4202]
Borrow
[4203]
8 BIT MULTIPLICATION
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
Step 6:
Step 7:
Step 8:
Memory
Location
4100
Machine code
Label
Mnemonics
Comment
21,00,42
LXI H, 4200
4103
4105
4106
3E, 00
4F
46
MVI A, 00
MOV C, A
MOV B, M
4107
4108
23
B8
4109
CA, 15 , 41
410C
86
410D
D2,11, 41
4110
0C
4111
4112
4115
4116
05
C2, 0C,41
23
77
4117
4118
23
71
4119
76
Clear accumulator
Clear C register
Get the multiplicand to
register B
INX H
Increment memory pointer
CMP B
Compare the multiplicand
with zero
JZ
LOOP3 If multiplicand is zero jump
to LOOP3
LOOP2 ADD M
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
Step 6:
Step 7:
Step 8:
Multiplier
[4201]
Product
LSB
[4202]
MSB
[4203]
8 BIT DIVISION
Initialize HL register pair with a memory pointer.
Clear register C.
Get the dividend to D register and divider to accumulator and B register .
Check for the divider. If the divider is zero, set the quotient and remainder
as EE, store in successive memory locations and end the program .
Else move the dividend to accumulator.
Subtract the contents of register B from accumulator.
If carry does not set increment C register and go to step 6
If carry sets, add the contents of register B to accumulator to get the
remainder, and store quotient and remainder in successive memory
locations.
Memory
Location
4100
Machine code
Label
Mnemonics
Comment
21,00,42
LXI H, 4200
4103
0E, 00
MVI C, 00
4105
56
4106
4107
4108
4109
23
7E
46
FE, 00
410B
CA, 23,41
410E
7A
410F
90
LOOP4 SUB
4110
4113
4114
4117
DA, 17,41
OC
C3, 0F 41
80
JC LOOP 3
INR
C
JMP LOOP4
LOOP3 ADD
B
4118
4119
23
71
INX H
MOV M,
Move dividend to
accumulator
Subtract the divider from
the dividend
If carry sets jump to LOOP3
Increment quotient register
Repeat subtraction
Add the contents of B to
accumulator to get the
quotient
Increment memory pointer
Store quotient in memory
411A
411B
23
77
INX H
MOV M , A
411C
411D
411E, 1F
76
23
36, EE
HLT
LOOP1 INX H
MVI M, EE
4120
4121,22
23
36, EE
INX H
MVI M, EE
4123
76
HLT
location
Increment memory pointer
Store remainder in memory
location
End execution
Increment memory pointer
Store EE in memory
location
Increment memory pointer
Store EE in memory
location
End execution
Divider
[4201]
Quotient
[4202]
Remainder
[4203]
Exercise
1.
2.
3.
Write a program to add the following data bytes stored in memory locations
starting at XX60H and display the sum in the location XX80H if the sum does
not generate a carry. If a result generates a carry, stop the addition, and display
01H in the location XX80H.
A set of eight data bytes are stored in memory locations starting from XX70H.
Write a program to add two data bytes at a time and store the sum in the same
memory locations, low order sum replacing the first byte and a carry replacing
the second byte. If any pair does not generate a carry, the memory location of
the second byte should be cleared.
A set of eight data bytes are stored in memory locations starting from XX70H.
Write a program to subtract two data bytes at a time and store the result in a
sequential order in memory location starting from XX70H