355
|
1 module io;
|
|
2 import arch;
|
|
3
|
356
|
4 function void println(string txt)
|
|
5 {
|
|
6 print(txt);
|
|
7 arch.putc(10); // Newline!
|
|
8 }
|
|
9
|
355
|
10 function void print(string txt)
|
|
11 {
|
|
12 var int i;
|
|
13 i = 0;
|
|
14
|
|
15 while (i < txt->len)
|
|
16 {
|
|
17 arch.putc(cast<int>(txt->txt[i]));
|
|
18 i = i + 1;
|
|
19 }
|
|
20 }
|
|
21
|
356
|
22 // Print integer in hexadecimal notation:
|
355
|
23 function void print_int(int i)
|
|
24 {
|
356
|
25 print("0x");
|
|
26
|
355
|
27 // int txt[20];
|
356
|
28 var int b;
|
|
29 var int c;
|
|
30
|
360
|
31 for (b=28; b >= 0; b = b - 4)
|
355
|
32 {
|
360
|
33 c = (i >> b) & 0xF;
|
356
|
34 if (c < 10)
|
|
35 {
|
|
36 arch.putc( 48 + c );
|
|
37 }
|
|
38 else
|
|
39 {
|
|
40 arch.putc( 65 - 10 + c );
|
|
41 }
|
355
|
42 }
|
356
|
43
|
360
|
44 arch.putc(10); // Newline!
|
355
|
45 }
|
|
46
|
360
|
47 function void print2(string label, int value)
|
|
48 {
|
|
49 print(label);
|
|
50 print_int(value);
|
|
51 }
|
|
52
|