Explain flag manipulation instruction of 8086 in detail.
Flag Instructions (Flag Transfer) : These instructions are related to movement of flag register to/from a register and memory.
Flag Instructions (Flag transfer) :
- LAHF (Load AH register from flags)
- SAHF (Store AH register flags)
- PUSHF (Push flags onto stack)
- POPF (Pop flags off stack)
=> LAHF - Load AH register from flags : Copy lower byte of flag register to AH.
Mnemonic LAHF Flags No flags are affected
Algorithm AH = flag register's lower byte
Addr. Mode Implied Addressing mode
Operation AH <- Lower byte of flag register
The lower byte of 8086 flag register is copied to the AH register.
=> SAHF - Store AH register in Flags : Copy contents of AH to lower byte of flag register
Mnemonic SAHF Flags No flags are affected.
Algorithm AH = flag register
Addr. Mode Implied Addressing mode
Operation AH -> Lower byte of flag register.
- This instruction copies the contents of AH register to the lower byte of flag register.
- It is included for 8085 compatibility.
- The OF, DF, IF and TF are not affected.
=> PUSHF - Push flags onto stack : PUSH flag register on the stack
Mnemonic PUSHF Flags No flags are changed.
Algorithm SP = SP - 2
SS : [SP] (top of stack) = operand.
Addr. Mode Register Addressing mode
Operation SP -> SP -2 SS -> data from flag register
- This instruction decrements the stack pointer by 2 and copies word in the flag register to the memory location pointed by stack pointer.
- The stack segment register is not affected.
=> POPF - Pop flags off stack :
Mnemonic POPF Flags All flags are affected.
Algorithm SS = data to flag register SP = SP + 2
Addr. Mode Register Addressing mode
Operation SS : [SP] -> Copy data to flag register SP = SP + 2.
- This instruction copies a word from the two memory locations at the top of the stack to flag register and increment the stack pointer by 2.
- The stack segment register and word on the stack are not affected.
Post a Comment