Assembly -- creat file like this

Source: Internet
Author: User

Data Segment
Path dB 'goodjob. txt ', 0
Fileinfo dB 'possible is nothing'
Mok dB 'goodjob, creat file sucdess! $'
Merror dB 'Sorry, failed! '
Handle DW?
Data ends
Code segment

Assume DS: data, CS: Code

Start:
MoV ax, Data
MoV ds, ax
MoV CX, 0

MoV dx, offset path
MoV ah, 3ch
Int 21 h
JC Error

MoV handle, ax; Save handle

MoV dx, offset Mok; Calculate the number of character

Sub dx, offset fileinfo; The sum of character save in dx, and then move to CX
MoV CX, DX
MoV BX, handle
MoV dx, offset fileinfo; Write data to file

MoV ah, 40 h
Int 21 h

JC Error
MoV BX, handle; Close the Open File
MoV ah, 3eh
Int 21 h
JC Error
MoV dx, offset Mok; Write the message on screen that the program work well
MoV ah, 9
Int 21 h
JMP end1
Error:
MoV dx, offset merror; If program terminal unnormal, then tell puts the information on sreen
MoV ah, 9
Int 21 h
End1:
MoV ah, 7; Waiting for user to press any key to exit the program
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.