]> git.sur5r.net Git - cc65/blob - libsrc/runtime/div.s
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / runtime / div.s
1 ;
2 ; Ullrich von Bassewitz, 07.08.1998
3 ;
4 ; CC65 runtime: division for signed ints
5 ;
6
7 ; When negating values, we will ignore the possibility here, that one of the
8 ; values if $8000, in which case the negate will fail.
9
10         .export         tosdiva0, tosdivax
11         .import         popsargs, udiv16, adjsres
12         .importzp       sreg
13
14 tosdiva0:
15         ldx     #0
16 tosdivax:
17         jsr     popsargs        ; Get arguments from stack, adjust sign
18         jsr     udiv16          ; Do the division
19         lda     sreg            ; Result is in sreg, remainder in ptr1
20         ldx     sreg+1
21         jmp     adjsres         ; Adjust the sign of the result if needed
22