User:Primis: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
mNo edit summary |
|||
Line 1: | Line 1: | ||
== Initial Setup == |
|||
In order to make our kernel work, we must be able to compile it, and link it. |
|||
We have two different ways of building our code, the *NIX way with a [[Makefile]], and the Windows way with a [[Batch]] file. |
|||
First is the Makefile: |
|||
<pre> |
|||
# Makefile for our kernel |
|||
# This is designed for *NIX and Cygwin systems |
|||
# Use build.BAT for windows systems |
|||
# Requires GCC and NASM |
|||
# Based on JamesM's Kernel Tutorials |
|||
SOURCES=boot.o main.o |
|||
CFLAGS=-nostdlib -nostdinc -fno-builtin |
|||
LDFLAGS=-Tlink.ld |
|||
ASFLAGS=-felf |
|||
all: |
|||
$(SOURCES) link |
|||
clean: |
|||
-rm *.o kernel |
|||
link: |
|||
ld $(LDFLAGS) -o kernel $(SOURCES) |
|||
.s.o: |
|||
nasm $(ASFLAGS) $< |
|||
</pre> |
|||
The basics are all quite simple, the only rule specifically changed is the assembler, which we've changed from [[GAS]] to [[NASM]], |
|||
The reason quite simply, Intel Syntax is more widely preferred over AT&T syntax in the [[x86]] [[Assembly]] world. |
|||
<source lang="c"> |
|||
// main.c -- Called from assembly, this is our main function. |
|||
int k_main() // We call this k_main() so we don't get main() warnings. |
|||
{ |
|||
return (0xDEADBEEF); |
|||
} |
|||
</source> |