	zpage r0
	zpage r1
	zpage r2
	zpage r3
	zpage r4
	zpage r5
	global ___moduint16
	global ___modint16

	section text

___modint16:
	ldy #0
	lda r1
	bpl mpos
	lda #0
	sec
	sbc r0
	sta r0
	lda #0
	sbc r1
	sta r1
	ldy #1
mpos:
	lda r3
	bpl mpos2
	lda #0
	sec
	sbc r2
	sta r2
	lda #0
	sbc r3
	sta r3
mpos2:
	cpy #0
	beq ___moduint16
	jsr ___moduint16
;	cpy #0
;	beq mnoneg
	eor #255
	clc
	adc #1
	pha
	txa
	eor #255
	adc #0
	tax
	pla
mnoneg:
	rts

___moduint16:
        lda     #0
	tay
	taz
        ldx     r1
        lda     r0
	stq	btmp0
        lda     #0
	tay
	taz
        ldx     r3
	lda	r2
	stq	btmp1
	jmp	___moduint32
