Advertisements
Advertisements
Question
Write an Assembly Language Program to subtract two one-byte data stored at memory locations CO30H and CO31H. Store the absolute difference at memory location CO32Н.
Code Writing
Advertisements
Solution
Label Mnemonics Comments
LXI H, C030H ; Set H-L pointer to C030H
MOV A, M ; Move 1st no. in Accumulator
INX H ; Increment H-L pair
SUB M ; Subtract 2nd no. from 1st no.
JP GO ; If positive result, jump to GO
MOV A, M ; Move 2nd no. in ACC
DCX H ; Decrement H-L pair
SUB M ; Subtract 1st no. from 2nd no.
GO STA C032H ; Store result in C032H
HLT ; Stopshaalaa.com
Is there an error in this question or solution?
