GCC

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
dc0d32

GCC

Post 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.
AR

Re:GCC

Post 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.
mystran

Re:GCC

Post by mystran »

Unfortunately, you can't have the functionality in pure C. Some asm-entry/exit code is unavoidable.
CopperMan

Re:GCC

Post 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 )
{
 ...
}

Post Reply