SAHF
Instruction
SAHF
instruction (store AH
into status flags) copies AH
into the low byte of the EFLAGS
register.
SAHF — Store AH Register into Flags |
|||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Setting Sign and Carry Flags | Output |
---|---|
.code mov ebx, 0 ; Clears ebx. mov ah, 10000001b ; Sets Sign and Carry flag. sahf ; Loads ah into flags. jnc L1 ; Jumps if not carry. inc ebx ; If carry, increases ebx. L1: jns L2 ; Jumps if not sign. inc ebx ; If sign, increases ebx. L2: mov eax, ebx ; Moves ebx to eax. call WriteInt ; Prints eax. |
test
: It performs an implied and
operation between each pair of matching bits in two operands and sets the flags accordingly.
The only difference between test
and and
is the test
does not modify the destination operand.jnz
: jumps if Zero
flag is not set.jnc
: jumps if Carry
flag is not set.jns
: jumps if Sign
flag is not set.