Calculator Community > ASM

[z80] 32 bit by 16 bits division and 32 bit square root

(1/7) > >>

Streetwalrus:
I need a 32 bit by 16 bit division routine but I have absolutely no idea how to do this. I specifically need to check if the modulus is non zero. Can you give me some tips ? Asm in 28 days has 32/8 which is not enough for me.

Same for a 32 bit square root routine. I need the result as a 16 bit integer.

Note that I'm not asking for code but some help to create them myself and then optimization because I'm not Runer/ThePenguin/Calc84maniac and I want to learn. :P

Streetwalrus:
Is anyone willing to help ?

Matrefeytontias:
I don't really know how to do that, but I think it's the same way as a 16 by 16 division. I know that in the process you loop as much times as bits that are in the first operand (idk if that's English :P), so you would do 32 loops I think. But I can't really help.

Hayleia:
I am not really sure that people trying to win the TI Planet contest will be willing to help you before the deadline :P

Runer112:
I think Z80 Bits is where everybody learned how bitwise math routines worked. It has code for multiplication, division, and square root routines of varying bit-width inputs, and pretty good explanations of the algorithms behind them. Unfortunately none of the routines go up to bit widths quite as high as you're looking for, probably because at that point you start running out of registers. I figure you can get 32-bit/16-bit by just using one of the existing routines and throwing in the use of ix to fit all the necessary bits. As for the restoring square root algorithm... that algorithm is a little mind-boggling. But I figure you'd need 16 bits to store the result instead of 8, the comparison step would have to compare 24 bits instead of 16, and you'd need to find a way to feed in 24 bits of the input (I think 8 bits always start in the "accumulator"). By the looks of it, you might be short one register, even if you use ix. Perhaps make sure interrupts are turned off and use shadow registers?

But as Hayleia said, since I'm pretty sure this is for the TI-Planet contest, I don't think anybody should really write your routines for you. But hopefully I've given you some good guidance to being able to take a stab at it yourself. :)

Navigation

[0] Message Index

[#] Next page

Go to full version