having a hard time printing new line in assembly language

Viewed 34

newbie here, just started learning about assembly language and i couldn't print a new line for some reason idk what i did wrong, i also tried trying some of the answers i found in here but still not working, okay well here's the code

.model small
.stack 0100h
.data
   a db "name $"
   b db "year $"
   c db "school name $"
   d db "phone number $"
   
.code
    mov ax, @data
    mov ds, ax
    
    mov ah, 09h
    mov dx, offset a
    int 21h     
    
    mov dl, 0ah
    int 21h
    mov dl, 0dh
    int 21h
    
    mov dx, offset b
    int 21h
    
    mov dl, 0ah
    int 21h
    mov dl, 0dh
    int 21h 
    
    mov dx, offset c
    int 21h 
    
    mov dl, 0ah
    int 21h
    mov dl, 0dh
    int 21h
    
    mov dx, offset d
    int 21h

    mov ax, 4c00h
    int 21h 

end
1 Answers

In DOS int 21h with AH=9 prints a $ terminated string pointed to by DS:DX, it has no ability to determine that you intend print the character loaded into DL as registers do not remember the type of value loaded into them, unlike some other languages.

You can use int 21h with AH=2 to print individual characters, or you can add the newlines to the $ terminated strings.

Related