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

时间:2020-10-23 11:13:25

标签: assembly x86-64 nasm eof backquote

我写了一个非常的简单汇编程序(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, rax
    add al,1 
    syscall
    ; exit
    xor rax,rax
    add al, 60
    syscall

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

0 个答案:

没有答案
相关问题