Page 1 of 1

[solved] link nasm to c

Posted: Mon Mar 22, 2021 2:44 am
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.

Re: link nasm to c

Posted: Tue Mar 23, 2021 2:14 pm
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.)

Re: link nasm to c

Posted: Tue Mar 23, 2021 2:25 pm
by acccidiccc
thanks a ton! this worked and now i can implement interrupts peacefully.