Morad Rajeh
Morad Rajeh

Reputation: 11

A to Z in emu8086 every letter in new line

I am solving a problem in assembly language where I have to print capital A to capital Z, each word in a newline but I am not understanding how can I print every character in a newline.

My code only prints A-Z in a single line. Please help me to print every character in a newline.

     ORG 100H

     MOV CX, 26                   

     MOV AH, 2                   
     MOV DL, 65
                 

     LP1:                       
       INT 21H                   

       INC DL                     
       DEC CX                     
 
     JNZ LP1                    

     MOV AH, 4CH                  
     INT 21H

Upvotes: 1

Views: 2227

Answers (2)

Md. Musfiqur Rahaman
Md. Musfiqur Rahaman

Reputation: 348

This code will print A-Z in a new line. See the comments to understand the process and code.


.MODEL SMALL
.STACK 100H 
.DATA 

.CODE
    MOV CX, 26    ;Initial value of counter CX=26 for 26 Alphabets A to Z
    MOV BL, 41H   ;Initial value of BL=A ASCII-41H 
    
    MOV AH, 2
    
    OUTPUT:
    MOV DL, BL    ;Display current value of BL
    INT 21H 
    
    MOV AH, 2H
    MOV DL, 10    ;Print Newline
    INT 21H 
    MOV DL, 13    ;Print Carriage Return
    INT 21H
    
    INC BL        ;Incrementing value of BL, BL=BL+1
    
    LOOP OUTPUT   ;Looping OUTPUT label and in each iteration CX=CX-1
    
    EXIT:
    MOV AH, 4CH   ;Terminating Program
    INT 21H 

Upvotes: 0

Ahtisham
Ahtisham

Reputation: 10116

Just as @Michael Petch said use 10 for line feed and 13 for carriage return.

Here is a working example:

#MAKE-COM#
 ORG 100H

 MOV CX, 26                   

 MOV BL, 65         
 MOV AH, 2 


 LP1:
   MOV DL, BL                
   INT 21H    

   MOV DL, 10  ; LINE FEED                     
   INT 21H 
   MOV DL, 13  ; CARRIAGE RETURN
   INT 21H     

   INC BL                     
   DEC CX                     

 JNZ LP1                    

 MOV AH, 4CH                  
 INT 21H

Upvotes: 1

Related Questions