delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/07/07:19:11

To: djgpp AT delorie DOT com
Subject: ASM in DJGPP V2.01
Date: Tue, 07 Jan 1997 12:08:07 +0000
Message-ID: <748.852638887@cs.ucl.ac.uk>
From: Chris AUSTIN <C DOT Austin AT cs DOT ucl DOT ac DOT uk>

I posted the following query on the 18/12/96 but only recieved one reply and they could not
help completely, so I am reposting this message in the hope that someone else will read it
and be able to help.  Here it is (with the modifications that have already been suggested):-

I 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).  

[Working C++ version]

                for (int row=0; row<16; row++)
                    memcpy(&s.data[(y+row)*s.width+x],&data[row*16],16);

[Working Borland C++ ASM version]

		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;
		}

[NOT working DJGPP ASM version - why?]

		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"
					" movw $0x16d,%%ax   \n"
					" movw $0x16d,%%dx   \n"
                              "0:          	   \n"
                              " movl %%eax,%%ecx   \n"
                              " rep; movsb         \n"
                              " addl %%ebx,%%edi   \n"
                              " decl %%edx         \n"
                              " jnz 0b	         \n"
                              " pop %%es             "
                              :
                              : "rm" (_my_ds()), "b" (offset), "S" (d), "D" (b)
                              : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc");

The error given by the above code is "fixed or forbidden register spilled"
What does this mean and what is causing it?

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, I would
be grateful.  Thanks for any help in finding what is wrong with the code,

Chris Austin

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019