Mercurial > lcfOS
comparison 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 |
comparison
equal
deleted
inserted
replaced
358:5ef1cb1bb54f | 359:b4ac28efcdf4 |
---|---|
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 var int d; | |
31 d = 12; | |
32 | |
33 for (b = 28; b > 0; b = b - 4) | |
34 { | |
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 | |
49 } | |
50 | |
51 println(""); | |
52 } | |
53 |