-
Notifications
You must be signed in to change notification settings - Fork 1
/
_TERM.asm
180 lines (179 loc) · 1.83 KB
/
_TERM.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
;
ORG #8000
;
LD A,2
CALL #1601
DI
LD A,1
OUT (#F7),A
LD A,1
OUT (#F7),A
LD A,#40
OUT (#F7),A
LD A,#4E
OUT (#F7),A
;
MAINLOOP
LD A,#16
OUT (#F7),A
CALL RXBLOCK
CALL PRINTBLOCK
LD A,#33
OUT (#F7),A
CALL READLN
CALL TXBLOCK
JR MAINLOOP
;
RXBLOCK
DI
LD HL,#C000
R1
LD A,#16
OUT (#F7),A
CALL RXBYTE
OR A
JR NZ,R1
R2
LD A,#16
OUT (#F7),A
CALL RXBYTE
OR A
JR Z,R2
JR R3
;
RXBLOCK1
LD A,#16
OUT (#F7),A
CALL RXBYTE
R3
LD (HL),A
INC HL
CP #1A
JR NZ,RXBLOCK1
EI
RET
;
PRINTBLOCK
LD HL,#C000
PRINTBLOCK1
LD A,(HL)
CP #1A
RET Z
CP 13
JR Z,RST
CP 32
JR C,RST2
RST
RST #10
RST2
INC HL
JR PRINTBLOCK1
;
RXBYTE
CALL #1F54
JR NC,BREAK
IN A,(#F7)
AND #38
JR NZ,RXBYTE1
IN A,(#F7)
BIT 1,A
JR Z,RXBYTE
RXBYTE1
IN A,(#77)
RET
BREAK
XOR A
OUT (#F7),A
EI
RST 8
DEFB 13
;
READLN
LD HL,#C000
READLN1
CALL GETKBD
CP #0D
JR Z,READLN_CR
CP #8
JR Z,READLN_BS
CP #20
JR C,READLN1
LD (HL),A
INC HL
RST #10
JR READLN1
READLN_CR
LD (HL),A
INC HL
LD (HL),#1A
JP #10
READLN_BS
LD A,L
OR A
JR NZ,READLN_BS1
LD A,H
CP #C0
JR Z,READLN1
READLN_BS1
DEC HL
LD A,8
RST #10
LD A," "
RST #10
LD A,8
RST #10
JR READLN1
;
TXBLOCK
DI
LD HL,#C000
LD B,16
T1
LD A,#33
OUT (#F7),A
XOR A
CALL TXBYTE
DJNZ T1
;
TXBLOCK1
LD A,#33
OUT (#F7),A
LD A,(HL)
CALL TXBYTE
INC HL
CP #1A
JR NZ,TXBLOCK1
CALL TXBYTE
CALL TXBYTE
CALL TXBYTE
CALL TXBYTE
CALL TXBYTE
CALL TXBYTE
CALL TXBYTE
EI
RET
;
TXBYTE
PUSH AF
TXBYTE1
CALL #1F54
JR NC,BREAK
IN A,(#F7)
BIT 0,A
JR Z,TXBYTE1
POP AF
OUT (#77),A
RET
GETKBD
EI
RES 5,(IY+1)
GETKBD1
BIT 5,(IY+1)
JR Z,GETKBD1
CALL #1F54
JP NC,BREAK
LD A,(IY-50)
RES 5,(IY+1)
RET
;
EOF