🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #47

Re: Fast 12 bit multiply on 8 bit machine

#47
From: Jos Horsmeier
Date: Mon, 10 Aug 1992 16:02
31 lines
1399 bytes
In article <1992Aug5.135844.6978@tigger.jvnc.net> dgd@polaris.aml.com (Denis Downey) writes:
|I'm looking for a fast way to do 12 bit multiply and divide using the
|8 bit multiply and divide available on my microcontroller (87c51).
|
|Anyone out there with any good ideas ??

Well, I don't know if it is a good idea, but I would chop these two numbers
into three nibble parts and do the multiplication like this:

X = 256*X1 + 16*X2 + X3
Y = 256*Y1 + 16*Y2 + Y3

X*Y = 65536*(X1*Y1) + 4096*(X1*Y2 + X2*Y1) + 256*(X1*Y3 + X2*Y2 + X3*Y1) +
      16*(X2*Y3 + X3*Y2) + (X3*Y3)

Division is something else ... the naive approach would be to subtract the
second number (after shifting it left enough bits,) but I'd suggest to read

Aho, Hopcroft & Ullman
Design and Analysis of Algorithm

(from memory) chapter 7 (8?) explains an integer division method, where
the result is taken modulo the wordsize, i.e. 

a/b= c mod 2^n ==> b*c = a mod 2^n

I have the book at home, sorry I can't be more detailed about this ...

kind regards,

Jos aka jos@and.nl
Technical Details
Message-ID: <3213@dozo.and.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!and!jos
References: <1992Aug5.135844.6978@tigger.jvnc.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!and!jos
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.misc
Subject: Re: Fast 12 bit multiply on 8 bit machine
Message-ID: <3213@dozo.and.nl>
Date: 10 Aug 92 16:02:35 GMT
References: <1992Aug5.135844.6978@tigger.jvnc.net>
Organization: AND Software BV Rotterdam
Lines: 31