Are there any assembly instructions to let us directly "set" or "clear" the "OF" and "TF" flags in Intel's 8086 16-bit Flags register ? If not, what pseudo code should we use?
Assembly instruction for setting, clearing OF & TF flags
Have you read the Intel Manuals before asking this question? –
Youlandayoulton
en.wikipedia.org/wiki/Trap_flag –
Riven
@DCoder have you ever found a pseudo code for such thing in Intel Manuals before posting comment ?! –
Puree
http://en.wikipedia.org/wiki/Trap_flag
The 8086 has no instruction to directly set or reset the trap flag. These operations are done by pushing the flag register on the stack, changing the trap flag bit to what the programmer wants it to be, and then popping the flag register back off the stack. The instructions to set the trap flag are:
PUSHF ; Push flags on stack
MOV BP,SP ; Copy SP to BP for use as index
OR WORD PTR[BP+0],0100H ; Set TF flag
POPF ; Restore flag Register
To reset the trap flag, simply replace the OR instruction in the preceding sequence with the instruction:
AND WORD PTR[BP+0],0FEFFH
To set and clear the overflow flag, you can do the same, replacing 0100H
with 0800H
and 0FEFFh
with 0F7FFh
.
Be sure to know what TF
does before you set it. It's a trap.
What is the reason for doing
mov bp,sp
and using bp register when you can just do or word [sp], 0100h
using solely sp register? –
Chamomile because 8086 is running in 16-bit real mode, there is no such way to make word [sp] as the only possible base registers in a memory operand are BX, BP, SI and DI. –
Overseas
© 2022 - 2024 — McMap. All rights reserved.