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

看板ASM (組合語言)作者 (厚片豬排)時間16年前 (2008/03/04 10:45), 編輯推噓1(105)
留言6則, 3人參與, 最新討論串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 13:59, , 1F
FD'FL'SDLF;L'DFS;'FSDLDF'LSDLF;SDLSD'LSDLF'DLFD;SFDL';SD
03/04 13:59, 1F

03/04 13:59, , 2F
FKL;SDKFLSD'FDLS;'SDFL';SDLFD';FLDS'FSDL'LFDS';SDFLFD';
03/04 13:59, 2F

03/04 13:59, , 3F
FK;DSLFKDL;KFL;SDKFDL;KDFL;FDKDL;KF;LKDL;FKDSL;FDK;DK;L
03/04 13:59, 3F

03/05 09:14, , 4F
樓上..?
03/05 09:14, 4F

03/06 20:58, , 5F
一樓是來亂的?
03/06 20:58, 5F

03/07 01:42, , 6F
square.s我在SunOS下組譯出錯
03/07 01:42, 6F
文章代碼(AID): #17pBUqhV (ASM)
文章代碼(AID): #17pBUqhV (ASM)