Added int printing to serial module.
This commit is contained in:
parent
ffe67f93c5
commit
8b129ea6d8
@ -22,5 +22,40 @@ proc write*(input: char) =
|
|||||||
proc write*(input: string) =
|
proc write*(input: string) =
|
||||||
for i in 0 .. input.len - 1:
|
for i in 0 .. input.len - 1:
|
||||||
write(input[i])
|
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')
|
||||||
|
@ -5,9 +5,9 @@ import tty, gdt, irq, serial
|
|||||||
|
|
||||||
proc kernelMain() {.exportc: "kernel_main"}=
|
proc kernelMain() {.exportc: "kernel_main"}=
|
||||||
serial.init()
|
serial.init()
|
||||||
serial.write("Booting OS")
|
serial.write("Booting OS\L")
|
||||||
gdt.gdtInstall()
|
gdt.gdtInstall()
|
||||||
serial.write("GDT installed")
|
serial.write("GDT installed\L")
|
||||||
terminalInitialize()
|
terminalInitialize()
|
||||||
terminalWrite("Hello World!\L")
|
terminalWrite("Hello World!\L")
|
||||||
terminalWrite("MAX_INT:")
|
terminalWrite("MAX_INT:")
|
||||||
|
Loading…
Reference in New Issue
Block a user