Need simple ASM division algorithm
Kye
Posts: 2,200
Like the title says.
I tried making my own but I messed it up.
This code would work if it knew when to exit but it always·shifts in·extra junk after it accumulates the answer. I was trying to avoid a counter but I see that's not really possible.
What I'm aiming for is the least amount of ASM instructions used. Not the fastest execution time. I would also prefer that the result appear in the mathArgument variable.
Also, this algorithm doesn't really do what I want. I need to be able to divide two unsigned·32 bit numbers by each other. The results of those divisions will be in the 16 bit to 8 bit area.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
I tried making my own but I messed it up.
mov mathResult, #0 ' Setup. shl mathArgument, #16 ' divideLoop if_nz shr mathArgument, #1 ' Preform division. cmpsub sampleBuffer, mathArgument wc ' rcl mathResult, #1 ' tjnz mathArgument, #divideLoop ' sampleBuffer res 1 mathArugment res 1 mathResult res 1
This code would work if it knew when to exit but it always·shifts in·extra junk after it accumulates the answer. I was trying to avoid a counter but I see that's not really possible.
What I'm aiming for is the least amount of ASM instructions used. Not the fastest execution time. I would also prefer that the result appear in the mathArgument variable.
Also, this algorithm doesn't really do what I want. I need to be able to divide two unsigned·32 bit numbers by each other. The results of those divisions will be in the 16 bit to 8 bit area.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Comments
called like:
James