将程序集文件包含在另一个程序集文件中
问题描述:
我有两个文件main.s和test.s,其中test.s看起来像这样:
I have two files, main.s and test.s where test.s looks like this:
test:
add a1,a2,a2
...和main.s看起来像这样:
...and main.s looks like this:
main:
call test
(很多毫无意义的例子).如何在main中包含测试?我正在使用这样的gcc:
(very senseless examples). How can I include test in main? I am using gcc like this:
gcc -o main main.c
gcc -o main main.c
但是我不知道如何在其中使用测试...任何帮助?
But I have no idea how I can use test in there...any help?
答
您可以像在GCC中添加其他文件一样包含文件:
You can include the file just as you would with anything else in GCC:
#include"test.S"
您是否正在使用NASM:
Were you using NASM you would use:
%include "test.s"