首页 > 解决方案 > NASM 中的文件编辑逆境

问题描述

我想创建一个创建、打开、编辑然后关闭文件的程序,目的是将“hello”写入文件,但不是编辑文件,而是创建一个名为“tfile.txt”的文件,然后将名称编辑为 'tfile.txtHello'$'001'。请帮忙。

section .data
    idfile db '/home/alvaro/nasm/tfile.txt'
    msgfile db 'Hello'
    lonmsg equ $-msgfile
section .text
    global _start
_start:
    mov eax, 8
    mov ebx, idfile
    mov ecx, 777o   
    int 0x80

_openfile:
    mov eax, 5
    mov ebx, [idfile]
    mov ecx, 777o
    int 0x80

_editfile:
    mov eax, 4
    mov ebx, [idfile]
    mov ecx, [msgfile]
    mov edx, lonmsg
    int 0x80

_closefile:
    mov eax, 6
    mov ebx, [idfile]
    int 0x80
    
_finalize:
    mov eax, 1
    mov ebx, 0
    int 0x80

标签: assemblyx86nasm

解决方案


推荐阅读