- 論壇徽章:
- 0
|
哪位大俠幫我看看下面的匯編程序,我運(yùn)行時(shí)出錯(cuò),系統(tǒng)環(huán)境是linux。
要實(shí)現(xiàn)的功能很簡單,就是在打印一個(gè)字符串。
gnu.c- #include<stdio.h>
- char *able = "hello";
-
- int main(void)
- {
- a_add (able);
-
- return 0;
- }
復(fù)制代碼 ass.s- .section .text
- .type a_add,@function
- .globl a_add
- a_add:
- pushl %ebp #現(xiàn)場保護(hù),
- pushl %ecx
- movl %esp,%ebp #
-
- movl 12(%ebp),%ecx #取得C函數(shù)傳過來的參數(shù)
- movl %ecx,%esi #放到si中
- call message
-
- addl $4,%esp #清理局部變量
- popl %ecx
- popl %ebp #恢復(fù)現(xiàn)場
- ret #返回
- 1:
- movw $0x0001, %bx
- movb $0xe, %ah
- int $0x10 #利用中斷顯示字符
- message:
- lodsl
- cmpb $0, %al
- jne 1b
- ret
復(fù)制代碼 我編譯、運(yùn)行:
#gcc gnu.c ass.s
#./a.out
出現(xiàn)段錯(cuò)誤,我對匯編不是很熟悉,大俠幫我找找錯(cuò)? |
|