HS>DM>Are you SURE that two shift operations followed by an addition is
DG>really
HS>DM>faster than the hardware-optimized integer multiplication?
HS>DM>Perhaps on an 8086... but on an 80486? Probably not...
HS>Bit shifting will ALWAYS be faster than multiplying.
DG>Yeah, but what about the other stuff that goes along with it too. Like
DG>the mov's and the extra add. On the newer chips it would probably be
DG>about the same, but then again, on the newer chips, you have 120 million
DG>cycles a second, compared to about 66 million. Plus the instructions
DG>take less cycles. I don't think you'd really notice the difference using
DG>a simple multiply vs. the shifts. Unless you did a _LOT_ of them. Still,
DG>personally, I use the shifting method cause it at least _seems_ faster.
DG>And it looks cooler. :)
If you use a table of precalculated [ * ] values it's even
ter.
eg.
char *screen= (char *) 0xA0000;
#if your using watcom - char *screen=(char *) 0x0A000;
int ytable[320];
void pre_calc(void)
{
int loop1;
for (loop1=0; loop1<319; loop1++)
ytable[loop1] := loop1 * 320;
};
void putpixel(int x, int y, unsigned char colour)
{
char *plot;
plot = &screen[ytable[y] + x];
*plot = (unsigned char)colour;
};
... Error, no Keyboard - Press F1 to Continue.
--- Ezycom V1.48g0 01fd016b
---------------
* Origin: Fox's Lair BBS Bris Aus +61-7-38033908 V34+ Node 2 (3:640/238)
|