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 var int d;
|
|
31 d = 12;
|
|
32
|
|
33 for (b = 28; b > 0; b = b - 4)
|
355
|
34 {
|
356
|
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
|
355
|
49 }
|
356
|
50
|
|
51 println("");
|
355
|
52 }
|
|
53
|