by Nikolai Golovchenko
;Inputs: ; Dividend - AARGB0:AARGB1:AARGB2 (0 - most significant!) ; Divisor - BARGB0:BARGB1 ;Temporary: ; Counter - LOOPCOUNT ; Remainder- REMB0:REMB1 ;Output: ; Quotient - AARGB0:AARGB1:AARGB2 ; Remainder- REMB0:REMB1 ; ; Size: 28 ; Max timing: 4+24*(6+6+4+3+7)-2+3+3=632 cycles (with return) ; Min timing: 4+24*(6+6+6+7)-2+3+3=608 cycles (with return) ; FXD2416U: clr REMB0 clr REMB1 mov W, #24 mov LOOPCOUNT, W LOOPU2416 rl AARGB2 ;shift left divider to pass next bit to remainder rl AARGB1 ;and shift in next bit of result rl AARGB0 rl REMB1 ;shift carry into remainder rl REMB0 rl LOOPCOUNT ;save carry in counter mov W, BARGB1 ;substract divisor from remainder sub REMB1, W mov W, BARGB0 sb C movsz W, ++BARGB0 mov W, REMB0-w ;keep that byte in W untill we make sure about borrow snb C ;if no borrow setb LOOPCOUNT.0 ;set bit 0 of counter (saved carry) snb LOOPCOUNT.0 ;if no borrow jmp UOK46LL ;jump mov W, BARGB1 ;restore remainder if borrow add REMB1, W mov W, REMB0 ;read high byte of remainder to W ;to not change it by next instruction UOK46LL mov REMB0, W ;store high byte of remainder clrb C ;copy bit 0 to carry rr LOOPCOUNT ;and restore counter decsz LOOPCOUNT ;decrement counter jmp LOOPU2416 ;and repeat loop if not zero rl AARGB2 ;shift in last bit of result rl AARGB1 rl AARGB0 ret
|file: /Techref/scenix/lib/math/div/24by16_sx.htm, 2KB, , updated: 2004/6/10 14:40, local time: 2019/10/14 23:27,
|©2019 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://www.sxlist.com/techref/scenix/lib/math/div/24by16_sx.htm"> SX Math Divide 24 bits by 16</A>
|Did you find what you needed?|
Welcome to sxlist.com!
& kind contributors
just like you!
Please don't rip/copy
Copies of the site on CD
are available at minimal cost.
Welcome to www.sxlist.com!