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