;多字节十进制整数(压缩
BCD码)转换为
二进制整数子程序NIDTB
;入口:R0指向多字节十进制整数高位,R1指向结果多字节
二进制整数高位,R7=n
;使用A,B,R0~R7,影响CY
NIDTB: MOV A,R1
MOV R6,A
MOV A,R7
MOV R3,A
CLR A
NDB0: MOV @R1,A
INC R1
DJNZ R3,NDB0
MOV A,R7
MOV R3,A
NDB3: CALL NDB1
MOV A,@R0
ANL A,#0F0H
SWAP A
CALL NDB2
CALL NDB1
MOV A,@R0
ANL A,#0FH
CALL NDB2
INC R0
DJNZ R3,NDB3
RET
NDB1: MOV A,R7
MOV R4,A
MOV A,R6
ADD A,R7
DEC A
MOV R1,A
CLR C
MOV R2,#0
NDB4: MOV A,@R1
MOV B,#10
PUSH PSW
MUL AB
POP PSW
ADDC A,R2
MOV @R1,A
MOV R2,B
DEC R1
DJNZ R4,NDB4
RET
NDB2: MOV R5,A
MOV A,R6
ADD A,R7
DEC A
MOV R1,A
MOV A,R7
MOV R4,A
MOV A,R5
ADD A,@R1
MOV @R1,A
DEC R1
DJNZ R4,NDB5
RET
NDB5: MOV A,@R1
ADDC A,#0
MOV @R1,A
DEC R1
DJNZ R4,NDB5
RET
;单字节
BCD码转换成压缩
BCD码子程序
BCDC
;入口:R0指向2n个单字节高位,R1指向n个双字节高位,R3=n
;使用A,R0,R1,R3
BCDC: MOV A,@R0
SWAP A
INC R0
ORL A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,
BCDC
RET