delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/22/15:45:21

From: bhodge AT gpu4 DOT srv DOT ualberta DOT ca (B Hodge)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help with graphics and inline asm please.
Date: 22 Oct 1996 16:34:44 GMT
Organization: University of Alberta
Lines: 39
Message-ID: <54it34$121k@pulp.ucs.ualberta.ca>
References: <01bbc016$d29f7660$88015838 AT peterstb DOT usps DOT gov> <01bbc02d$a7f47de0$88015838 AT peterstb DOT usps DOT gov>
NNTP-Posting-Host: gpu4.srv.ualberta.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

B. Peterson (bpeterson AT ntip DOT usps DOT gov) wrote:
: Nevermind..  I figured it out.  our_global_selecter, x, y, and color have
: to be global variables.  
: New question...  Is this the only way of doing it?  Is there some way of
: passing the parameters x, y, and color
: to the function?

Yes there is.  It involves using extended ASM.  There's more info in the
FAQ and in some inline asm tutorials on the web, but basically here is how
it would go....

putpixel(int x, int y, int color)
{
  __asm__ __volatile__("
    movw %%ax, %%es
    movl $0xA0000, %%edi
    movl $320, %%eax
    imull %%ecx, %%eax
    addl %%ebx, %%eax
    addl %%eax, %%edi
    movb %%dl, (%%edi)
    " : : "a" (_dos_ds), "b" (x), 
          "c" (y), "d" (color) );
}

Note that I did some mods to teh code structure but it'll work.  I may
have some typos in there.  I'm not at my computer so I can't test it, but
if you're smart enough, you'll figure it out. ;)

Also, you could speed up the function many times by using bit shifting
instead of the slow multiplication instruction.  Which is the entire point
behind using assembler in the first place.

BTW, the \n s you had in the code were redundant. :)

-----------------------------------------
Blaine Hodge <bhodge AT gpu DOT srv DOT ualberta DOT ca>
Homepage: http://www.ualberta.ca/~bhodge/
"I am currently between signatures."  -me

- Raw text -


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