Who knows the use of TF(Trap Flag) ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Who knows the use of TF(Trap Flag) ?

Post by david »

There is TF(bit 8 ) in 80X86 CPU.
I can't understand its use.
I think it maybe has relations with Int 01h.
Interrupt Jump Table wrote: Int 01 - CPU-generated - SINGLE STEP
Int 01 - CPU-generated (80386+) - DEBUGGING EXCEPTIONS

Volume 3A_ System Programming Guide wrote: TF Trap (bit 8 ) : Set to enable single-step mode for debugging; clear to
disable single-step mode. In single-step mode, the processor generates a
debug exception after each instruction. This allows the execution state of a
program to be inspected after each instruction. If an application program
sets the TF flag using a POPF, POPFD, or IRET instruction, a debug exception
is generated after the instruction that follows the POPF, POPFD, or IRET.
I wrote some code to set TF.

Code: Select all

	pushf
	pop ax
	or ax, 0100h
	push ax
	popf
But nothing happened.
Just For Fun
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

Have you set up an IDT handler for the debug exception (exception 3) which does more than just return to the next instruction?

Cheers,
Adam
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Post by df »

turning the TF on will tell the cpu to trigger interrupt 0x01 before the instruction is run.
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Post by david »

I found int 01h's ISR entry point is the same with int 03h's(F000:E819).
I disassemblyed the ISR code.
They only set 0:46B's value.

Code: Select all

push ds
push ax
push cx
mov ax, 40h
mov ds, ax
jmp 0EFBDh
.....
0EFBD:
mov ah, 0FFh
mov [6Bh], ah
pop cx
pop ax
pop ds
iret

I could not found any useful things.
Just For Fun
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Post by df »

you have to provide your own ISR routine for it to do anything usefull.

when this gets called you will have on top of stack the cs:ip of the instruction to be executed, which you can modify, etc. its good for single step debugging.
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Post by david »

df wrote:you have to provide your own ISR routine for it to do anything usefull.

when this gets called you will have on top of stack the cs:ip of the instruction to be executed, which you can modify, etc. its good for single step debugging.
What is the number of my own ISR? int 1h or other?
Just For Fun
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Post by suthers »

You can change any Interrupt to whatever you want by changing there entry in the IVT/IDT (Depending on what mode you're in...), so change INT 1 to whatever you want, the point of the TF is to have an interrupt that can give you tailored more targeted debug info for every single operation....
Jules
Post Reply