【发布时间】:2024-04-29 10:50:02
【问题描述】:
我在 Ubuntu 上使用 NASM 汇编程序。我正在尝试执行此代码:
section .data
fmt db "%d",0
val1 dd 23
val2 dd 9
val3 dd 7
section .text
global _start
extern printf
_start:
push val1
push val2
push val3
pop rax
pop rbx
imul rax, rbx
push rax
pop rax
pop rbx
add rax, rbx
push rax
pop rax
mov [val1], rax
push val1
push fmt
call printf
add rsp, 16
mov rax,0
ret
nasm -f elf64 test64.asm 成功创建了 test64.o,ld -s -o hello test64.o -lc 创建了一个可执行文件,但是当我尝试运行它时,出现“没有这样的文件或目录”错误。
【问题讨论】:
-
关于编辑 - 我正在添加 Linux 标签。这段代码是用 NASM 编译的;是关于在类似 Linux 的环境中运行可执行文件(证实了我们被标记为 Ubuntu 的事实);链接器目标是 ELF64。我建议,鉴于这些信息,Linux 仍然是一个适用的标签,因为它是一个关于 Linux 环境中软件开发的问题,要解决这个问题需要一个 Linux 特定的解决方案。
标签: linux assembly ubuntu-14.04 nasm x86-64