diff kernel/src/io.c3 @ 359:b4ac28efcdf4

Reorganize files
author Windel Bouwman
date Fri, 14 Mar 2014 15:41:55 +0100
parents kernel/io.c3@52492b304adf
children 42343d189e14
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/src/io.c3	Fri Mar 14 15:41:55 2014 +0100
@@ -0,0 +1,53 @@
+module io;
+import arch;
+
+function void println(string txt)
+{
+    print(txt);
+    arch.putc(10); // Newline!
+}
+
+function void print(string txt)
+{
+    var int i;
+    i = 0;
+
+    while (i < txt->len)
+    {
+        arch.putc(cast<int>(txt->txt[i]));
+        i = i + 1;
+    }
+}
+
+// Print integer in hexadecimal notation:
+function void print_int(int i)
+{
+    print("0x");
+
+    // int txt[20];
+    var int b;
+    var int c;
+    var int d;
+    d = 12;
+
+    for (b = 28; b > 0; b = b - 4)
+    {
+        //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("");
+}
+