作者chup (厚片猪排)
看板ASM
标题[请益] 将C code某段函数转换为汇编,使用gcc & gas
时间Tue Mar 4 10:45:07 2008
原始档有两个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
1F:→ Miayi:FD'FL'SDLF;L'DFS;'FSDLDF'LSDLF;SDLSD'LSDLF'DLFD;SFDL';SD 03/04 13:59
2F:→ Miayi:FKL;SDKFLSD'FDLS;'SDFL';SDLFD';FLDS'FSDL'LFDS';SDFLFD'; 03/04 13:59
3F:→ Miayi:FK;DSLFKDL;KFL;SDKFDL;KDFL;FDKDL;KF;LKDL;FKDSL;FDK;DK;L 03/04 13:59
4F:→ guteres:楼上..? 03/05 09:14
5F:→ loveflames:一楼是来乱的? 03/06 20:58
6F:推 loveflames:square.s我在SunOS下组译出错 03/07 01:42