我有一个 64 位 Ubuntu 操作系统,我一直在学习 32 位汇编。我正在尝试编译这两个文件:
正方形.s:
#square.s
.section .text
.globl sqr
.type sqr, @function
sqr:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
imull %eax, %eax
popl %ebp
ret
主.c:
//main.c
#include <stdio.h>
extern long sqr(long);
int main(int argc, char* argv[])
{
long squared = sqr(10);
printf("%lu\n", squared);
return 0;
}
在我的 32 位虚拟机上,我用这个命令编译了它们
gcc main.c square.s -o test
它奏效了。我遇到的问题是我想在我的 64 位机器上编译这些文件。我尝试了几种编译这些文件的方法,但都没有奏效。谁能指出我正确的方向?有没有办法做到这一点?我试过-m32但这没有用。
当我这样做时:
gcc -m32 -o test main.c square.s
我明白了:
In file included from /usr/include/stdio.h:28:0,
from main.c:1:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.