I am trying to do a decimal adjust after addition creating a 4 digit decimal. I see that the daa
command exists but that only adjusts the al
while I need the entire ax
adjusted to from hex to decimal.
For Example:
mov ax, 9876h
mov bx, 5432h
add ax, bx
would result in ECA8 in the ax
register. The answer after the conversion I want would be something like 5308 in the ax
register with a carry flag specifying the one before the 5 in the full answer (15308)
DAA
only affects al
instead of ax
, is there some other command to do this or an easy way to do such a thing? (I'm also looking for an idea for subtraction as well since DAS
also only affects al
)
Since the original example is for the 8086, I'll show an answer with that instruction set. The same principle would apply to the 8085. There isn't an equivalent to the daa
instruction that operates on a two-byte value. So, you'll have to split up your operation:
mov al, 76h
add al, 32h
daa
mov bl, al
jnc skip
mov bh, 1
skip:
mov al, 98h
add al, 54h
daa
add bh, al
And CF
will be set if there's a 5th digit carry over.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.