From: buers AT gmx DOT de (Dieter Buerssner) Newsgroups: comp.os.msdos.djgpp Subject: Re: inline asm problem Date: 6 May 2000 18:06:54 GMT Lines: 48 Message-ID: <8f1t7r.3vs63bt.0@buerssner-17104.user.cis.dfn.de> References: <007f01bfb76e$0020d320$2f5293c3 AT pkcrone> NNTP-Posting-Host: pec-1-205.tnt1.s2.uunet.de (149.225.1.205) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 957636414 10277116 149.225.1.205 (16 [17104]) X-Posting-Agent: Hamster/1.3.13.0 User-Agent: Xnews/03.02.04 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Paul Crone wrote: >Please help. I've used the following inline assembly code function in >my program using gpp 2.8.1 and all was well. I've just made a new >installation on a different PC using gpp 2.9.5.2 and get a compiler >error. What have I missed? There is a change in the handling of inline assembly in recent versions of gcc. You are not allowed anymore, to put registers in the input-list into the clobber list >inline void set_vesa_bank_pm(int bank_number) >{ > asm ( > " call *%0 " > : /* no outputs */ > : "r" (pm_bank_switcher), /* function pointer in any register */ > "b" (0), /* set %ebx to zero */ > "d" (bank_number) /* bank number in %edx */ > > : "%eax", /* clobber list (we have no way of */ > "%ebx", /* knowing which registers the VESA */ > "%ecx", /* code is going to change, so we */ > "%edx", /* have to assume the worst and list */ > "%esi", /* them all here) */ > "%edi" > ); >} On possible (untested) fix, is to use temporary vars like: /* Assume, the VESA-function does not change ebp */ int unused1, unused2, unused3; asm (" call *%5 " : "=b" (unused1), "=d" (unused2), "=a" (unused3) : "0" (0), "1" (bank_number), "2" (pm_bank_switcher) : "ecx", "esi", "edi" /* all other registers */); Or you push all the registers yourself onto the stack, call the function, and pop the registers again. /* Untested */ asm ("pushal; call *%2; popal" : : "b" (0), "d" (bank_number), "r" (pm_bank_switcher)); -- Dieter Buerssner