Message-ID: <3f34b5c7$0$164$cc7c7865@news.luth.se> From: Martin Str|mberg Subject: Re: Inline assembly error Newsgroups: comp.os.msdos.djgpp References: <84e4e2a9 DOT 0308072140 DOT 47872db2 AT posting DOT google DOT com> <84e4e2a9 DOT 0308082024 DOT 59e5816b AT posting DOT google DOT com> User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (NetBSD/1.6Q (alpha)) Date: 09 Aug 2003 08:50:15 GMT Lines: 83 NNTP-Posting-Host: speedy.ludd.luth.se X-Trace: 1060419015 news.luth.se 164 130.240.16.13 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Joel wrote: : jbs30000 AT aol DOT com (Joel) wrote in message news:<84e4e2a9 DOT 0308072140 DOT 47872db2 AT posting DOT google DOT com>... :> One of the SVGA graphics routines I'm making has given me an inline :> error message. :> What I'm doing is making a routine to call the protected mode verson :> of :> Function 9 -Set/Get Palette Data :> BL = 0 - Set Palette Data / 80H Set Palette Data During Vertical :> Retrace :> CX = Number of Palette Registers to Update :> DX = First of the Palette Registers to Update :> ES:EDI = Table of Palette Values :> So, here's my routine :> unsigned short PM_Palette_Data(unsigned char Flag, unsigned short :> PCount, unsigned short FirstPal, unsigned short TableSeg, unsigned :> long TableOff) :> { :> asm("movw %%ax, %%es\n\t" :> "call *%0" :> : :> : "r" (PMPaletteData), "b" (Flag), "C" (PCount), "a" :> (TableSeg), "D" (TableOff) :> ); :> } :> :> And here's the error I get :> Error: inconsistent operand constraints in an `asm' :> Referring of course, to the "movw %%ax, %%es\n\t" :> I'm not sure why this is happening. movw is move word ax and es are :> words, although maybe it's confusing es as esi, but then what would I :> use to represent ES? :> Anyway, I'm still getting use to AT&T style DJGPP extended inline :> assembly, so any help is appreciated. Thanks. : All right, nobody is answering me, so it must be that the answer is : obvious, and you're waiting for me to figure it out on my own. But No, it's hard. Or too obvious for me. : going over everything, I shouldn't be having a problem. movw moves : words, and ax and es are words. I used two %% with each register : which is required in extended inline assembly. The source and dest : are in the correct order, movw %%ax, %%es should move ax into ex, and : I put the required \n\t at the end since I had two lines of assembly. But you're wrong; it's not movw that makes gcc complain; there are two bugs too (``"C"''; DX?). (And shouldn't "TableSeg" be "TableSel"?) I tried to figure it out. And it's the second constraint that messes up. If I remove that one (Flag), the next one (PCount) makes it complain. This doesn't make sense. Things I did: 1. Change every non int/long to int. 2. ``"C" (PCount)'' -> ``"c" (PCount)''. 3. Removal of "movw %%ax, %%es\n\t". 4. "movw" -> "movl" -> "mov". 5. "movw %%ax, %%es\n\t" -> "movl %%eax, %%es\n\t". Repeat 4. 6. Removal of "c" (PCount). 7. Removal of every constraint except "r" (PMPaletteData). With 1 and 7 it the warning vanishes at least. Not sure if 1 is necessary. Most of the tries above is just to understand what is going on. Some of the 4 and 5 changes are broken anyway. Sum: there's someting strange going on. Right, MartinS