Reputation: 75
I am new with 8086 and i need a little help. I know the basic of AAM. that if i multiple two no.s suppose 07H and 09H
MUL AL,BL
AAM
this will store the value 06H in AH and 03H in AL. But suppose if apply AAM at a value of 3 hexadecimal bits, Suppose
MOV AL,77H
MOV BL,0AH
MUL BL
AAM
What will be the content of AL at last ?
Upvotes: 1
Views: 20914
Reputation: 71
ASCII Adjust after Multiplication(AAM):
Corrects the result of multiplication of two BCD values.
Algorithm:
AH = AL / 10
AL = remainder
Example:
MOV AL, 15 ; // AL = 0Fh
AAM ; // AH = 01, AL = 05
RET
Upvotes: 0
Reputation: 3670
AAM (BCD ADJUST AFTER MULTIPLY)
use aam only after executing a mul instruction between two BCD digits (unpacked). mul stores the result in the AX register. The result is less than 100 so it can be contained in the AL register (the low byte of the AX register). aam unpacks the AL result by dividing AL by 10, stores the quotient (most-significant digit) in AH, and stores the remainder (least-significant digit) in AL.
So question is what it will do if we provide Al
bigger value than 99
?
It will do the same AH = AL / 10
and AL = AL mod 10
but will leave incorrect unpacked bcd values.
So Coming to your case
before AAM
AL
will be 166 (0xA6)
(AX
will be 0x04A6
after multiply)
after AAM
Ah= 166/10=16 ( 0x10)
AL=166 mod 10=6 (0x6)
As we see AX
will be 0x1006
after AAM
And it left incorrect unpacked bcd number
. BeCause the input was not below 100
Upvotes: 5