Last change
on this file since 924 was
520,
checked in by bouyer, 11 years ago
|
Re-add the tests; reverting previous which was done at the wrong level (sorry)
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <registers.h> |
---|
2 | /* test common subroutines |
---|
3 | |
---|
4 | .text |
---|
5 | /* |
---|
6 | * void print(char *): print a string to the multitty. |
---|
7 | * assumes k0 points to the tty base. |
---|
8 | */ |
---|
9 | .globl print |
---|
10 | print: |
---|
11 | .set noreorder |
---|
12 | move t0, a0 |
---|
13 | 1: |
---|
14 | lb t1, 0(t0); |
---|
15 | beq t1, zero, end |
---|
16 | nop |
---|
17 | sb t1, 0(k0) |
---|
18 | addiu t0, t0, 1 |
---|
19 | j 1b |
---|
20 | nop |
---|
21 | end: |
---|
22 | jr ra |
---|
23 | nop |
---|
24 | |
---|
25 | /* |
---|
26 | * void print_sync(char *): print a string to the multitty with a sync instruction for each character. |
---|
27 | * assumes k0 points to the tty base. |
---|
28 | */ |
---|
29 | .globl print_sync |
---|
30 | print_sync: |
---|
31 | .set noreorder |
---|
32 | move t0, a0 |
---|
33 | 1: |
---|
34 | lb t1, 0(t0); |
---|
35 | beq t1, zero, end_print_sync |
---|
36 | nop |
---|
37 | sb t1, 0(k0) |
---|
38 | sync |
---|
39 | addiu t0, t0, 1 |
---|
40 | j 1b |
---|
41 | nop |
---|
42 | end_print_sync: |
---|
43 | jr ra |
---|
44 | nop |
---|
45 | |
---|
46 | |
---|
47 | /* |
---|
48 | * void printx(uint32_t): print a number in hex to the multitty |
---|
49 | * assumes points to the tty base. |
---|
50 | */ |
---|
51 | .globl printx |
---|
52 | printx: |
---|
53 | .set noreorder |
---|
54 | move t0, a0 |
---|
55 | li t1, '0' |
---|
56 | sb t1, 0(k0) |
---|
57 | li t1, 'x' |
---|
58 | sb t1, 0(k0) |
---|
59 | li t1, 8 |
---|
60 | 1: |
---|
61 | lui t2, 0xf000; |
---|
62 | and t2, t0, t2 |
---|
63 | srl t2, t2, 28 |
---|
64 | slti t3, t2, 0xa |
---|
65 | beq t3, zero, 2f /* in range A-F */ |
---|
66 | nop |
---|
67 | addi t2, t2, '0' |
---|
68 | j 3f |
---|
69 | nop |
---|
70 | 2: |
---|
71 | addi t2, t2, 'A' - 0xa |
---|
72 | 3: |
---|
73 | sb t2, 0(k0) |
---|
74 | addi t1, t1, -1 |
---|
75 | bgtz t1, 1b |
---|
76 | sll t0, t0, 4 |
---|
77 | jr ra |
---|
78 | nop |
---|
Note: See
TracBrowser
for help on using the repository browser.