Include assembly file in another assembly file

2020-07-24 05:39发布

I have two files, main.s and test.s where test.s looks like this:

test:
   add a1,a2,a2

...and main.s looks like this:

main:
   call test

(very senseless examples). How can I include test in main? I am using gcc like this:

gcc -o main main.c

But I have no idea how I can use test in there...any help?

1条回答
放荡不羁爱自由
2楼-- · 2020-07-24 06:13

You can include the file just as you would with anything else in GCC:

 #include"test.S"

Were you using NASM you would use:

 %include "test.s"
查看更多
登录 后发表回答