Added int printing to serial module.

This commit is contained in:
neviyn 2017-11-09 23:21:18 +00:00
parent ffe67f93c5
commit 8b129ea6d8
2 changed files with 38 additions and 3 deletions

View File

@ -22,5 +22,40 @@ proc write*(input: char) =
proc write*(input: string) =
for i in 0 .. input.len - 1:
write(input[i])
write('\L')
var parsedData: array[0..9, char]
proc write*(data: SomeSignedInt) =
if(data == 0):
write('0')
return
var input = data
var i = 0
if(input < 0):
write('-')
input = input * -1
while(input != 0):
let parsedChar: char = char(48 + (input mod 10))
parsedData[i] = parsedChar
i = i + 1
input = input div 10
while i > 0:
i = i - 1
write(parsedData[i])
proc write*(data: SomeUnsignedInt) =
if(data == 0):
write('0')
return
var input = data
var i = 0
while(input != 0):
let parsedChar: char = char(48'u + (input mod 10))
parsedData[i] = parsedChar
i = i + 1
input = input div 10
while i > 0:
i = i - 1
write(parsedData[i])
proc newLine*() = write('\L')

View File

@ -5,9 +5,9 @@ import tty, gdt, irq, serial
proc kernelMain() {.exportc: "kernel_main"}=
serial.init()
serial.write("Booting OS")
serial.write("Booting OS\L")
gdt.gdtInstall()
serial.write("GDT installed")
serial.write("GDT installed\L")
terminalInitialize()
terminalWrite("Hello World!\L")
terminalWrite("MAX_INT:")