annotate kernel/src/io.c3 @ 381:6df89163e114

Fix section and ldr pseudo instruction
author Windel Bouwman
date Sat, 26 Apr 2014 17:41:56 +0200
parents 42343d189e14
children
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
360
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
31 for (b=28; b >= 0; b = b - 4)
355
c2ddc8a36f5e Enabled optimization
Windel Bouwman
parents:
diff changeset
32 {
360
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
33 c = (i >> b) & 0xF;
356
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
34 if (c < 10)
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
35 {
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
36 arch.putc( 48 + c );
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
37 }
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
38 else
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
39 {
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
40 arch.putc( 65 - 10 + c );
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
41 }
355
c2ddc8a36f5e Enabled optimization
Windel Bouwman
parents:
diff changeset
42 }
356
52492b304adf Added newline to print
Windel Bouwman
parents: 355
diff changeset
43
360
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
44 arch.putc(10); // Newline!
355
c2ddc8a36f5e Enabled optimization
Windel Bouwman
parents:
diff changeset
45 }
c2ddc8a36f5e Enabled optimization
Windel Bouwman
parents:
diff changeset
46
360
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
47 function void print2(string label, int value)
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
48 {
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
49 print(label);
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
50 print_int(value);
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
51 }
42343d189e14 Bugfix in for loop
Windel Bouwman
parents: 359
diff changeset
52