-
Notifications
You must be signed in to change notification settings - Fork 1
/
Petnica bios.z8a
executable file
·267 lines (202 loc) · 5.4 KB
/
Petnica bios.z8a
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
;org 256
; 256
test_loop:
call BIOS_scanchar
call nz,put_one
jr test_loop
; test random
put_one:
ld a,64
call BIOS_putchar
ret
; Test progrmm:
;ld de,STR_ver
;call BIOS_printstr
ld hl,STR1
ld bc,STR2
call BIOS_strcmp
ld a,d
cp 1
jr z,_prepoznato
call _ne_prepoznato
_prepoznato:
ld de,STR_newline
call BIOS_printstr
ld de,STR_succParse
call BIOS_printstr
halt
_ne_prepoznato:
ld de,STR_newline
call BIOS_printstr
ld de,STR_errorParse
call BIOS_printstr
halt
loop:
ld de,STR_newline
call BIOS_printstr
ld de,STR_prompt
call BIOS_printstr
call BIOS_getcommand
jr loop
;ld a,2
;ld (2560),a
;ld a,41
;ld (2048),a
;ld a,42
;ld (2064),a
;call BIOS_filesystem_list
halt
; Rutina za ocitavanje jednog karaktera. Ceka se da
; otkucani znak bude na raspolaganju pa se vraca
; u registru A.
; scans for character (key press)
BIOS_scanchar:
in a,(13h)
ret
; input (HL), (BC), output Z, compare two characters
BIOS_charcmp:
ld a,(BC)
cp (HL)
ret
; Compare two strings and put it into D
BIOS_strcmp:
ld d,1
_strcmp_loop:
ld a,(HL)
cp 0
jr z,_strcmp_check_another
ld a,(bc)
cp 0
jr z,_strcmp_check_another_1
call BIOS_charcmp
jr nz,_strcmp_exit
inc hl
inc bc
jr _strcmp_loop
_strcmp_exit:
ld d,0
ret
_strcmp_check_another:
ld a,(bc)
cp 0
jr nz,_strcmp_exit
ret
_strcmp_check_another_1:
ld a,(hl)
cp 0
jr nz,_strcmp_exit
ret
; get character
BIOS_getchar:
_waitgc:
in a,(12h)
bit 1,a
jr z,_waitgc
in a,(13h)
ret
; Rutina za ispisivanje jednog karaktera na terminalu.
; Karakter se srosledjuje kroz registar. Rutina ceka
; terminal da bude spreman za upis.
BIOS_putchar:
push af
_waitpc:
in a,(12h)
bit 2,a
jr z,_waitpc
pop af
out (13h),a
ret
; Rutina za ocitavanja niza karaktera sa tastature
; i smestanje u memoriju. Po pritisku ENTER na kraju
; se upisuje NULL i prekida se citanje
BIOS_getcommand:
push af
push bc
push hl
ld hl,LINE_BUFFER
ld b,64
_cmdloop:
call BIOS_getchar
; Proveri da li je pritisnut enter,
; pa ako jese, zavrsi sa unosom linije.
cp 13
jr z,_exitgc
; Pravilno izvrsavanje backspace
cp 8
jr nz,_gcback
ld a,b
cp 64
jr z,_cmdloop
ld a,8
call BIOS_putchar
ld a,32
call BIOS_putchar
ld a,8
call BIOS_putchar
inc b
dec hl
jr _cmdloop
_gcback:
; Provera da li je unet maksimalni broj
; karaktera, pa ako jeste vrati se na
; ocitavanje bez promene brojaca.
ex af,af'
ld a,b
cp 0
jr z,_cmdloop
; Ako nije ENTER, upisi karakter u memoriju
ex af,af'
ld (hl),a
call BIOS_putchar
inc hl
dec b
jr _cmdloop
_exitgc:
ld (hl),0
pop hl
pop bc
pop af
ret
BASIC_parse_line:
; routine for parsing commands
ld de,STR_newline
call BIOS_printstr
ld de,STR_errorParse
call BIOS_printstr
ld de,STR_newline
call BIOS_printstr
ret
; Rutina za ispis NULL terminisanog stringa.
; Registar DE se koristi kao pocetna adresa
; stringa koji treba ispisati. Po zavrsetku
; de pokazuje na NULL karakter, a ostali
; registri su nepromenjeni
BIOS_printstr:
push af
_seeknull:
ld a,(de)
cp 0
jr z,_exitps
call BIOS_putchar
inc de
jr _seeknull
_exitps:
pop af
ret
STR_prompt:
db "READY>> ",0
STR_newline:
db 13,10,0
STR_succParse:
db "Successful parsing"
STR_errorParse:
db "Error while parsing"
STR_ver:
db "Petnica BIOS v1.0", 13, 10
db "Z80 Emu port, FEB/2014", 13, 10, 13, 10, 0
STR1:
db "aab",0
STR2:
db "aaa",0
LINE_BUFFER:
db 128