UcharDiv: ;R2=A/R1 R0=A%R1 R3,R4 temp ;if divded by zero R2=R0=0 MOV R0,A CLR 04H CLR R4 BC 03H,0 MOV A,@0x0FD ADD A,R1 JBS 03H,0 JMP UcharDiv6 CLR R3 MOV A,@0x0F0 AND A,R1 JBS 03H,2 JMP UcharDiv1 MOV A,@0x04 MOV R3,A SWAP R1 UcharDiv1: CLR R2 BC 03H,0 UcharDiv2: INC R3 RLC R1 JBS 03H,0 JMP UcharDiv2 UcharDiv3: RRC R1 MOV A,R1 SUB A,R0 JBC 03H,0 MOV R0,A RLC R2 DJZ R3 JMP UcharDiv3 UcharDiv4: JBS R4,7 JMP UcharDiv5 COM R2 INC R2 UcharDiv5: JBS R4,7 RETL @0x00 COM R0 INC R0 RETL @0x00 UcharDiv6: RRC R1 JBC 03H,0 JMP UcharDiv7 RRC R1 JBS 03H,0 CLR R0 BC 03H,0 RRC R0 JBS 03H,0 UcharDiv7: BC 03H,0 MOV A,R0 MOV R2,A CLR R0 RLC R0 JMP UcharDiv4 |