Menu

#3 LAHF bug

v1.0
closed
nobody
Opcodes (4)
5
2018-01-20
2007-07-22
No

The LAHF instruction loads the low byte of FLAGS unchanged into AH. According to the Intel manual it should instead first perform a special bit mask operation of the value.

Discussion

  • Memphis

    Memphis - 2008-06-17

    Logged In: YES
    user_id=990829
    Originator: NO

    Do you have any references for this. As far as i know it is just loaded into the register AH.

     
  • Memphis

    Memphis - 2008-06-17

    Logged In: YES
    user_id=990829
    Originator: NO

    i also found this in the intel manual ... but beleave me ... when coding this, we had books for the 8086 where the bits 1 3 and 5 are simply undefined. In the intel reference ist now has changed to a define value. Whatever - i'll fix this.

    ciao

    Christian

     
  • Memphis

    Memphis - 2018-01-20

    Ok - looked into it again. In the intel reference from 1978 (the pdf i added to the docs folder in git) - says:
    [..] The content of bits 5 3 and 1 is undefined [..]

    Thats what we basically implemented here by simply copying the whole 8 bits of the flags register to AH (overwriting bits 5 3 and 1 in AH with whatever is in the flags register at that time).

    The second source of truth [tm] i've found is this one:
    http://www.electronics.dit.ie/staff/tscarff/8086_instruction_set/8086_instruction_set.html#LAHF

    It says:
    AH bit: 7 6 5 4 3 2 1 0
    [SF] [ZF] [0] [AF] [0] [PF] [1] [CF]
    bits 1, 3, 5 are reserved.

    Imo this even suggests to set bits 5 3 and 1 in AH to 0 0 and 1 statically - which sounds even more weired to me.

    And the third source (in german - sorry):
    http://www.i8086.de/asm/8086-88-asm-lahf.html

    So this is what you suggest. Also as the manual from 1978 says we should explicitly only transfer the mentioned bits - also suggest to leave bit 5, 3 and 1 unaltered. So lets go for that route.

     
  • Memphis

    Memphis - 2018-01-20

    fixed in git master 273cb2fd5d4fcf370978d5a65867d1a89e27dd9d

     
  • Memphis

    Memphis - 2018-01-20
    • status: open --> closed
    • Group: --> v1.0
     

Log in to post a comment.