From 4d896d0eb7f33462679e5e5f8b8cd3e4969073e3 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Mon, 6 Nov 2017 21:43:34 +0000 Subject: [PATCH] Fixed printing of unsigned integers. --- kernel/arch/i386/tty.nim | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kernel/arch/i386/tty.nim b/kernel/arch/i386/tty.nim index fee3c7a..09836f8 100644 --- a/kernel/arch/i386/tty.nim +++ b/kernel/arch/i386/tty.nim @@ -65,9 +65,9 @@ proc terminalWrite*(data: string) = proc terminalWrite*(data: char) = terminalWriteChar(data) -var parsedData = ['0','0','0','0','0','0','0','0','0','0'] +var parsedData: array[0..9, char] -proc terminalWrite*(data: int) = +proc terminalWrite*(data: SomeSignedInt) = if(data == 0): terminalWrite('0') return @@ -85,3 +85,17 @@ proc terminalWrite*(data: int) = i = i - 1 terminalWrite(parsedData[i]) +proc terminalWrite*(data: SomeUnsignedInt) = + if(data == 0): + terminalWrite('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 + terminalWrite(parsedData[i])