32bit division help

Go To Last Post
2 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


HELP I have been messing around ALL day trying to get a 32bit by 16 bit divide routine running...can anyone point me to some WORKING assembly code? I searched around and all I came up with were dead links, false promises, or just general schema's. I need code & need it now. Your favorite beverage rides on this.


When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  .area text
  rcall	long_prolog
  rcall	tstzero2
  breq	alldone
  clr	  r8
  clr	  r9
  clr	  r10
  clr	  r11
  rcall	tstzero1
  breq	alldone
  ldi	  r30,0x20
  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
  dec	  r30
  brne	startloop
  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.
I choose a beer at the ballpark next time I am in Cincinnati.
Dave Raymond