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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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.
fixed in git master 273cb2fd5d4fcf370978d5a65867d1a89e27dd9d