X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Rod Pemberton" Newsgroups: comp.os.msdos.djgpp Subject: Re: still no support/alternative to __attribute__((naked)) ? Date: Thu, 1 Mar 2007 04:03:38 -0500 Organization: Aioe.org NNTP Server Lines: 57 Message-ID: References: <1172695353 DOT 457041 DOT 104610 AT h3g2000cwc DOT googlegroups DOT com> NNTP-Posting-Host: IVw7K97ih4IohxRqyKkqFw.user.aioe.org X-Complaints-To: abuse AT aioe DOT org X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-Priority: 3 X-MSMail-Priority: Normal X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Glaux" wrote in message news:1172695353 DOT 457041 DOT 104610 AT h3g2000cwc DOT googlegroups DOT com... > Hi, > I found that some guy ask for this attribute 2 years before without > reply. Now I also run to situation where need to make > __attribute__((naked)) function. Is there some better way than use > array of bytes constant with binary assembled code which I would call > as a code? > I know of no method to do this in DJGPP. Unfortunately, DJGPP is able to produce a number of different stack frames. This code snippet shows how I create "naked" functions for DJGPP. I use the 'leave' instruction to undo the stackframe for simple 'void xxx(void)' functions. This won't work if your function needs arguments or returns arguments. You shouldn't need them for an interrupt wrapper from assembly to C. Also, -fomit-frame-pointer changes the way the frame is created, i.e., don't use... #ifdef __DJGPP__ #if 0 #define FOMIT /* for -fomit-frame-pointer */ #endif /* LEAVE will undo the stack frame for **simple** DJGPP procedures. */ /* i.e., void xxx(void) */ /* This allows the use of an retf,iretf, or jmp out of the procedure. */ #ifdef FOMIT #define LEAVE #else #define LEAVE "leave\n" #endif #define __declspec(naked) #endif /* '__declspec(naked)' for WATCOM to eliminate stack frame. */ /* removed by empty preprocessor define for DJGPP */ void __declspec(naked) iret_special(void) { #ifdef __DJGPP__ __asm__ ( LEAVE "iretl\n" ); #endif #ifdef __WATCOMC__ _asm { .386 iretd } #endif } Rod Pemberton