Data Segment
Msg1 dB 'Please input your name: $'
Msg2 dB 'Please input your age: $'
Msg3 dB 'your name is'
Buffer1 dB 10 ,?, 10 DUP (?)
Db' $'
Msg4 dB 'age'
Buffer2 DB 3 ,?, 3 DUP (?)
Db' $'
Data ends
Code segment
Assume Cs: code, DS: Data
Start:
MoV ax, Data
MoV ds, ax
; Output msg1
MoV dx, offset msg1
MoV ah, 09 h
Int 21 h
; Output line feed
MoV DL, 0ah
MoV ah, 02 h
Int 21 h
MoV DL, 0dh
MoV ah, 02 h
Int 21 h
Receiving input name
MoV dx, offset buffer1
MoV ah, 0ah
Int 21 h
; Output line feed
MoV DL, 0ah
MoV ah, 02 h
Int 21 h
MoV DL, 0dh
MoV ah, 02 h
Int 21 h
; Output msg2
MoV dx, offset msg2
MoV ah, 09 h
Int 21 h
; Output line feed
MoV DL, 0ah
MoV ah, 02 h
Int 21 h
MoV DL, 0dh
MoV ah, 02 h
Int 21 h
; Receive input age
MoV dx, offset buffer2
MoV ah, 0ah
Int 21 h
; Output line feed
MoV DL, 0ah
MoV ah, 02 h
Int 21 h
MoV DL, 0dh
MoV ah, 02 h
Int 21 h
The output msg3 and buffer1 are stopped only when '$' is encountered, and the memory allocation in the data segment is continuous.
MoV dx, offset msg3
MoV ah, 09 h
Int 21 h
MoV DL, 0ah
MoV ah, 02 h
Int 21 h
The reason for output msg4 and buffer2 is the same as above
MoV dx, offset msg4
MoV ah, 09 h
Int 21 h
MoV ah, 4ch
Int 21 h
Code ends
End start