Mail Archives: djgpp/1996/12/31/00:02:08
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...
...Chambers
(PS: Here is the original program (a whole 20 lines)):
#include <malloc.h>
#include <stdio.h>
unsigned char *data;
int size;
int main(void)
{
size=20;
data=(unsigned char *)malloc(size);
size=16;
asm("0: \n
movb $1, (,%%eax,1) \n
incl %%eax \n
decl %%edx \n
cmpl $0, %%edx \n
jne 0 \n
"
: // No Output
: "d" (size),
"a" (data)
: "memory", "%cc"
);
for (size=0;size<16;size++)
printf("At line %d: %d\n",size,data[size]);
return(0);
}
- Raw text -