I am doing some assembly 32 bit by 32 bit division (or at least starting to). I've dug around a bit looking for some good sources. The only one I came up with provides a nice 32/32 divide:
Thanks to dave for this original posting
CODE
clr r8 clr r9 clr r10 clr r11 rcall tstzero1 breq alldone ldi r30,0x20 startloop: lsl r16 rol r17 rol r18 rol r19 rol r8 rol r9 rol r10 rol r11 cp r8,r24 cpc r9,r25 cpc r10,r26 cpc r11,r27 brcs donebit sub r8,r24 sbc r9,r25 sbc r10,r26 sbc r11,r27 inc r16 donebit: dec r30 brne startloop alldone: rjmp long_epilog
Numerator in r19-r16, denominator in r27-r24 (meaning for a 16 bit divide r27, r26 are 0.) long_prolog and long_epilog move input and output as appropriate, tstzerox check numerator and denominator, the remainder is in R8-11.
Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.