home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3137 / divsi3.s < prev    next >
Encoding:
Text File  |  1991-03-27  |  732 b   |  31 lines

  1.     .text            | cjpurcell 30Jul89
  2.     .even            |
  3.     .globl __divsi3        |
  4.     .globl ___divsi3    |
  5. __divsi3:            |
  6. ___divsi3:            |
  7.     link a6,#-2        | 2 bytes of local
  8.     clrw a6@(-2)        | zap the local; it's our neg flg
  9.                 |
  10.     movel a6@(12),d0    | get b
  11.     bge divs1        | pos, ok
  12.     negl d0            | negate it
  13.     addqw #1,a6@(-2)    | and inc the flag
  14. divs1:                |
  15.     movel d0,sp@-        | push adjusted b
  16.     movel a6@(8),d0        | get a
  17.     bge divs2        | pos, ok
  18.     negl d0            | negate it
  19.     subqw #1,a6@(-2)    | and dec the flag
  20. divs2:                |
  21.     movel d0,sp@-        | push adjusted a
  22.     jbsr ___udivsi3        | do an unsigned div
  23.     addql #8,sp        | flush args
  24.     tstw a6@(-2)        | flag set?
  25.     beq divs3        | nope, go ahead and return
  26.     negl d0            | negate the result
  27. divs3:                |
  28.                 |
  29.     unlk a6            | unlink the frame
  30.     rts            | done!
  31.