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
|
2018-05-24 01:55:40 +00:00
|
|
|
.import popptr1, udiv16
|
|
|
|
.importzp sreg, 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
|
2018-05-24 01:55:40 +00:00
|
|
|
jsr popptr1 ; 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
|
|
|
|
2018-05-24 01:55:40 +00:00
|
|
|
; Result is in ptr1, remainder in sreg
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2018-05-24 01:55:40 +00:00
|
|
|
lda sreg
|
|
|
|
ldx sreg+1
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2022-04-17 14:06:22 +00:00
|
|
|
|