To: djgpp AT delorie DOT com Subject: ASM in DJGPP V2 Date: Wed, 18 Dec 1996 21:01:33 +0000 Message-ID: <2615.850942893@cs.ucl.ac.uk> From: Chris AUSTIN I am new to using DJGPP but have been using Borland C++ 3.1 for a couple of years. I am currently trying to get a program running under DJGPP V2 that was working in BC++, but am having problems with a bit of assembler for copying a 16x16 picture to a virtual screen (s) which has width (s.width) and is stored as an array of unsigned char (s.data). The following section of code is the C++ version:- for (int row=0; row<16; row++) memcpy(&s.data[(y+row)*s.width+x],&data[row*16],16); which works in both, and the following is assembler which worked in BC++:- unsigned char* b=s.data+y*s.width+x; const unsigned char* p=data; int scrw=s.width; asm{ push ds; mov ax,16; mov dx,16; mov bx,scrw; sub bx,ax; les di,b; lds si,p; cld; shr ax,1; } rowloop: asm{ mov cx,ax; rep movsw; add di,bx; dec dx; jnz rowloop; pop ds; } I have tried to convert this to GNU asm and came up with the following, but this doesn't work. What is wrong with it? register unsigned long b asm ("%edi") = s.data+y*s.width+x; register unsigned short offset asm ("%ebx") = s.width-16; register unsigned long d asm ("%esi") = &data[0]; asm volatile (" cld \n" " push %%es \n" " movw %w0,%%es \n" "rowloop: \n" " movl %%eax,%%ecx \n" " rep; movsb \n" " addl %%ebx,%%edi \n" " decl %%edx \n" " jnz rowloop \n" " pop %%es " : : "rm" (_my_ds()), "a" (16), "d" (16), "b" (offset), "S" (d), "D" (b) : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc"); I have read through the FAQ and the info pages but can't find that much information on asm in DJGPP programs. The bit of asm that I have written is based very much on an example program in EXE magazine, so I don't fully understand it. So if someone could explain what the "rm" is in the input list and the "cc" means, I would be grateful. Thanks for any help in finding what is wrong with the code, Chris Austin