TITLE PROG3-7 (EXE) ADDING ASCII NUMBERS PAGE 60,132 .MODEL SMALL .STACK 64 ;-------------- .DATA VALUE1 DB '0659478127' ORG 0010H VALUE2 DB '0779563678' ORG 0020H RESULT1 DB 10 DUP (?) ORG 0030H RESULT2 DB 10 DUP (?) ;-------------- .CODE MAIN PROC FAR MOV AX,@DATA MOV DS,AX CALL ASC_ADD ;call ASCII addition subroutine CALL CONVERT ;call convert to ascii subroutine MOV AH,4CH INT 21H ;go back to DOS MAIN ENDP ;--------------- ;THIS SUBROUTINE ADDS THE ASCII NUMBERS AND MAKES THE RESULT UNPACKED. ASC_ADD PROC CLC ;clear the carry MOV CX,10 ;set up loop counter MOV BX,9 ;point to LSD BACK: MOV AL,VALUE1[BX] ;move next byte of operand 1 ADC AL,VALUE2[BX] ;add next byte of operand 2 AAA ;adjust to make it unpacked BCD MOV RESULT1[BX],AL ;store BCD sum DEC BX ;point to next byte LOOP BACK RET ASC_ADD ENDP ;--------------- ;THIS SUBROUTINE CONVERTS UNPACKED BCD TO ASCII CONVERT PROC MOV BX,OFFSET RESULT1 ;BX points to unpacked BCD data MOV SI,OFFSET RESULT2 ;SI points to ASCII data MOV CX,05 ;CX is loop counter BACK2: MOV AX,WORD PTR [BX] ;get next 2 ASCII bytes OR AX,3030H ;insert ASCII 3s MOV WORD PTR [SI],AX ;store ASCII ADD BX,2 ;increment BCD pointer ADD SI,2 ;increment ASCII pointer LOOP BACK2 RET CONVERT ENDP END MAIN