Search code examples
assemblymasm

How does multiplication work with 16 bit register in Assembly - MASM


According to my textbook, ax equals FE01h:

mov al, -1
mov bl, -1
mul b1

How is this the case? The textbook does not explain. Thanks.


Solution

  • your operation mul is defined as:

    ax = (unsigned)al * (unsigned)bl
    

    -1 is converted to unsigned, which is 255 (check out Two's complement)

    so, as soon as al = 255 and bl = 255, result is ax = 65025 (FE01 in hex)