Simple assembly of man-machine conversation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.