Statement: Write an ALP using 8085 to evaluate the expression C=A2+B2
Let ‘A’ be Data#1 and ‘B’ be Data#2
|
Source program 1:
MVI B, Data#1 ; Data #1 is stored in register B
MOV C, B ; Copy of Data #1 is made in register C
MVI D, Data#2 ; Data #2 is stored in register D
MOV E,D ; Copy of Data #2 is made in register E
XRA A ; Accumulator content is cleared
Again: ADD B ]
DCR C } A2 is calculated by repeated Addition
JNZ Again ]
MOV H,A ; Calculated A2 value is stored in register H
XRA A ; Accumulator content is cleared
Loop: ADD D ]
DCR E } B2 is calculated by repeated Addition
JNZ Loop ]
ADD H ; A2+ B2 is determined,
by adding result in A
and register content H
STA 4200H ; Result is stored in memory location 4200H
|
Related Programs for Beginners: (Click down)
Store 8-bit data in memory
Add two 16-bit numbers
Finding Two's complement of a number
Exchange the contents of memory locations
Pack-the-unpacked-BCD-numbers