Assembly Program to get a String from user and Store it


This program uses string instructions to get a string from the user and store it in the memory. After storing this program simply prints the stored string entered by the user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB "ENTER A STRING: $"
MSG2 DB 0DH, 0AH, "YOU ENTERED: $"
STRING DB 100 DUP(?)     
.CODE
MAIN PROC
    
     MOV AX, @DATA
     MOV DS, AX
     MOV ES, AX
     
     MOV AH, 9
     LEA DX, MSG1
     INT 21H
     
     LEA DI, STRING
 
     MOV AH, 1
     READ:
     INT 21H
     CMP AL, 0DH
     JE ENDOFSTRING
     STOSB
     JMP READ
     
     ENDOFSTRING:
     MOV AL, "$"
     STOSB
     
     MOV AH, 9
     LEA DX, MSG2
     INT 21H
     
     MOV AH, 9
     LEA DX, STRING
     INT 21H
     
    MAIN ENDP
END MAIN

Output: 

No comments