2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 07.08.1998
|
|
|
|
;
|
|
|
|
; CC65 runtime: modulo operation for unsigned ints
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export tosumoda0, tosumodax
|
|
|
|
.import popsreg, udiv16
|
|
|
|
.importzp ptr1, ptr4
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
tosumoda0:
|
2013-05-09 11:56:54 +00:00
|
|
|
ldx #0
|
2000-05-28 13:40:48 +00:00
|
|
|
tosumodax:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta ptr4
|
|
|
|
stx ptr4+1 ; Save right operand
|
|
|
|
jsr popsreg ; Get right operand
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Do the division
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr udiv16
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Result is in sreg, remainder in ptr1
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
lda ptr1
|
|
|
|
ldx ptr1+1
|
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|