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