Xref: news2.mv.net comp.os.msdos.djgpp:2142 From: brennan AT mack DOT rt66 DOT com (Brennan "Mr. Wacko" Underwood) Newsgroups: comp.os.msdos.djgpp Subject: Re: Is this ASM ok? Date: 24 Mar 1996 17:42:47 -0700 Organization: None, eh? Lines: 44 Message-ID: <4j4q67$h4b@mack.rt66.com> References: <3150B8B2 DOT 8B2 AT jeffnet DOT org> <4ishog$obf AT mack DOT rt66 DOT com> <4ius89$76n AT agate DOT berkeley DOT edu> NNTP-Posting-Host: mack.rt66.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <4ius89$76n AT agate DOT berkeley DOT edu>, Eric J. Korpela wrote: >In article <4ishog$obf AT mack DOT rt66 DOT com>, >Brennan "Mr. Wacko" Underwood wrote: >>asm( >> "loopf:\n\t" >> "movb %%dh, (%%edi)\n\t" /* write integer portion of color - U1 */ >> "addl %%ebx, %%edx\n\t" /* Add colstep to col - V1 */ >> "incl %%edi\n\t" /* increment edi - U2 */ >> "decl %ecx\n\t" /* decrement count - V2 */ >> "jnz loopf" /* If ecx not zero goto loop - U3 */ >> : : "D" (tscreen), "d" (tcol1), "b" (tcolstep), "c" (tlength)/*loaded regs*/ >> : "%edi", "%ebx", "%ecx", "%edx"); /* clobbered regs */ > >I think there is a problem with your clobbered register list. Because >you have already specified the loaded registers gcc already knows that >these registers will be modified. Ordinarily I wouldn't think that >would be a problem, but the GCC info pages state that "The input >operands are guaranteed not to use any of the clobbered registers." >There's clearly a contradiction here, and I would hope GCC flags >this as an error, or at least gives a warning. Nope, I found out the hard way, that if you tell GCC that x is in eax, it expects it to still be there after your asm completes, unless you tell it it's been clobbered. This is a Good Thing, actually, because it can save a register load if it needs it later (and you didn't clobber it.) It's part of how it optimizes. (You can put (x+1) in there, and afterwards, if you respecify (x+1), it'll remember that it's already got it in a register.) Oh, I see what you mean about the Info pages. That refers to this register loading method: "q" (tscreen) then use %0 for the register name, in case GCC was already using eax or whatever you would have picked. Or something to that effect. I haven't been able to get that to be useful yet, I just specify the registers. I did notice after I posted this that I specified ebx as clobbered when it isn't, but it wouldn't break anything. --brennan I love the word clobber. -- brennan AT rt66 DOT com | Do what you'll wish you had done.