We need a SIGNED 32x32 multiply and 32x32 divide for PropBASIC. Can you help ?
Bean
Posts: 8,129
We need a signed multiply and divide routine for PropBASIC.
The input will be 32 bits, and the results will be 32 bits.
I looked in the object exchange, but I didn't see anything.
A search of the forum found some unsigned routines.
If you have a routine, or can whip one up, I would appreciate it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
The input will be 32 bits, and the results will be 32 bits.
I looked in the object exchange, but I didn't see anything.
A search of the forum found some unsigned routines.
If you have a routine, or can whip one up, I would appreciate it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
Comments
input A, B;
Sign = 1;
if (A < 0) Sign = -Sign, A = -A
if (B < 0)·Sign = -Sign, B = -B
Perform unsigned multiply/divide into result R
if (Sign < 0) R = -R
I would recommend you look for a 32x32=64 multiply routine to start off. If you plan to include the PBASIC operators ** and */ on native longs, you will need it as a foundation. Since Spin includes **, you might find the routine you need in Chip's interpreter code.
-Phil
This is lifted directly from the Spin interpreter, but with the interpreter control logic removed.· You need to declare LONGs or RES asm_x, asm_y, asm_n, t1, and t2; as written in the course of computation the original asm_y gets absolute valued, asm_n is trashed,·and the signed result of the signed multiply is written to the 64 bit pair t1:asm_x.
You can lift the code from my faster spin interpreter. IIRC I increased it's performance from some code Chip posted later. Link is in my signature under Tools.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade, RetroBlade,·TwinBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80) , MoCog (6809)
· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm