Mail Archives: djgpp/1996/10/10/02:25:37
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 -