[問題] 將C code某段函數轉換為彙編,使用gcc & gas

看板LinuxDev作者 (厚片豬排)時間17年前 (2008/03/04 10:43), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
原始檔有兩個main1.c square.s //main1.c #include<stdio.h> extern int square(int i); int main(void) { int i; for (i=0;i<10;i++) { printf("Square of %d is %d\n",i,square(i)); } } @square.s .text .global square square: MUL r1,r0,r0 @ r1 = r0 x r0 MOV r0,r1 @ r0 = r1 MOV pc,lr @ return r0 .end 編譯步驟與錯誤訊息如下 [leo@localhost main]$ ls main1.c square.s [leo@localhost main]$ gcc -c main1.c [leo@localhost main]$ as -o square.o square.s [leo@localhost main]$ ls main1.c main1.o square.o square.s [leo@localhost main]$ ld -o main1 main1.o square.o ld: warning: cannot find entry symbol _start; defaulting to 00008074 main1.o: In function `main': main1.c:(.text+0x34): undefined reference to `printf' 請問是哪裡的寫法不對?先謝謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.155.213

03/04 15:23, , 1F
03/04 15:23, 1F
文章代碼(AID): #17pBTR2P (LinuxDev)
文章代碼(AID): #17pBTR2P (LinuxDev)