Mercurial > lcfOS
comparison kernel/io.c3 @ 402:0fb6633c42f6
Moved several files to logical locations
author | Windel Bouwman |
---|---|
date | Thu, 19 Feb 2015 00:13:07 +0100 |
parents | kernel/src/io.c3@42343d189e14 |
children | 6aa9743ed362 |
comparison
equal
deleted
inserted
replaced
401:994c00d55fd5 | 402:0fb6633c42f6 |
---|---|
1 module io; | |
2 import arch; | |
3 | |
4 function void println(string txt) | |
5 { | |
6 print(txt); | |
7 arch.putc(10); // Newline! | |
8 } | |
9 | |
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 | |
22 // Print integer in hexadecimal notation: | |
23 function void print_int(int i) | |
24 { | |
25 print("0x"); | |
26 | |
27 // int txt[20]; | |
28 var int b; | |
29 var int c; | |
30 | |
31 for (b=28; b >= 0; b = b - 4) | |
32 { | |
33 c = (i >> b) & 0xF; | |
34 if (c < 10) | |
35 { | |
36 arch.putc( 48 + c ); | |
37 } | |
38 else | |
39 { | |
40 arch.putc( 65 - 10 + c ); | |
41 } | |
42 } | |
43 | |
44 arch.putc(10); // Newline! | |
45 } | |
46 | |
47 function void print2(string label, int value) | |
48 { | |
49 print(label); | |
50 print_int(value); | |
51 } | |
52 |