delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/23/05:02:52

Xref: news2.mv.net comp.os.msdos.djgpp:4163
From: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline ASM, Mode 13h problem
Date: Wed, 22 May 1996 13:29:18 +0100
Organization: The University of York, UK
Lines: 46
Message-ID: <Pine.SGI.3.91.960522093705.7942A-100000@tower.york.ac.uk>
NNTP-Posting-Host: tower.york.ac.uk
Mime-Version: 1.0
In-Reply-To: <31A26377.29C6@postoffice.ptd.net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Tue, 21 May 1996, Matthew J. Freyman wrote:

> Here's my problem:  I managed to set mode 13h under DJGPP v2, and 
> restore the text mode, but I am not having luck using the inline 
> assembler to work on a put-pixel routine.  
>   
> void putpixel(short x,short y,short c) {
>   __asm__ __volatile__("
>     movw %0, %%es;
>     movl $0xA0000, %%edi;
>     movw %2, %%ax;
>     imulw $320, %%ax;
>     addw %1, %%ax;
>     addw %%ax, %%di;
>     movb %3, %%es:(%%edi);"
>     :
>     : "g" (glib_selector), "g" (x), "g" (y), "g" (c)
>     );
> }//END PUTPIXEL ROUTINE        
> 
> I'm developing under RHIDE beta4.  I get an assembler error in the 
> putpixel function, and I believe it is with the following line:  
> 	movb %3, %%es:(%%edi);"  
> 
> ERROR:  OPERANDS GIVEN DON'T MATCH ANY KNOWN 386 INSTRUCTION.

You are moving from parameter %3 to a memory address, but my guess is 
that gcc is allocating parameter %3 as a memory location itself, and you 
can't move from memory -> memory. You are declaring the color parameter 
with the "g" constraint, which means general, ie. gcc can put the 
parameter in a register, memory, or it can be an immediate operand. If 
you are going to move it to memory, it can't be in memory itself, so you 
should use a different constraint to force it into a register (I think 
"r", but I don't have the docs handy). 

btw. why are you using 16 bit operations on %ax? I'd replace them all 
with longs and %eax. Not only does this reduce the chance of overflow, 
but 32 bit instructions are faster because they don't need a size prefix...


/*
 *	Shawn Hargreaves.        Why is 'phonetic' spelt with a ph?
 *	Check out Allegro and FED on http://www.york.ac.uk/~slh100/
 */


- Raw text -


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