Search code examples
assemblyx86dos

Assembly code to print a new line string


I have an assembly code to print (display) a string. My problem is I'm not able to how print two string into different line!

.MODEL SMALL 
.STACK 100H

.DATA
MSG1 DB 'Fun $'
MSG2 DB 'Day!$'
.CODE 
MAIN PROC
MOV AX, @data
MOV DS, AX 

LEA DX,MSG1
MOV AH,9
LEA DX,MSG2
MOV AH,9

INT 21H 

MOV AH,4Ch 
INT 21H

MAIN ENDP
END MAIN

The output should be like:

Fun 
Day!

But in Result:

Day!

Help me!


Solution

  • You are missing the INT 21H call for the first part, that's why only the second is printed. As for the two lines, just append a CR LF to your string. You can also print the whole thing at once, such as:

    .MODEL SMALL 
    .STACK 100H
    
    .DATA
    MSG DB 'Fun', 10, 13, 'Day!$'
    .CODE 
    MAIN PROC
    MOV AX, @data
    MOV DS, AX 
    
    LEA DX,MSG
    MOV AH,9
    INT 21H
    
    MOV AH,4Ch 
    INT 21H
    
    MAIN ENDP
    END MAIN