1
我是一個彙編程序設計的新手,並且在我的PC上運行彙編程序時遇到困難。我不完全瞭解運行該程序的過程。我正在做的是試圖運行如下的「HELLO WORLD」程序。需要幫助,在linux mint中運行一個彙編程序
#include <asm/unistd.h>
#include <syscall.h>
#define STDOUT 1
.data
hello:
.ascii "hello world\n"
helloend:
.text
.globl _start
_start:
movl $(SYS_write),%eax // SYS_write = 4
movl $(STDOUT),%ebx // fd
movl $hello,%ecx // buf
movl $(helloend-hello),%edx // count
int $0x80
movl $(SYS_exit),%eax
xorl %ebx,%ebx
int $0x80
ret
很抱歉,因爲我自己也不明白大部分不加評論。我只是試圖在我的電腦上設置環境,以便我可以學習組裝。
要運行上述代碼,我所做的是首先將文件保存爲「hello.S」。 然後在當前目錄中打開終端我跑以下命令:
/lib/cpp hello.S hello.s
as -o hello.o hello.s //to generate an object file named hello.o
ld hello.o
./a.out
但運行可執行的a.out之後我沒有看到結果符合市場預期。我的意思是程序應該打印出「hello world」,但我沒有得到任何結果,也沒有任何錯誤信息。我知道這個程序是正確的。所以我的系統或運行程序的方式肯定有問題。
爲什麼運行可執行文件a.out後沒有得到任何結果?