www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/09/21:15:19

Xref: news2.mv.net comp.os.msdos.djgpp:7016
From: "Robert E. Arthur" <rea AT st-and DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Drawing a pixel??
Date: Fri, 09 Aug 1996 13:17:29 +0100
Organization: The University of St Andrews
Lines: 58
Message-ID: <320B2C59.167E@st-and.ac.uk>
References: <Pine DOT SOL DOT 3 DOT 91 DOT 960730200841 DOT 16539A-100000 AT wilbur>
NNTP-Posting-Host: dufftown.dcs.st-and.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

patrick fox wrote:
> 
> void v_putpixel(int x,int y,char clr)
> {
>   __asm__ __volatile__(
>     "pushl %%eax\n"
>     "pushl %%edi\n"
>     "pushw %%es\n"
>     "movl %0,%%eax\n"
	     ^
	Should this not read "movl %1,%%eax\n" ?

>     "movl %%eax,%%edi\n"
>     "shll $8,%%eax\n"
>     "shll $6,%%edi\n"
>     "addl %0,%%eax\n"
>     "addl %%eax,%%edi\n"
>     "movw _dos_ds,%%ax\n"
>     "movw %%ax,%%es\n"
>     "movb %2,%%al\n"
>     "stosb\n"
>     "popw %%es\n"
>     "popl %%edi\n"
>     "popl %%eax");
> }


Also, if you wish to replace y*320 by faster instructions, try

movl	%1,%%edi
leal	[%%edi,%%edi,4],%%edi
shll	$6,%%edi

(you *can* leal with edi can't you?)

So the complete version would read

void v_putpixel(int x,int y,char clr)
{
  __asm__ __volatile__(
    "pushl %%eax\n"
    "pushl %%edi\n"
    "pushw %%es\n"
    "movl %1,%%edi\n"
    "leal [%%edi,%%edi,4],%%edi
    "shll $6,%%edi\n"
    "addl %0,%%edi\n"
    "movw _dos_ds,%%ax\n"
    "movw %%ax,%%es\n"
    "movb %2,%%al\n"
    "stosb\n"
    "popw %%es\n"
    "popl %%edi\n"
    "popl %%eax"
);


Bob.

- Raw text -


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