Você está na página 1de 2

ADDITION OF TWO 16 BIT NUMBERS

Write program to add two 16 bit numbers, the numbers are FC45H and 02ECH

When adding two 16 bit data operand, we need to be concerned with the propagation of a carry from
the lower byte to the higher byte. The instruction ADDC (add with carry) is used on such occasion.

e.g. 1

3C E7

+ 3B 8D

________

78 74

When the first byte is added (E7+8D=74, CY=1). The carry is propagated to the higher byte, which results
in 3C+3B+1=78 (all in hex).

Flow Chart:
Start

Initialize Carry counter

Load low byte of first number

Add low byte of second number with Low byte of first number

Store low byte result

Load high byte of first number

Add high byte of second number with High byte of second number with carry

Store high byte result

Stop
Program:

CLR C ;make CY=0

MOV A, #0E7H ;load the low byte now A=E7H

ADD A, #8DH ;add the low byte now A=74H and CY=1

MOV R6, A ;save the low byte of the sum in R6

MOV A, #3CH ;load the high byte

ADDC A, #3BH ;add with the carry

;3B + 3C + 1 = 78(all in hex)

MOV R7, A ;save the high byte of the sum

END

Result:

R6= Low byte of result

R7: High byte of result

Você também pode gostar