Binary Division and Multiplication
SailerMan
Posts: 337
I'm trying to wrap my head around Binary Division and Multiplication.
I know that these functions exist in spin as Pasm Blocks. I'm just curious if anyone has code in spin that illustrates this.
I mean how bits get shifted and stuff like that?
This is just a learning thing for me so any help would be greatly appreciated.
Thanks,
Eric
I know that these functions exist in spin as Pasm Blocks. I'm just curious if anyone has code in spin that illustrates this.
I mean how bits get shifted and stuff like that?
This is just a learning thing for me so any help would be greatly appreciated.
Thanks,
Eric
Comments
Here is a fast *10
Value2=Value (example 5)
Value2<<3 (multi by 8, result 40)
Value2=+Value (result 45)
Value2=+Value (result 50)
@Tony Hey thanks that pretty cool! ... Now how to make this for any Number.
Thanks!
Eric
Another example is coded in Propforth.spin
* trims the results of um*, which calls the assembler function a_umstar
( The high level multiplication function * is coded in forth in Propforthkernel.f)
This code expects the numerator and denominator on the stack, and leave the results on the stack. Since there are no initial, intermediate, or result variables, its a bit faster and shorter than working from values fetched and stored to main memory.