Mail Archives: djgpp/1996/10/22/15:45:21
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 -