📄 file.asm
字号:
data_seg segment
path db 'c:\file.txt',0 ;file path
digit dw ? ;file digit
dataw db 3 dup(?) ;data buffer
data_seg ends
setfile proc near ;establish a new file
lea dx,path ;
mov cx,0
mov ah,3ch
int 21h
jnc nexts
nexts:
mov digit,ax ;save file digit
ret
setfile endp ;open file
openfile proc near
lea dx,path
mov al,2
mov ah,3dh
int 21h
jnc nexto ;if can not open then establish a new file
call setfile
nexto:
mov digit,ax ;set the file pointer to file head
mov al,0
mov cx,0
mov dx,0
mov ah,42h
int 21h
ret
openfile endp
closefile proc near ;close file
mov ah,3eh
mov bx,digit
int 21h
ret
closefile endp
readfile proc near ;read file content to data buffer
lea dx,dataw
mov bx,digit
mov cx,3
mov ah,3fh
int 21h
ret
readfile endp
writefile proc near
lea dx,dataw ;write data buffer content to data buffer
mov cx,3
mov ah,40h
mov bx,digit
int 21h
call closefile
ret
writefile endp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -