Skip to content

Commit

Permalink
Updated to work with nim 1.6.0
Browse files Browse the repository at this point in the history
Nim nolonger needs an external library for unsigned integers, so I
removed the call for that library.
I forced the gnu99 dialect of c for compatibility, I'll work on getting
a newer version to work later.
I changed i586-elf-* to i686-elf-* since that is the cross compiler I
have and what osdev says to use. I also explicitly set nimcache since
the default is outside the repo and it was less work to update the
linker command. Nim has a different naming scheme for cached object
files so I updated those in the linker command.
  • Loading branch information
sudo-d4s3 authored and dom96 committed Nov 3, 2021
1 parent 23da4fd commit fd13b98
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions ioutils.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import unsigned
type
PVIDMem* = ptr array[0..65_000, TEntry]

Expand Down Expand Up @@ -77,4 +76,4 @@ proc screenClear*(video_mem: PVidMem, color: TVGAColor) =
var i = 0
while i <=% VGAWidth*VGAHeight:
video_mem[i] = space
inc(i)
inc(i)
4 changes: 2 additions & 2 deletions main.nim.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

--cpu:i386
--boundChecks:on
--passc:"-w -I$lib -ffreestanding -O2 -Wall -Wextra"
--passc:"-w -I$lib -std=gnu99 -ffreestanding -O2 -Wall -Wextra"

--noLinking

Expand All @@ -10,4 +10,4 @@

--deadCodeElim:on
--noMain
--parallelBuild:"1"
--parallelBuild:"1"
8 changes: 4 additions & 4 deletions nakefile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import nake
import os

const
CC = "i586-elf-gcc"
asmC = "i586-elf-as"
CC = "i686-elf-gcc"
asmC = "i686-elf-as"

task "clean", "Removes build files.":
removeFile("boot.o")
Expand All @@ -13,13 +13,13 @@ task "clean", "Removes build files.":

task "build", "Builds the operating system.":
echo "Compiling..."
direShell "nim c -d:release --gcc.exe:$1 main.nim" % CC
direShell "nim c -d:release --nimcache:nimcache --gcc.exe:$1 main.nim" % CC

direShell asmC, "boot.s -o boot.o"

echo "Linking..."

direShell CC, "-T linker.ld -o main.bin -ffreestanding -O2 -nostdlib boot.o nimcache/main.o nimcache/stdlib_system.o nimcache/stdlib_unsigned.o nimcache/ioutils.o"
direShell CC, "-T linker.ld -o main.bin -ffreestanding -O2 -nostdlib boot.o nimcache/@mmain.nim.c.o nimcache/stdlib_system.nim.c.o nimcache/@mioutils.nim.c.o -lgcc"

echo "Done."

Expand Down

0 comments on commit fd13b98

Please sign in to comment.