[英]Why I can't compile this assembly successfully?
引自這個問題 :
.text
call start
str:
.string "test\n"
start:
movl $4, %eax
movl $1, %ebx
pop %ecx
movl $5, %edx
int $0x80
ret
gcc -c test.S
給出:
test.S: Assembler messages:
test.S:8: Error: suffix or operands invalid for `pop'
pop只是命令。 在at&t語法中,您必須推遲操作數維。 因此您必須將“ pop”行更改為“ popl”
編輯
您可能正在嘗試編譯32位程序集的64位系統上。 強制gcc使用-m32編譯32位:
gcc -m32 -c test.S
編輯:
64位版本:
.text
call start
str:
.string "test\n"
start:
movl $1, %eax
movl $1, %edi
popq %rsi
movl $5, %edx
syscall
movl $60,%eax
movl $0, %edi
syscall
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.