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

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fast inline asm pixel plotter
Date: Thu, 15 Jan 1998 23:31:46 +0000
Organization: None
Distribution: world
Message-ID: <hcKLDBAixpv0Ewla@talula.demon.co.uk>
References: <19980115231400 DOT SAA18322 AT ladder01 DOT news DOT aol DOT com>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 24
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Fist1000 writes:
>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. 

This is where you need to roll out the -S flag. Use that on your C code
(with all the optmisation options) and have a look at the code that gets
output by gcc. Then you can see exactly where the difference is, and
start to appreciate just how good the gcc optimiser can be! When using
Borland C you can speed almost anything up by rewriting it in asm, but
with gcc you have to write really _good_ asm code if you want to improve
on the compiler output :-)

>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; }

I suspect mainly because your asm routine is doing a slow multiply while
gcc wil replace that *320 with a series of shifts and additions.


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa

- Raw text -


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