Page 1 of 1
GCC
Posted: Mon Jul 04, 2005 11:37 pm
by dc0d32
does gcc support any function type like "interrupt", like the one found in the borland/turbo compilers? or is there any __attribute__ to manage it somehow like omit the entry and exit instructions for a function?
i have coded the wrapper functions, but those are in asm and i want the functionality in C.
Re:GCC
Posted: Mon Jul 04, 2005 11:47 pm
by AR
Not as far as I am aware, you simply use an assembly stub to call the C function once the stack and environment has been configured.
Re:GCC
Posted: Tue Jul 05, 2005 12:34 am
by mystran
Unfortunately, you can't have the functionality in pure C. Some asm-entry/exit code is unavoidable.
Re:GCC
Posted: Thu Jul 07, 2005 5:09 am
by CopperMan
For this reasons I use something like this :
Code: Select all
[section .text]
extern _handle_trap
%macro define_trap 2
global _trap%1
_trap%1:
%if %2 == 0 ; if this trap does'nt produce error code
push 0
%endif
push %1h ; push trap number
jmp _main_handler
%endm
_main_handler:
pushad
...
push esp
call _handle_trap
add esp, 4
...
popad
add esp, 8
iretd
Code: Select all
void handle_trap( trap_ctx *ctx )
{
...
}