Mail Archives: djgpp/1996/03/25/13:13:15
In article <4ius89$76n AT agate DOT berkeley DOT edu>,
Eric J. Korpela <korpela AT islay DOT ssl DOT berkeley DOT edu> wrote:
>In article <4ishog$obf AT mack DOT rt66 DOT com>,
>Brennan "Mr. Wacko" Underwood <brennan AT mack DOT rt66 DOT com> 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.
- Raw text -