[solved] link nasm to c

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
acccidiccc
Member
Member
Posts: 38
Joined: Sun Mar 21, 2021 1:09 pm
Location: current location

[solved] link nasm to c

Post by acccidiccc »

so i have been following the meaty skeleton tutorial and wanted to implement interrupts. so i followed the tutorial on interrupts and now, how should i link the assembly to the c. I probably need to manipulate the kernel makefile, but i have no idea how.
sorry for asking a stupid question.
Last edited by acccidiccc on Tue Mar 23, 2021 2:25 pm, edited 1 time in total.
iustitiae iniustos iudicat
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: link nasm to c

Post by Octocontrabass »

The makefile already supports assembly using GAS, so if you want to use NASM as well you'll have to specify another file extension for assembly using NASM instead of GAS. Add the suffix here:

Code: Select all

.SUFFIXES: .o .c .S .asm
And add a rule to build NASM assembly source files into object files right around the lines for building other source files into object files:

Code: Select all

.asm.o:
	nasm -f elf -MD -o $@ $<
(I haven't tested this so the syntax may not be quite right.)
User avatar
acccidiccc
Member
Member
Posts: 38
Joined: Sun Mar 21, 2021 1:09 pm
Location: current location

Re: link nasm to c

Post by acccidiccc »

thanks a ton! this worked and now i can implement interrupts peacefully.
iustitiae iniustos iudicat
Post Reply