.define .dvu

.sect .text

.dvu:
 LDMFD R12<,{R0,R1}
 STMFD R12<,{R4}
 CMP R0,#0
 BEQ divbyzero
 MOV R2,#0
 MOV R3,#0
 MOV R4,#32
DVU11:
 SUB.S R4,R4,#1
 LDMFD.EQ R12<,{R4}
 MOV.EQ R15,R14
 MOV.S R1,R1,ASL #1
 BPL DVU11
DVU22:
 MOV.S R1,R1,ASL #1
 ADC R2,R2,R2
 CMP R2,R0
 SUB.CS R2,R2,R0
 ADC R3,R3,R3
 SUB.S R4,R4,#1
 BNE DVU22
 LDMFD R12<,{R4}
 MOV R15,R14
divbyzero:
 MOV R0,#6
 STMFD R12<,{R0}
 BAL _EmTrp
