一个 hex to bcd 的算法程序

HEX_BCD:CLR A
MOV 30H,A
MOV 31H,A
MOV 32H,A
MOV R2,#15
H_B0: MOV A,R1
RLC A
MOV R1,A
MOV A,R0
RLC A
MOV R0,A
MOV A,32H
RLC A
ACALL BCD_ADJ
MOV 32H,A
MOV A,31H
RLC A
ACALL BCD_ADJ
MOV 31H,A
MOV A,30H
RLC A
ACALL BCD_ADJ
MOV 30H,A
DJNZ R2,H_B0
MOV A,R0
RLC A
MOV A,32H
RLC A
MOV 32H,A
MOV A,31H
RLC A
MOV 31H,A
MOV A,30H
RLC A
MOV 30H,A
RET
BCD_ADJ:PUSH PSW
PUSH ACC
CJNE A,#50H,$+2
JC B1
POP ACC
ADD A,#30H
PUSH ACC
B1: ANL A,#0FH
CJNE A,#5,$+2
JC B2
POP ACC
ADD A,#3
PUSH ACC
B2: POP ACC
POP PSW
RET