读取文件的内容并将其打印到程序集x64中的stdout

问题描述

我写了一个非常的简单汇编程序(x64,Linux),该程序从/ etc / passwd中读取内容(实际上从什么地方都没关系)并将其写入stdout。我用nasm(nasm -f elf64 foo.asm -o bar)进行编译。我收到以下错误./bar: 24: Syntax error: EOF in backquote substitution

这是我的代码

global _start
section .data
    fn:  db  '/etc/passwd',0

section .bss

section .text
_start:
    ; open the file
    xor rax,rax
    add al,2
    lea rdi,[fn]
    xor rsi,rsi
    syscall

    ; read the file,use some area
    ; in the stack to store the contents
    mov rdi,rax
    sub sp,0xfff
    lea rsi,[rsp]
    xor rdx,rdx
    mov dx,0x200
    xor rax,rax
    syscall

    ; write to stdout
    xor rdi,rdi
    add dil,1
    mov rdx,rax
    xor rax,1 
    syscall
    ; exit
    xor rax,60
    syscall

是否也可以获取有关该错误的更多信息?程序编译时没有nasm错误。 谢谢:)!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)