diff --git a/kernel/arch/i386/serial.nim b/kernel/arch/i386/serial.nim index baa11d0..28ea0ec 100644 --- a/kernel/arch/i386/serial.nim +++ b/kernel/arch/i386/serial.nim @@ -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') diff --git a/kernel/kernel.nim b/kernel/kernel.nim index 19d1f81..b4da3a8 100644 --- a/kernel/kernel.nim +++ b/kernel/kernel.nim @@ -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:")