我找到了“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