.define	.dvi

	.sect .text

.dvi:	LDMFD R12<,{R1,R2}
	STMFD R12<,{R4}
	CMP R1,#0
	BEQ dbyzero
	MOV R4,#0
	CMP R1,#0
	ADD.LT R4,R4,#1
	RSB.LT R1,R1,#0
	CMP R2,#0
	ADD.LT R4,R4,#2
	RSB.LT R2,R2,#0
	MOV R0,#1
div1:	CMP R1,#0x80000000
	CMP.CC R1,R2
	MOV.CC R1,R1,ASL #1
	MOV.CC R0,R0,ASL #1
	BCC div1
	MOV R3,#0
div2:	CMP R2,R1
	SUB.CS R2,R2,R1
	ADD.CS R3,R3,R0
	MOV.S R0,R0,LSR #1
	MOV.NE R1,R1,LSR #1
	BNE div2
	CMP R4, #1
	RSB.EQ R3,R3,#0
	CMP R4,#2
	RSB.EQ R3,R3,#0
	LDMFD R12<,{R4}
	MOV R15,R14
dbyzero:
	MOV R0,#6
	STMFD R12<,{R0}
	BAL _EmTrp

