diff kernel/io.c3 @ 356:52492b304adf

Added newline to print
author Windel Bouwman
date Fri, 14 Mar 2014 13:02:16 +0100
parents c2ddc8a36f5e
children
line wrap: on
line diff
--- a/kernel/io.c3	Fri Mar 14 10:30:13 2014 +0100
+++ b/kernel/io.c3	Fri Mar 14 13:02:16 2014 +0100
@@ -1,6 +1,12 @@
 module io;
 import arch;
 
+function void println(string txt)
+{
+    print(txt);
+    arch.putc(10); // Newline!
+}
+
 function void print(string txt)
 {
     var int i;
@@ -13,12 +19,35 @@
     }
 }
 
+// Print integer in hexadecimal notation:
 function void print_int(int i)
 {
+    print("0x");
+
     // int txt[20];
-    while (i != 0)
+    var int b;
+    var int c;
+    var int d;
+    d = 12;
+
+    for (b = 28; b > 0; b = b - 4)
     {
-        arch.putc(1);
+        //c = 7; // (i >> b) & 0xF;
+        d = b;
+        c = (i >> d) & 0xF;
+        // c = (i >> b) & 0xF;
+        if (c < 10)
+        {
+            arch.putc( 48 + c );
+        }
+        else
+        {
+            arch.putc( 65 - 10 + c );
+        }
+        // arch.putc( 65 );
+
     }
+
+    println("");
 }