Mail Archives: djgpp/1997/01/06/21:32:54
In article <19961231 DOT 204032 DOT 5015 DOT 0 DOT chambersb AT juno DOT com>,
Benjamin D Chambers <chambersb AT juno DOT com> wrote:
>Well, I spent some time stepping through my program with GDB, and found
>that the following lines caused problems:
>
>cmpl $0, %%edx (This is, of course, in the c file)
>jne 0
>
>Now, to me, this means that if edx is not zero, jump to the label 0
>(which was defined earlier) and, if edx is zero, keep executing as
>normal. However, when I stepped through this with GDB, I found that no
>matter what value edx held, the loop fell through (that is, no jump was
>performed). Am I doing something wrong here? Again, thanx in advance...
Tell you what, just use jnz as below... (JNZ = jump if not zero)
> asm("0: \n
> movb $1, (,%%eax,1) \n
> incl %%eax \n
> decl %%edx \n
jnz 0b \n
> "
> : // No Output
> : "d" (size),
> "a" (data)
> : "memory", "%cc"
> );
Also, the decl and jnz will pair into 1 cycle on the Pentium.
And, I put a 'b' on the '0', to make 0 into a local label in case of
loop unrolling.
Brennan
--
brennan AT rt66 DOT com | "Developing for Windows is not fun." -- John Carmack
Riomhchlaraitheoir|
Rasterfarian | <http://brennan.home.ml.org> -O
- Raw text -