www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/02/09:03:50

Message-Id: <199701021351.OAA04696@mail.umu.se>
Mime-Version: 1.0
Date: Thu, 02 Jan 1997 14:52:43 +0100
To: djgpp AT delorie DOT com
From: Andreas Vernersson <hubb AT freenet DOT hut DOT fi>
Subject: Re: Intel ASM to AT&T ASM question

At 22:54 1997-01-01 GMT, "Chuck Jarenski" <3455245 AT popnet DOT ca DOT out DOT net> wrote:
>Intel code:
>	void vputpixel(int x, int y, char color, char far *vscreen)
>	{
>	  asm {
>	    push es
>	    mov ax,[y]
>	    mov bx,320
>	    mul bx
>	    add ax,[x]
>	    les di,[vscreen]
>	    mov di,ax
>	    mov al,color
>	    stosb
>	    pop es
>	  }
>	}

change to this:

>My AT&T code:
>	void PutPixel(char *Buf, int X, int Y, char Color)
>	{
>	  /* Places a pixel on the buffer at a X,Y location */
>
>	__asm__ __volatile__("
>	  movl %0 , %%eax\n
>	  movl $_ScreenWidth, %%ebx\n
>	  mull %%ebx\n
>	  addl %1, %%eax\n
>	  leal %2, %%edi\n
>	  addl %%eax, %%edi\n
>	  movb %3, %%al\n
>	  movb %%al, (%edi)\n"
>	  :
>	  : "g" (Y), "g" (X), "g" (Buf), "g" (Color)
>	  : "%eax", "%ebx", "%edi", "memory"
>	  );
>	}
>
>

>The AT&T code crashes when I call the module.  Did I transfer the Intel
>syntax correctly to AT&T syntax? =20
hm.. without the changes i made you pushed the selector in es and poped
it into ss (not a great idea), you also les:ed the buffer, you put
the al into color variable instead of the opposite, you moved the offset
from the mul of y and add of x to edi instead of adding it.. with
the changes i made it'll probably work.. :)


/andreas vernersson - Ume=E5, Sweden - hubb AT freenet DOT hut DOT fi - Irc: hubble

- Raw text -


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