-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.asm
More file actions
373 lines (290 loc) · 5.35 KB
/
kernel.asm
File metadata and controls
373 lines (290 loc) · 5.35 KB
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
org 0x8600
jmp 0x0000:start
data:
emptyString times 7 db '------',0
chosenWord times 7 db 'ENIGMA',0
congrats times 14 db 'Uau! Acertou!',0
ncongrats times 17 db 'Tente novamente amanha :(',0
writtenString times 7 db 0
tempoCarregar:
mov bp, 3000
mov dx, 3000
delayTela:
dec bp
nop
jnz delayTela
dec dx
jnz delayTela
ret
readchar:
mov ah, 0x00
int 16h
ret
putchar: ;mov al, char e mov bl, color
mov ah, 09h
mov cx, 0x01
int 10h
inc dl
mov ah, 02h
int 10h
ret
putchar_ast:
mov al, '*'
mov ah, 09h
mov cx, 0x01
int 10h
inc dl
mov ah, 02h
int 10h
ret
delchar:
mov ah, 03h
int 10h
mov ah, 02h
dec dl
int 10h
mov al, '_'
mov bl, 0Fh
call putchar
mov ah, 03h
int 10h
mov ah, 02h
dec dl
int 10h
ret
endl:
; Acha onde o cursor está
mov ah, 03h
int 10h
;Pula a linha
mov ah, 02h
inc dh
int 10h
ret
ret
readString: ; mov di, string
xor cx, cx ; zerar contador
push cx
.loop1:
call readchar
cmp al, 0x08 ; backspace
je .backspace
cmp al, 0x0d ; enter
je .done
pop cx
cmp cl, 6 ; string limit checker
je .limit
cmp al, 'A'
jl .limit ;Se não for uma letra maíuscula
cmp al, 'Z'
jg .limit ;Se não for uma letra maíuscula
stosb
inc cl
push cx
mov bl, 0x0F ;Deixando branco
call putchar
jmp .loop1
.limit:
push cx
jmp .loop1
.backspace:
pop cx
cmp cl, 0 ; is empty?
je .limit
dec di
dec cl
push cx
mov byte[di], 0
call delchar
jmp .loop1
.done:
pop cx
mov al, 0
stosb
ret
lineBegin: ;seta o cursor no começo da linha
; Acha onde o cursor está
mov ah, 03h
int 10h
;Move para o inicio da linha
mov ah, 02h
mov dl, 17
int 10h
ret
startVideo:
mov ah, 00h
mov al, 0Dh
int 10h
mov ah, 02h
mov bh, 01h
mov dl, 17 ;Aqui coloca os "___" do jogo horizontalmente
mov dh, 8 ;Aqui coloca os "___" do jogo verticalmente
int 10h
ret
prints: ; mov si, string
.loop2:
lodsb ; bota character em al
cmp al, 0
je .endloop2
call putchar
jmp .loop2
.endloop2:
ret
checkWord:
mov si, writtenString
xor cx, cx
push cx
.loop3:
lodsb
cmp al, 0
je .endloop3
cmp al, 'E'
je .E
cmp al, 'N'
je .N
cmp al, 'I'
je .I
cmp al, 'G'
je .G
cmp al, 'M'
je .M
cmp al, 'A'
je .A
jmp .notInTheWord
.E:
pop cx
cmp cx, 0
je .right
jmp .wrongPlace
.N:
pop cx
cmp cx, 1
je .right
jmp .wrongPlace
.I:
pop cx
cmp cx, 2
je .right
jmp .wrongPlace
.G:
pop cx
cmp cx, 3
je .right
jmp .wrongPlace
.M:
pop cx
cmp cx, 4
je .right
jmp .wrongPlace
.A:
pop cx
cmp cx, 5
je .right
jmp .wrongPlace
.notInTheWord:
pop cx
inc cx
push cx
mov bl, 0x04 ;Deixando vermelho
call putchar_ast
jmp .loop3
.right:
inc cx
push cx
mov bl, 0x02 ;Deixando verde
call putchar
jmp .loop3
.wrongPlace:
inc cx
push cx
mov bl, 0x0E ;Deixando amarelo
call putchar_ast
jmp .loop3
.endloop3:
pop cx
ret
;ajeitar a condição de parada!
round:
;xor cx, cx
inc cx
push cx
mov si, emptyString
mov bl, 0x0F
call prints
call lineBegin
mov di, writtenString
call readString
call lineBegin
call checkWord
; PCGR PCGR PCGR PCGR -----------------------------------------------------------
lea si, chosenWord
lea di, writtenString
dec di
compare:
inc di ; di -> proximo char da writtenString
lodsb ; carrega al com o proximo char da chosenWord
cmp [di], al
jne NotEqual ;se não for igual sai do loop
cmp al, 0 ;sao os mesmo chars, mas chegou no final da string?
jne compare ;entao vai pro loop novamente
lea dx, congrats ;se chegou aqui, é igual
mov ah, 9 ;printar parabens
int 21h
call end_compare
end_compare:
call tempoCarregar
mov ah, 0
mov al, 13
int 10h
;escolhe a cor da tela
mov ah, 0xb
mov bh, 0
mov bl, 2;cor da tela
int 10h
;texto vc ganhou
mov ah, 02h
mov bh, 00h
mov dh, 11
mov dl, 13
int 10h
mov si, congrats
mov bl, 15 ;cor do nome escrito
call prints
ret
NotEqual:
call endl
call lineBegin
pop cx
cmp cx, 6
jne round
;perdeu o jogo
call tempoCarregar
mov ah, 0
mov al, 13
int 10h
;escolhe a cor da tela
mov ah, 0xb
mov bh, 0
mov bl, 4;cor da tela
int 10h
;texto vc perdeu
mov ah, 02h
mov bh, 00h
mov dh, 11
mov dl, 7
int 10h
mov si, ncongrats
mov bl, 15 ;cor do nome escrito
call prints
ret
; ----------------------------------------------------------------------- PCGR PCGR PCGR -------------------------------------------------
start:
xor ax, ax
xor bx, bx
xor cx, cx
xor dx, dx
mov ds, ax
mov es, ax
call startVideo
call round
jmp $