Is there any algorithm to set or clear TF? For example for ZF flag, we can making situation for set or clear it by adding two number that result is zero...
Asked
Active
Viewed 2,168 times
2 Answers
1
The TF (Trap Flag) is not an arithmetic flag, it's a system/debug flag for single stepping. You can only manage it indirectly, for example through POPF
or IRET
.

Jester
- 56,577
- 4
- 81
- 125
-
The wikipedia article even has code for this. https://en.wikipedia.org/wiki/Trap_flag – Nils Pipenbrinck Nov 21 '14 at 16:28
-
Are you sure he is really asking about `TF`? – Jester Nov 21 '14 at 16:52
-
Yes I'm sure he asked about trap flag ! – mohammadrezamajd Nov 21 '14 at 16:56
0
to enter the trap mode, use the following code:
pushf
pop ax
or ah, 1
push ax
popf
This will set the 8th bit in the flag register, which defines, whether the trap mode is set or not.
to leave the trap mode, use the following code:
pushf
pop ax
and ah, 11111110b
push ax
popf

Van Uitkon
- 356
- 1
- 6