Is the motorola 68hc08 really 8bit?

Addition and subtraction of 16-bit values on an 8-bit processor is hardly a show-stopper for implementing C on it. It takes two instructions instead of one, but that's hardly dramatic. Multiplication and division are a real pain to implement, but that's true even for some of the 16-bit processors not having MUL or DIV instructions (or having limited versions of those).

Reply to
Everett M. Greene
Loading thread data ...

That's not really true either. You don't have to invent the algorithm, just code it (or easier still, use the vendor's library). It's not a long routine.

--Toby

Reply to
toby

The most efficient way to do a 16 * 16 -> 32bit multiply is often with two applications of an 8 * 16 -> 24 bits and an addition. This certainly applied to the 8080/z80 years ago.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 Click to see the full signature
Reply to
CBFalconer

Op Thu, 03 Feb 2005 01:54:10 GMT schreef CBFalconer:

Why do that, an unsigned 16 * 16 -> 32 bit multiply amounts only to about 30 to 40 bytes code. I used that in my Forth for the ZX Spectrum around 1986.

And the division 32 / 16 --> 16 bit quotient and 16 bit remainder doesn't take much more space, either.

--
Coos
Reply to
Coos Haak

In the 8080 it can all be done in registers, and takes much less code. From a very old listing (1980) (21 bytes of code):

; ; 8 bit by 16 bit unsigned multiplication ; (ahl) := (a) * (bc) ; (d) := (e) := 0 ; a,f,d,e,h,l bmult: lxi d,8; d := 0; e := bit counter mov h,d mov l,d; clear hl add a; 1st multiplier bit to cy jnc bmult2; 0 bit bmult1: dad b; 1 bit, add to partial product adc d; with cy to (a) rh bit bmult2: dcr e rz; done dad h; l shift product adc a; into (a), next mul bit to cy jc bmult1; bit is 1 jmp bmult2; bit is 0

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 Click to see the full signature
Reply to
CBFalconer

Op Thu, 03 Feb 2005 18:32:39 GMT schreef CBFalconer:

Ha, you won! I needed the EXX instruction and assume the alternative registers were free, as is the case in the Spectrum. In other computers that might be disruptive. Maybe I trusted the excellent code in the Z80 book that Rodney Zaks wrote a bit to much ;-(

--
Coos
Reply to
Coos Haak

Nobody said that the algorithms have to be (re)invented. Then there's a question as to whether the vendor has support libraries and legal issues of incorporating their work in another product. And the details vary from one processor to another. All in all, not a fun thing to do.

Reply to
Everett M. Greene

Now extend it to do 16x16=32 on that processor (or even

8x16=24).
Reply to
Everett M. Greene

It IS doing 8x16=24. The 16x16 involves two calls to this, one with each byte of one operand, a 16 bit addition, and a carry into the high order byte. The result is about twice the speed of a straight forward 16x16 multiply routine.

I remember making some choices in that routine so that the timing would be as independant as possible of the multiplier bit pattern.

BTW, my notes credit the idea to Jerry L. Goodrich, of Pennsylvania State University. The implementation was mine. The net result was a slight increase in the total code size for 16x16 multiplication.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 Click to see the full signature
Reply to
CBFalconer

algorithm,

a

I can't believe this much handwringing over a simple little multiply routine. Some people might even consider it fun.

--Toby

Reply to
toby

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.