	zpage	btmp0
	zpage	btmp1
	zpage	btmp2
	zpage	r30
	zpage	r31
	zpage	___m65mathptr

	global	___divint32

	section	text
___divint32:
	lda     #$70
	sta     ___m65mathptr
	lda	btmp0+3
	sta	r30
	bpl	a1pos
	lda	#0
	tax
	tay
	taz
	sec
	sbcq	btmp0
	bra	a1done
a1pos:
	ldq	btmp0
a1done:
	stq	[___m65mathptr]
	lda	#$74
	sta	___m65mathptr
	lda	btmp1+3
	sta	r31
	bpl	a2pos
	lda	#0
	tax
	tay
	taz
	sec
	sbcq	btmp1
	bra	a2done
a2pos:
	ldq	btmp1
a2done:
	stq	[___m65mathptr]
	lda	#$6c
	sta	___m65mathptr
	lda	r30
	eor	r31
	bpl	respos
	lda	#0
	tax
	tay
	taz
	sec
	sbcq	[___m65mathptr] ; do we need more delay?
	stq	btmp0
	ldz	#0
	rts
respos:
	ldz	#0
	ldq	[___m65mathptr],z ; do we need more delay?
	stq	btmp0
	ldz	#0
	rts
