SUB_BIN2BCD16: MOV A, R3 ANL A, #11111100B RR A RR A MOV R5, A ADD A, R5 ADD A, R5 MOV R7, A MOV A, R2 ANL A, #3 MOV R6, A XRL A, R3 ANL A, #3 XRL A, R2 RR A RR A ADD A, R7 JC BIN2BCD16_L1 SJMP BIN2BCD16_L2 BIN2BCD16_L1: INC R5 ADD A, #6 BIN2BCD16_L2: ADD A, R7 MOV B, #25 JNC BIN2BCD16_L3 INC R5 ADD A, #6 DIV AB SJMP BIN2BCD16_L4
BIN2BCD16_L4B: SJMP BIN2BCD16_L4
BIN2BCD16_L3: DIV AB CJNE A, #10, BIN2BCD16_L4B INC R5 CLR A BIN2BCD16_L4: MOV R7, A ; *100
MOV A, #10 XCH A, B ; B = 10 ADD A, #(L16DB-$-3) MOVC A, @A+PC ADD A, R6 DA A XCH A, R5 ; *1 BCD
DIV AB XCH A, R7 ; *10000 SWAP A ORL A, B SWAP A MOV R6, A RET L16DB: DB 00H, 04H, 08H, 12H, 16H DB 20H, 24H, 28H, 32H, 36H DB 40H, 44H, 48H, 52H, 56H DB 60H, 64H, 68H, 72H, 76H DB 80H, 84H, 88H, 92H, 96H ;===================== end ;16 bits bin2bcd 52 周期 ;32 bits bin2bcd 185 周期(算法暂时不公开)
|