.MODEL SMALL
.STACK 64
;--------------------------------------------------------------------
.DATA
DATA1_ASC DB '1234545612'
DATA2_ASC DB '5645342978'
DATA1_BCD DB 5 DUP(?)
DATA2_BCD DB 5 DUP(?)
DATA3_ADD DB 5 DUP(?)
DATA4_ASC DB 10 DUP(?)
;--------------------------------------------------------------------
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV SI,OFFSET DATA1_ASC
MOV BX,OFFSET DATA1_BCD
MOV CX,10
CALL CONV_BCD
;*****************data1 convert...
MOV SI,OFFSET DATA2_ASC
MOV BX,OFFSET DATA2_BCD
MOV CX,10
CALL CONV_BCD
;*****************data2 converT
CALL BCD_ADD
CALL CONV_ASC
HLT
MAIN ENDP
;---------------------------------------------------------------------
CONV_BCD PROC
LP: PUSH CX
MOV AX,[SI]
XCHG AH,AL
AND AX,0F0FH
MOV CL,04
SHL AH,CL
OR AL,AH
MOV [BX],AL
INC BX
INC BX
INC SI
POP CX
LOOP LP
RET
CONV_BCD ENDP
;----------------------------------------------------------------------
BCD_ADD PROC
MOV SI,OFFSET DATA1_BCD
MOV DI,OFFSET DATA2_BCD
MOV BX,OFFSET DATA3_ADD
MOV CX,5
CLC
LP2:MOV AL,[SI]
ADC AL,[DI]
DAA
MOV [BX],AL
INC SI
INC DI
INC BX
LOOP LP2
RET
BCD_ADD ENDP
;-----------------------------------------------------------------------
CONV_ASC PROC
MOV SI,OFFSET DATA3_ADD
MOV DI,OFFSET DATA3_ASC
MOV CX,05
LP3: MOV AL,[SI]
MOV AH,AL
AND AX,0F00FH
MOV CL,04
SHR AH,CL
XCHG AH,AL
OR AX,3030H
MOV [DI],AX
ADD DI,2
INC SI
LOOP LP3
RET
CONV_ASC ENDP
;------------------------------------------------------------------------
No comments:
Post a Comment