This is my program to print even numbers in 8086 for n>10. My logic seems to be correct, but it's printing 00 50 50... and so on. I am a beginner in 8086 programming a help would be very much appreciated.
When I emulate the code I have seen that right after the AAM line the value of the AL register which was 2 changes to 5.
;Program to print even numbers using loop for multiple digit range
.model small
.stack 100h
.data
n db '?'
msg1 db 10,13,"Enter the range : $"
msg2 db 10,13, "The even numbers are $"
value db 0
total db 0
.code
begin:
MOV AX, @data
MOV DS, AX
LEA DX, msg1
MOV AH, 09h
INT 21H
read: ;to read digits more than 1
MOV AH, 01
INT 21H
CMP AL, 13
JE message
MOV value, AL
SUB value, 30h
MOV AL, total
MOV BL, 10
MUL BL
ADD AL, value
MOV total, AL
JMP read
MOV AL, total
MOV n , AL
message:
LEA DX, msg2
MOV AH, 09h
INT 21H
;initialising variables
MOV CL, 0
MOV BL, 0
even:
MOV AL, BL
AAM
ADD AX, 3030h
MOV BX, AX
MOV AH, 2
MOV DL, BH
INT 21H
MOV AH,2
MOV DL, BL
INT 21H
ADD BL, 2
MOV DL, ' '
INT 21H
INC CL
CMP CL, n
JNE even
MOV AH, 4CH
INT 21H
end begin