I don't have these at hand, but you should be able to write them quickly using these algorithms: 24 x 24 Multiplication algorithm: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D x5:0 =3D x2:0 * y2:0, x2:0 - input1, y2:0 - input2, x5:0 - output, 0 - least significant byte. 1) clear sum x5:3 =3D 0 2) clear carry 3) shift x2:0 right 4) if carry set, add y2:0 to x5:3 5) shift x5:0 right (carry from previous addition shifted to MSb and next bit of input to carry) 6) repeat 23 more times from 4 48 / 24 Division algorithm: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D x5:0 =3D x5:0 / y2:0 1) Check y2:0 for zero 2) Clear temporary Temp2:0 =3D 0 3) Set up counter Counter =3D 48 4) Shift left x5:0 5) Shift left Temp2:0 to get next bit from x5:0 6) Save carry (MSb of Temp might be set), e.g. in Counter<7> 7) Substract y2:0 from Temp2:0 8) If carry=3D1 (no borrow), set Counter<7> 9) If Counter<7>=3D0 (borrow and Msb of Temp was zero), add y2:0 to Temp2= :0 to restore it 10) carry=3DCounter<7> (next bit of result) 11) clear Counter<7> 12) decrement Counter, and repeat from 4 if not zero 13) Final shift left x5:0 Since result is known to fit in 3 bytes, then first 24 loops can be skipped. It would save also 3 temporary bytes Temp2:0. Nikolai ---- Original Message ---- From: K=FCbek Tony Sent: Wednesday, August 16, 2000 17:20:54 To: PICLIST@MITVMA.MIT.EDU Subj: [PIC]: Number crunching.. 24x24 and 48/24 > Hi, > I dont have much hope of anyone supplying these but > anyway, as I'm far to busy at the moment, here goes: > I need routines for: > 24 bit X 24 bit =3D 48 bit=20 > and > 48 bit / 24 bit =3D 24 bit ( last bit properly rounded ) > ( and yes the result will alwyas fit inside 24 bits ) > Anyone have these laying around.. ;-) > Code size over performance, as few temp vars as possible. > I really need the accuracy, the end result from a few > formulas are 'only' 24 bit, but they are using quite a bit of > math in between. > In case of no replys, I'll make them myself and post them later > ( next month or so ), when I have a bit more time. > /Tony > Tony K=FCbek, Flintab AB =20 > =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 > E-mail: tony.kubek@flintab.com > =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu