Programación Funcional - Ayuda con juego 4 líneas, ensamblador

 
Vista:
sin imagen de perfil
Val: 2
Ha mantenido su posición en Programación Funcional (en relación al último mes)
Gráfica de Programación Funcional

Ayuda con juego 4 líneas, ensamblador

Publicado por Alexander (1 intervención) el 19/12/2019 03:10:47
org 100h

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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
MAIN:
mov byte [Paso],0
mov word [Jug1],0
mov byte [TxtJugador],"1"
xor al,al
mov cx,9
mov di,C1
repne stosb
 
Datos:
call Borrar
mov bx,TxtDatos
call prtext
 
InDatos:
call input
cmp al,"1"
je Principal
cmp al,"2"
je PO
cmp al,"3"
je OP
cmp al,"4"
je OO
cmp al,"5"
je OO2
cmp al,27
je near Salir
jmp InDatos
 
PO:
call InputLevel
mov byte [Jug2],al
jmp Principal
 
OP:
call InputLevel
mov byte [Jug1],al
jmp Principal
 
OO2:
mov byte [Paso],1
OO:
mov al,"1"
call print
mov al,"."
call print
call InputLevel
mov byte [Jug1],al
call prLine
mov al,"2"
call print
mov al,"."
call print
call InputLevel
mov byte [Jug2],al
jmp Principal
 
InputLevel:
mov bx,TxtLevel
call prtext
mov bl,[MinLevel]
mov bh,[MaxLevel]
 
InputLevelB
call input
cmp al,bl
jb InputLevelB
cmp al,bh
jg InputLevelB
call print
ret
 
Principal:
call Borrar
call ImpTablero
call prLine
call JJugador
call Borrar
 
Juego:
call ImpTablero
call prLine
call C3R
 
call CEmpate
call IncJugador
cmp byte [Paso],1
jne NPaso
call input
cmp al,27
je near WaitEsc
NPaso
call JJugador
call prLine
 
call Borrar
jmp Juego
 
JJugador:
mov bx,TxtTecla
call PRTEXT
mov al,[TxtJugador]
sub al,31h
xor ah,ah
mov si,ax
mov al,[Jug1+si]
or al,al
jz near JPersona
 
JOrdenador:
push ax
call prLine
pop ax
cmp al,"1"
je JOrdenador1
cmp al,"2"
je JOrdenador2
cmp al,"3"
je JOrdenador3
cmp al,"4"
je JOrdenador4
 
JOrdenador1:
mov ax,9
call Rnd
mov si,ax
cmp byte [C1+si],0
jnz JOrdenador1
mov al,[TxtJugador]
sub al,30h
mov [C1+si],al
ret
 
JOrdenador2:
call Evitar3
cmp al,9
;mov al,[TxtJugador]
je JOrdenador1
xor ah,ah
mov si,ax
mov al,[TxtJugador]
sub al,30h
mov [C1+si],al
ret
 
JOrdenador3:
call Ganar3
cmp al,9
je JOrdenador2
xor ah,ah
mov si,ax
mov al,[TxtJugador]
sub al,30h
mov [C1+si],al
ret
 
JOrdenador4:
call Ganar3
cmp al,9
je CEvitar
xor ah,ah
mov si,ax
mov al,[TxtJugador]
sub al,30h
mov [C1+si],al
ret
 
CEvitar:
call Evitar3
cmp al,9
je CCentral
xor ah,ah
mov si,ax
mov al,[TxtJugador]
sub al,30h
mov [C1+si],al
ret
 
CCentral:
cmp byte [C5],0
jne CBordes
mov al,[TxtJugador]
sub al,30h
mov [C5],al
mov al,8
call print
ret
 
CBordes:
cmp byte [C1],0
je RBordes
cmp byte [C3],0
je RBordes
cmp byte [C7],0
je RBordes
cmp byte [C9],0
je RBordes
jmp JOrdenador1
 
RBordes:
mov al,4
call Rnd
cmp al,0
je RBordes1
cmp al,1
je RBordes3
cmp al,2
je RBordes7
cmp al,3
je RBordes9
 
RBordes1:
cmp byte [C1],0
jne RBordes
mov al,[TxtJugador]
sub al,30h
mov [C1],al
ret
 
RBordes3:
cmp byte [C3],0
jne RBordes
mov al,[TxtJugador]
sub al,30h
mov [C3],al
ret
 
RBordes7:
cmp byte [C7],0
jne RBordes
mov al,[TxtJugador]
sub al,30h
mov [C7],al
ret
 
RBordes9:
cmp byte [C9],0
jne RBordes
mov al,[TxtJugador]
sub al,30h
mov [C9],al
ret
 
 
Evitar3:
mov al,[TxtJugador]
sub al,30h
add al,1
cmp al,3
jne E1
mov al,1
jmp E1
 
Ganar3:
mov al,[TxtJugador]
sub al,30h
jmp E1
 
E1:
cmp [C1],al
jne E2
 
E12
cmp [C2],al
jne E13
cmp byte [C3],0
je near RC3
 
E13
cmp [C3],al
jne E14
cmp byte [C2],0
je near RC2
 
E14
cmp [C4],al
jne E15
cmp byte [C7],0
je near RC7
 
E15
cmp [C5],al
jne E17
cmp byte [C9],0
je near RC9
 
E17
cmp [C7],al
jne E19
cmp byte [C4],0
je near RC4
 
E19
cmp [C9],al
je E2
cmp byte [C5],0
je near RC5
 
E2:
cmp [C2],al
jne E3
 
E23
cmp [C3],al
jne E25
cmp byte [C1],0
je near RC1
 
E25:
cmp [C5],al
jne E28
cmp byte [C8],0
je near RC8
 
E28
cmp [C8],al
jne E3
cmp byte [C5],0
je near RC5
 
 
E3:
cmp [C3],al
jne E4
 
E35
cmp [C5],al
jne E36
cmp byte [C7],0
je near RC7
 
E36:
cmp [C6],al
jne E37
cmp byte [C9],0
je near RC9
 
E37
cmp [C7],al
jne E39
cmp byte [C5],0
je near RC5
 
E39
cmp [C9],al
jne E4
cmp byte [C6],0
je near RC6
 
 
E4:
cmp [C4],al
jne E5
 
E45
cmp [C5],al
jne E46
cmp byte [C6],0
je near RC6
 
E46:
cmp [C6],al
jne E47
cmp byte [C5],0
je near RC5
 
E47:
cmp [C7],al
jne E5
cmp byte [C1],0
je near RC1
 
 
E5:
cmp [C5],al
jne E6
 
E56
cmp [C6],al
jne E57
cmp byte [C4],0
je near RC4
 
E57:
cmp [C7],al
jne E58
cmp byte [C3],0
je near RC3
 
E58:
cmp [C8],al
jne E59
cmp byte [C2],0
je near RC2
 
E59:
cmp [C9],al
jne E6
cmp byte [C1],0
je near RC1
 
E6:
cmp [C6],al
jne E7
 
E69
cmp [C9],al
jne E7
cmp byte [C3],0
je near RC3
 
E7:
cmp [C7],al
jne E8
 
E78
cmp [C8],al
jne E79
cmp byte [C9],0
je near RC9
 
E79
cmp [C9],al
jne E8
cmp byte [C8],0
je near RC8
 
E8:
cmp [C8],al
jne E9
 
E89
cmp [C9],al
jne E9
cmp byte [C7],0
je near RC7
 
E9:
mov al,9
ret
 
 
RC1:
mov al,0
ret
RC2:
mov al,1
ret
RC3:
mov al,2
ret
RC4:
mov al,3
ret
RC5:
mov al,4
ret
RC6:
mov al,5
ret
RC7:
mov al,6
ret
RC8:
mov al,7
ret
RC9:
mov al,8
ret
 
 
JPersona:
mov al,","
call print
mov al," "
call print
mov bx,TxtMover
call PRTEXT
call InCasilla
call prLine
ret
 
Victoria:
mov bx,TxtVictoria
mov al,[TxtJugador]
mov [TxtVic],al
call prtext
jmp WaitEsc
C3R:
 
C3R1:
;o
; o
; o
mov al,[C1]
or al,al
jz C3R2
cmp al,[C5]
jne C3R2
cmp al,[C9]
jne C3R2
jmp Victoria
 
C3R2:
; o
; o
; o
mov al,[C2]
or al,al
jz C3R3
cmp al,[C5]
jne C3R3
cmp al,[C8]
jne C3R3
jmp Victoria
 
C3R3:
mov al,[C3]
or al,al
jz C3R4
cmp al,[C5]
jne C3R4
cmp al,[C7]
jne C3R4
jmp Victoria
 
C3R4:
mov al,[C4]
or al,al
jz C3R5
cmp al,[C5]
jne C3R5
cmp al,[C6]
jne C3R5
jmp Victoria
 
C3R5:
mov al,[C1]
or al,al
jz C3R6
cmp al,[C2]
jne C3R6
cmp al,[C3]
jne C3R6
jmp Victoria
 
C3R6:
mov al,[C7]
or al,al
jz C3R7
cmp al,[C8]
jne C3R7
cmp al,[C9]
jne C3R7
jmp Victoria
 
C3R7:
mov al,[C1]
or al,al
jz C3R8
cmp al,[C4]
jne C3R8
cmp al,[C7]
jne C3R8
jmp Victoria
 
C3R8:
mov al,[C3]
or al,al
jz C3R9
cmp al,[C6]
jne C3R9
cmp al,[C9]
jne C3R9
jmp Victoria
 
C3R9:
ret
 
CEmpate:
mov cx,0ah
mov di,C1
mov al,0
repne scasb
or cx,cx
jz Empate
ret
 
Empate:
mov bx,TxtEmpate
call PRTEXT
jmp WaitEsc
 
IncJugador:
inc byte [TxtJugador]
jnp Return
sub byte [TxtJugador],2
Return:
ret
 
ImpTablero:
mov bx,C1
mov si,0
mov di,3
call ImpFila
call prLine
mov bx,TxtFil
call prtext
mov bx,C1
mov si,3
mov di,6
call ImpFila
call prLine
mov bx,TxtFil
call prtext
mov bx,C1
mov si,6
mov di,9
call ImpFila
call prLine
ret
 
ImpFila:
mov al,[bx+si]
call ImpCasilla
inc si
cmp si,di
je ImpFilaR
mov al,"|"
call print
jmp ImpFila
ImpFilaR:
ret
 
InCasilla:
call input
cmp al,27
je MAIN
cmp al,30h
jb InCasilla
cmp al,39h
ja InCasilla
xor ah,ah
mov si,ax
sub si,31h
cmp byte [C1+si],0
jnz InCasilla
push ax
mov al,[TxtJugador]
sub al,30h
mov [C1+si],al
pop ax
call print
ret
 
WaitEsc:
call input
cmp al,27
jne WaitEsc
jmp MAIN
 
Salir:
call prLine
jmp 0
 
input:
xor ah,ah
int 16h
ret
 
ImpCasilla:
cmp al,1
je ImpCasillaO
cmp al,2
je ImpCasillaX
mov al,0
call print
ret
 
ImpCasillaO:
mov al,"O"
call print
ret
 
ImpCasillaX
mov al,"X"
call print
ret
 
prLine:
mov al,10
call print
mov al,13
call print
ret
 
print:
push bx
push ax
mov ah,0fh
int 10h
pop ax
mov ah,0eh
int 10h
pop bx
ret
 
PRTEXT:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
MOV SI,0
CALL PCTEXT
POP SI
POP DX
POP CX
POP BX
POP AX
RET
 
PCTEXT:
MOV AL,[ES:BX+SI]
CMP AL,0
JE RETURN
CALL PRINT
INC SI
JMP PCTEXT
 
PRINT:
call print
 
RETURN:
ret
 
prtext:
call PRTEXT
ret
 
Borrar:
push es
mov ax,0b800h
mov es,ax
mov ah,0fh
int 10h
mov ah,2
xor dx,dx
int 10h
mov di,0
mov cx,1000
mov ax,720h
repne stosw
pop es
ret
 
Rnd:
mov bl,al
mov ax,0
int 1ah
in al,70h
and al,128
out 71h,al
in al,71h
mov ax,dx
xor ah,ah
div bl
mov al,ah
xor ah,ah
ret
 
C1 db 0
C2 db 0
C3 db 0
C4 db 0
C5 db 0
C6 db 0
C7 db 0
C8 db 0
C9 db 0
Jug1 db 0
Jug2 db 0
Paso db 0
TxtFil db "-*-*-",10,13,0
TxtTecla db "Turno del jugador "
TxtJugador db "1",0
TxtMover db "Donde desea mover?",0
TxtEmpate db "EMPATE",0
TxtVictoria db "VICTORIA JUGADOR "
TxtVic db 0,10,13,0
TxtDatos db "*** 3N LINE 1.0 ***",10,13,"----------------------",10,13,"ELEGIR TIPO DE JUEGO:",10,13,"1.Persona-Persona",10,13,"2.Persona-Ordenador",10,13,"3.Ordenador-Persona",10,13,"4.Ordenador-Ordenador",10,13,"5.Ordenador-Ordenador (Paso a Paso)",10,13,10,13,"ESC Salir",10,13,0
TxtLevel db "Introducir nivel de dificultad (1-2-3-4)",0
MinLevel db "1"
MaxLevel db "4"
 
times 800h-($-$$) db 0
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder