;program to print the sum of a three digit number
.model small
.stack 100h
.data
msg1 db 10,13,"Enter a three digit number $"
msg2 db 10,13,"The sum of three digits : $"
value db 0
total db 0
.code
start:
MOV AX, @data
MOV DS, AX
LEA DX, msg1
MOV AH, 09h
INT 21H
read:
MOV AH, 01
INT 21H
CMP AL, 13
JE calculate
MOV value, AL
SUB value, 30h
MOV AL, total
MOV BL, 10
MUL BL
ADD AL, value
MOV total, AL
JMP read
calculate:
MOV AL, total
AAM
MOV CL, AL
AAM
ADD AL, AH
ADD AL, CL
MOV DL, AL
LEA DX, msg2
MOV AH, 09h
INT 21H
MOV AH, 02
INT 21H
MOV AH, 4CH
INT 21H
end start
I am a beginner in Assembly Programming in 8086. And I have written a program to print the sum of a three digit number. I think I have successfully taken a three digit number as an input , and also the sum part using AAM seems to be correct but the output is an unwanted character. Could someone tell me where I went wrong?