www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/10/02:25:37

From: korpela AT islay DOT ssl DOT berkeley DOT edu (Eric J. Korpela)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: asm() tutorial & problem
Date: 2 Oct 1996 23:47:32 GMT
Organization: Cal Berkeley-- Space Sciences Lab
Lines: 54
Message-ID: <52uuul$mv7@agate.berkeley.edu>
References: <3249f20b DOT 3507235 AT nntp DOT arrakis DOT es>
NNTP-Posting-Host: islay.ssl.berkeley.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <3249f20b DOT 3507235 AT nntp DOT arrakis DOT es>,
Rafa Couto <rcouto AT arrakis DOT es> wrote:
>	Info pages does not give very info about gas... Is there any
>gxx.asm() tutorial over i386?

Check out http://www.rt66.com/~brennan/djgpp/djgpp_asm.html


>	Is needed to push all registers when a asm stament is started?
>or only DS, (E)BP registers like other compilers...

Use the extended addembly format and you don't need to....
>
>	and the problem: opcode LES does not exist :-??

Your problem was trying to access parameters as if they were global
variables.  You are also trying to use 16 bit assembly.  Why?   There's
little point in useing the les opcode in a 32 bit environment.
Try this for a change.....


typedef	unsigned char Byte;

void put_pixel(int x, int y, Byte color, void *buffer) {
  asm ( "
	leal (%1,%1,4),%1
        addl %3,%0
        shll  $6,%1
        movb %2,(%0,%1)
     "
     : /* no outputs */
     : "r" (x), "r" (y), "r" (color), "r" (buffer)  /* inputs */
  );
}

Even easier to write is....
-----------------------------------------------------------
void put_pixel(int x, int y, Byte color, Byte *buffer) {
  buffer[x+320*y]=color;
} 

Use to -S option to look at the machine code that comes out.  Chances
are it's pretty close to as good as you can do with such a simple function.
It would also make things a bit faster if you passed the color as an
unsigned int rather than as an unsigned char (it'll get rid of a movzbl 
instruction).

Eric

-- 
Eric Korpela                        |  An object at rest can never be
korpela AT ssl DOT berkeley DOT edu            |  stopped.
<a href="http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpela/w">
Click here for more info.</a>

- Raw text -


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