我写了一个小 .s 程序,它必须在监视器上打印一个小字符串。 然后我在 Windows 10 上打开了 linux bash 并完成了:
as -o file.o file.s
ld -o file file.o
./file
但它不打印任何东西 为什么?我在 linux 虚拟机上尝试了相同的代码并且它有效
该文件是一个简单的“hello world”,用于在学校学习汇编
.section .data
hello:
.ascii "Hello, World!\n"
hello_len:
.long . - hello
.section .text
.global _start
_start:
movl $4, %eax
movl $1, %ebx
leal hello, %ecx
movl hello_len, %edx
int $0x80
movl $1, %eax
xor %ebx, %ebx
int $0x80
最佳答案
由于 WSL 目前处于测试阶段,因此某些功能尚不可用。运行 32 位 ELF 二进制文件是缺失功能的一部分(问题记录在 WSL github 和 uservoice 上)。
目前,要执行您想要的操作,您可以等到开发人员发布此功能或使用可在 here 中找到的 x86_64
指令集重新编写您的程序。 .
关于linux - 在 Windows Bash 上执行程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42855363/