8086汇编创建文件并写入内容
Posted u25th_engineer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了8086汇编创建文件并写入内容相关的知识,希望对你有一定的参考价值。
图 1程序编译前
图 2 程序编译后
图 3 程序运行后
图 4 用edit打开所创建的文件
图 5 查看文件内容
图 6 查看文件内容
stack segment stack
db 512 dup(?)
stack ends
data segment
filename db 'motto.txt',0
fhandle dw ?
buff db "There are more things in heaven and earth, Horatio, than are dreamt of in your philosophy. $" ;"8086 ALP $"
data ends
code segment
assume cs:code, ss:stack, ds:data
start:
mov ax, stack
mov ss, ax
mov ax,data
mov ds,ax
mov ah,3ch;set function number to crate filename
xor cx,cx ;make contents of cx all zero
mov dx,seg filename;mov segment address of filename in which
mov ds,dx; it is appearing, to register dx and then to ds
mov dx,offset filename; points to filename
int 21h;call software interrupt of type 21 h
mov ah,3dh;set function number to open file
mov al,1 ; set file access mode as 1 i.e. write access
mov dx,seg filename;mov segment address of filename in which
mov ds,dx; it is appearing, to register dx and then to ds
mov dx,offset filename;points to filename
int 21h; call sofrware interrupt of type 21h
mov fhandle,ax; mov flie handler of file motto.txt to fhandle
mov ah,40h;mov function number to ah to write into file
mov dx,seg buff;mov segment address of buff in which
mov ds,dx;it is appearing, to register dx and then to ds
mov dx,offset buff; points to buff
mov bx,fhandle;mov flie handler of file motto.txt to fhandle
mov cx, 90;8; specify number of butes to write into file
int 21h;call software interrupt of type 21h to write into file
mov ah,3eh;set function number to close file
mov bx,fhandle; move fhandle to bx
int 21h; call software interruopt of the type 21h to close file
mov ah, 4ch
int 21h
code ends
end start
以上是关于8086汇编创建文件并写入内容的主要内容,如果未能解决你的问题,请参考以下文章
Android 逆向使用 Python 解析 ELF 文件 ( Capstone 反汇编 ELF 文件中的机器码数据 | 创建反汇编解析器实例对象 | 设置汇编解析器显示细节 )(代码片段