我找到了「hello world」並寫下了它。 納米hello.s我如何開始學習asm(gas)?
這個代碼
.data
msg:
.string "Hello, world!\n"
len = . - msg
.text
global _start
_start:
movl $len,%edx
movl $msg,%ecx
movl $1,%ebx
movl $4,%eax
int $0x80
movl $0,%ebx
movl $1,%eax
int $0x80
我做as -o hello.o hello.s
我給了一個錯誤
hello.s:6: Error: no such instruction: global _start
delete global _start.
我做
ld -s -o hello.o hello*
error
ld: hello: No such file: No such file or directory
上午在哪裏我錯了?
p/s debian,amd64。
很難說出你在問什麼。當您遇到有關「global _start」的錯誤時,您確實運行了彙編程序。您應該查看彙編器的手冊以查看該行的錯誤。也許它不應該有一個空間或全球需要一個「。」前面。 –
2013-02-15 19:15:49
也可以使用'gcc'編譯器,並查看其生成的彙編代碼,例如'gcc -Wall -fverbose-asm -O -S file.c'然後查看'file.s' – 2013-02-15 21:40:10