Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

8086 program to print a String

  • Difficulty Level : Hard
  • Last Updated : 25 Jun, 2019

Problem: Write an assembly level program to print a given string .

Examples:

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

Input String: "This is a sample string" 
Output: This is a sample string


Input String: "Geeks for Geeks" 
Output: Geeks for Geeks 

Explanation:



  1. Create a string
  2. Load the effective address of the string in dx using LEA command
  3. Print the sting by calling the interrupt with 9H in AH
  4. The string must be terminated by ‘$’ sign

Program




.MODEL SMALL 
.STACK 100H 
.DATA 
  
;The string to be printed 
STRING DB 'This is a sample string', '$'
  
.CODE 
MAIN PROC FAR 
 MOV AX,@DATA 
 MOV DS,AX 
  
 ; load address of the string 
 LEA DX,STRING 
  
 ;output the string
 ;loaded in dx 
 MOV AH,09H
 INT 21H 
  
 ;interrupt to exit
 MOV AH,4CH
 INT 21H 
  
MAIN ENDP 
END MAIN 

Output:

This is a sample string 

Note:
The program cannot be run on an online editor, please use MASM to run the program and use dos box to run MASM, you might use any 8086 emulator to run the program.

My Personal Notes arrow_drop_up
Recommended Articles
Page :