Assembly Language Programming: - Addition of Two 8-Bit Numbers
Assembly Language Programming: - Addition of Two 8-Bit Numbers
Example: DATA:
2501H – 49H
2502H – 56H
RESULT:
2503 H– 9FH
Addition of Two 8-bit Numbers
MVI A, 49H
MVI B, 56H
ADD B
STA 2503H
HLT
(Or) MVI A, 49H
ADI 56H
STA 2503H
HLT
LDA 2501H
MVI B, 56H
ADD B
STA 2503H
HLT
Addition of Two 8-bit Numbers
LXI H, 2501H
Sum: 16 bits
MVI C, 00H
MOV A,M
INX H
ADD M
JNC AHEAD
INR C
STA 2503H
MOV A,C
STA 2504H
HLTExample:
DATA: 2501H – F5H
2502H – 8AH
RESULT:
2503 H– 7FH
2504H – 01H
8-bit Subtraction
LXI H, 2501H Get address of 1st number in HL pair
MOV A,M 1st Number in accumulator
INX H Increment content of HL Pair
SUB M subtract 1st and 2nd numbers
STA 2503H Store sum in 2503H
HLT Stop
Example: DATA:
2501H – 49H
2502H – 32H
RESULT:
2503 H– 17H
Assembly Language Programming
• Twos Complement of an 8-bit Number
• 16-bit addition
• To find smaller of two numbers
• Unpacking of a BCD number
• Packing of a BCD number
• Transfer a Block of Data
• 8-bit Multiplication
• Addition of ‘n’ Numbers