Subject: Re: T11 design WAS - Re: Inside old games machines,was: Re: Simulated CP/M-68K?
From: "Ethan Dicks" <ethan.dicks at gmail.com>
Date: Wed, 20 Jun 2007 10:02:02 -0400
To: "General Discussion: On-Topic and Off-Topic Posts" <cctalk at
classiccmp.org>
Even without 32-bit registers, there are tricks one may employ.
Twenty years ago, I had to implement a high-frequency filter in 286
assembler as part of an auto-focus routine for a vision system. It
had to be fast, and the company would not pay for a 287 co-pro. The
normal technique for a simple 3x3 kernel is to sum up all the values
in a 3x3 area and divide by 9 to get the average value, then iterate
over the entire frame. Dividing by 9 is expensive for a 286.
Dividing by 8 isn't, and produced acceptable results.
There are frequently tricks to avoid expensive math operations. Video
games use most of them.
-ethan
I've used the same idea for decimal to bin and bin to decimal as multiply
or divide by 10 is costly in 8080/Z80/8048. It was far easier and faster
to do a pair of shifts and one add and then do a shift again than a
general multiply. The same is true for the reverse though then you do
a subtract as needed. The code is linear and faster. It also works well
for other non binary constants (3,5,6,7,9,10,11..). Doing it this way
is the obvious specific unrolling of a general shift and add multiply
routine.
One of many tricks.
Allison