]>
Commit | Line | Data |
---|---|---|
1 | PUTC: MACRO | |
2 | ld a, \1 | |
3 | call putc | |
4 | ENDM | |
5 | ||
6 | PUTS: MACRO | |
7 | ld hl, \1 | |
8 | call puts | |
9 | ENDM | |
10 | ||
11 | PUTSI: MACRO | |
12 | push hl | |
13 | call putsi | |
14 | db \1, 0 | |
15 | pop hl | |
16 | ENDM | |
17 | ||
18 | PUTSIL: MACRO | |
19 | push hl | |
20 | call putsi | |
21 | db \1, 13, 10, 0 | |
22 | pop hl | |
23 | ENDM | |
24 | ||
25 | PUTHEX: MACRO | |
26 | ld a, \1 | |
27 | call puthex | |
28 | ENDM | |
29 | ||
30 | SECTION "serial", HOME | |
31 | ||
32 | putc: | |
33 | push af | |
34 | .waitport: | |
35 | ld a,[$FF53] | |
36 | and $01 | |
37 | jr nz,.waitport | |
38 | pop af | |
39 | ld [$FF52],a | |
40 | ret | |
41 | ||
42 | puts: | |
43 | ld a, [hli] | |
44 | cp $00 | |
45 | ret z | |
46 | call putc | |
47 | jr puts | |
48 | ||
49 | EX_SP_HL: MACRO | |
50 | push de | |
51 | di | |
52 | add sp, 2 | |
53 | pop de | |
54 | push hl | |
55 | ld l, e | |
56 | ld h, d | |
57 | add sp, -2 | |
58 | ei | |
59 | pop de | |
60 | ENDM | |
61 | ||
62 | putsi: | |
63 | pop hl | |
64 | push af | |
65 | push bc | |
66 | push de | |
67 | .lp: ld a, [hli] | |
68 | or a | |
69 | jr z, .done | |
70 | call putc | |
71 | jr .lp | |
72 | .done: pop de | |
73 | pop bc | |
74 | pop af | |
75 | push hl | |
76 | ret | |
77 | ||
78 | puthex: ; Put two hex nibbles to the serial console. | |
79 | push bc | |
80 | push hl | |
81 | push af | |
82 | swap a | |
83 | and $0F | |
84 | ld hl,hex | |
85 | ld b,0 | |
86 | ld c,a | |
87 | add hl,bc | |
88 | ld a, [hl] | |
89 | call putc | |
90 | pop af | |
91 | and $0F | |
92 | ld hl,hex | |
93 | ld c,a | |
94 | add hl,bc | |
95 | ld a, [hl] | |
96 | call putc | |
97 | pop hl | |
98 | pop bc | |
99 | ret | |
100 | hex: db "0123456789ABCDEF" |