comparison kernel/io.c3 @ 356:52492b304adf

Added newline to print
author Windel Bouwman
date Fri, 14 Mar 2014 13:02:16 +0100
parents c2ddc8a36f5e
children
comparison
equal deleted inserted replaced
355:c2ddc8a36f5e 356:52492b304adf
1 module io; 1 module io;
2 import arch; 2 import arch;
3
4 function void println(string txt)
5 {
6 print(txt);
7 arch.putc(10); // Newline!
8 }
3 9
4 function void print(string txt) 10 function void print(string txt)
5 { 11 {
6 var int i; 12 var int i;
7 i = 0; 13 i = 0;
11 arch.putc(cast<int>(txt->txt[i])); 17 arch.putc(cast<int>(txt->txt[i]));
12 i = i + 1; 18 i = i + 1;
13 } 19 }
14 } 20 }
15 21
22 // Print integer in hexadecimal notation:
16 function void print_int(int i) 23 function void print_int(int i)
17 { 24 {
25 print("0x");
26
18 // int txt[20]; 27 // int txt[20];
19 while (i != 0) 28 var int b;
29 var int c;
30 var int d;
31 d = 12;
32
33 for (b = 28; b > 0; b = b - 4)
20 { 34 {
21 arch.putc(1); 35 //c = 7; // (i >> b) & 0xF;
36 d = b;
37 c = (i >> d) & 0xF;
38 // c = (i >> b) & 0xF;
39 if (c < 10)
40 {
41 arch.putc( 48 + c );
42 }
43 else
44 {
45 arch.putc( 65 - 10 + c );
46 }
47 // arch.putc( 65 );
48
22 } 49 }
50
51 println("");
23 } 52 }
24 53