Mail Archives: djgpp/1996/12/30/12:18:05
Sorry if this is an obvious mistake, but I misplaced my copy of Brennan's
Guide to ASM, and I won't have www access for a while...
Anyways, I'm trying to write some values to a buffer in memory.
Eventually, I'll get around to writing real values, but for now I'm just
writing a constant. This is the code I have:
--file test.c--
#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) \n
incl %%eax \n
decl %%edx \n
cmp $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);
}
Now, when I run this program, I would expect it to print all 1's - but
only the first line is. The rest is random garbage.
My question is: What am I doing wrong?
Thanx in advance,
...Chambers
- Raw text -