www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/15/18:16:45

From: fist1000 AT aol DOT com (Fist1000)
Newsgroups: comp.os.msdos.djgpp
Subject: fast inline asm pixel plotter
Date: 15 Jan 1998 23:14:43 GMT
Lines: 37
Message-ID: <19980115231400.SAA18322@ladder01.news.aol.com>
NNTP-Posting-Host: ladder01.news.aol.com
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I figured out how to get an inline asm pixel plotter working, but now, to my
astonishment, it is slower than my straight C version. It's just a simple
mode13h pixel plotter, like so:

  // sets a pixel in mode 13h
  inline void _vga_putpixel(int x, int y, unsigned char color)
      {
      __asm__ __volatile__ ("
          movw %%ax,%%es;
          movl $0xA0000,%%edi;
          movl %1,%%eax;
          imull $320,%%eax;
          addl %0,%%eax;
          addl %%eax,%%edi;
          movb %2,%%al;
          movb %%al,%%es:(%%edi)
          "
          : : "g" (x), "g" (y), "g" (color), "a" (_dos_ds)
          );
      }

I don't understand how it is slower than this:

  inline void _vga_putpixel(int x, int y, unsigned char color)
      { _gbuf[(y*320)+x] = color; }

_gbuf is a pointer to the video memory. i have nearptrs enabled also. i
understand that muls are slow in asm, but i can't get it to work when i try to
convolute everything to work with shifting.

If it's any help, here's my command line:

  gcc -Wall -Werror -m486 -O3 foo.cc -o foo.exe

Any advice?

- Aegis (fist1000 AT aol DOT com)

- Raw text -


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