Nobody is taught to use comments anymore? It is so important to comment your code in Assembly, ESPECIALLY in ancient 16bit code where functions don't have names but numbers!!
Your getting weird characters because after you get the input character, you are modifying it by adding 20h to dl
.
To print each letter on a new line, you need to add a call to your nlcr
in your y
loop, but you must also save the register dx
This should get you started:
main proc
mov ax,@data
mov ds, ax
mov ah, 9
lea dx, string
int 21h
call nlcr
mov ah, 9
lea dx, string2
int 21h
mov ah, 1 ; get user input
int 21h
mov dl, al
call nlcr ; print CRLF
mov cx, 25 ; print 25 chars in loop
inc dl ; adjust to print input char on 1st iteration
PrintChar:
mov ah, 2 ; print char
dec dl
int 21h
call nlcr ; print CRLF
loop PrintChar ; repeat loop until cx == 0
mov ah, 4ch ; goodbye
int 21h
main endp
nlcr proc
push dx ; save dx since dl contains char to print
mov ah, 2
mov dl, 13
int 21h
mov dl, 10
int 21h
pop dx
ret
nlcr endp