-
Notifications
You must be signed in to change notification settings - Fork 0
/
progexamen.s
1360 lines (1304 loc) · 24.1 KB
/
progexamen.s
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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.data
.align 2
jump_table000:
.word B14_4
.word B14_5
.word B14_9
.word B14_15
.word B14_22
.word B14_25
.align 2
pieza1:
.word 3
.word 3
.asciiz " * ****"
.space 1014
item_auxiliar:
.align 2
.space 108
.align 2
main.t1:
.word 5
.word 4
.asciiz "11112222333344445555"
.space 1003
.align 2
main.t2:
.word 5
.word 4
.asciiz "101312a2933a33442456"
.space 1003
.align 2
main.t3:
.word 5
.word 10
.asciiz "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee"
.space 973
.align 2
main.t4:
.word 5
.word 10
.asciiz "aaazzzazaabbbbb33bxbcccxc55cccddddddzz22222zeeeeee"
.space 973
.align 2
main.test:
.word 2369
.word 2021
.word 8712
.word 8510
.word 1060
.word 7543
.word 8849
.word 1504
.word 2533
.word 3045
.word 7228
.word 8911
.word 6856
.word 2825
.word 9510
.word 4352
.word 8870
.word 6191
.word 2500
.word 2856
.align 2
main.t118:
.word 5
.word 9
.asciiz "aaaaaaaaabbbbbbbbbcccccccccdddddddddeeeeeeeee"
.space 978
.align 2
main.t219:
.word 7
.word 8
.asciiz "jfsvnrpotigdsfbkndsvfelkrgoirgfgijdsfgkndffkgjh123456789"
.space 967
.align 2
main.test24:
.asciiz "abc"
.space 96
.word 3
.word 5
.asciiz "def"
.space 96
.word 8
.word 2
.asciiz "ghi"
.space 96
.word 3
.word 1
.asciiz "jkl"
.space 96
.word 0
.word 3
.asciiz "mnñ"
.space 95
.word 0
.word 2
str000:
.asciiz "+"
str001:
.asciiz "-"
str002:
.asciiz "+\n"
str003:
.asciiz "|"
str004:
.asciiz "|\n"
str005:
.asciiz "\n\nExamen de ETC de ensamblador\n\n 1. Simular juego de la vida (prueba contar_vecinos)\n 2. Comparar tableros\n 3. Clasificar números\n 4. Eliminar caracteres de tableros\n 5. Ordenar\n 0. Salir\n\nElige una opción: "
str006:
.asciiz "\n\n"
str007:
.asciiz "Iteración "
str008:
.asciiz ":\n"
str009:
.asciiz "\n Pulsa «X» para salir, o cualquier otra para pasar a la siguiente iteración. "
str010:
.asciiz "Comparando:\n"
str011:
.asciiz "y:\n"
str012:
.asciiz "Resultado:\n"
str013:
.asciiz "Los tableros no son del mismo tamaño, por lo que no se pueden comparar celda a celda.\n"
str014:
.asciiz "\nPulse una tecla para otra prueba.\n"
str015:
.asciiz "Clasificando: "
str016:
.asciiz "\nPares: "
str017:
.asciiz "\nImpares: "
str018:
.asciiz "abde"
str019:
.asciiz "jgf"
str020:
.asciiz "Eliminado «"
str021:
.asciiz "» de:\n"
str022:
.asciiz "Lista sin ordenar:\n"
str023:
.asciiz "\nLista ordenada:\n"
str024:
.asciiz "¡Adiós!\n"
str025:
.asciiz "Opción incorrecta. Pulse cualquier tecla para seguir.\n"
.text
tablero_celda_addr:
lw $t1, 4($a0)
mul $t1, $t1, $a1
addu $t1, $t1, $a2
addu $t1, $a0, $t1
addiu $v0, $t1, 8
jr $ra
tablero_set_celda:
addiu $sp, $sp, -24
sw $ra, 20($sp)
sw $s0, 16($sp)
move $s0, $a3
jal tablero_celda_addr
sb $s0, 0($v0)
lw $s0, 16($sp)
lw $ra, 20($sp)
addiu $sp, $sp, 24
jr $ra
tablero_get_celda:
addiu $sp, $sp, -24
sw $ra, 20($sp)
jal tablero_celda_addr
lb $v0, 0($v0)
lw $ra, 20($sp)
addiu $sp, $sp, 24
jr $ra
tablero_init:
addiu $sp, $sp, -32
sw $ra, 28($sp)
sw $s2, 24($sp)
sw $s1, 20($sp)
sw $s0, 16($sp)
move $s0, $a0
sw $a1, 0($s0)
sw $a2, 4($s0)
lw $t1, 0($s0)
beqz $t1, B3_6
li $s1, 0
j B3_3
B3_2: lw $a2, 4($s0)
B3_3: li $s2, 0
beqz $a2, B3_5
B3_4: move $a0, $s0
move $a1, $s1
move $a2, $s2
li $a3, 32
jal tablero_set_celda
addiu $s2, $s2, 1
lw $t1, 4($s0)
sltu $t1, $s2, $t1
bnez $t1, B3_4
B3_5: lw $t1, 0($s0)
addiu $s1, $s1, 1
sltu $t1, $s1, $t1
bnez $t1, B3_2
B3_6: lw $s0, 16($sp)
lw $s1, 20($sp)
lw $s2, 24($sp)
lw $ra, 28($sp)
addiu $sp, $sp, 32
jr $ra
tablero_copy:
addiu $sp, $sp, -40
sw $ra, 36($sp)
sw $s3, 32($sp)
sw $s2, 28($sp)
sw $s1, 24($sp)
sw $s0, 20($sp)
move $s0, $a1
move $s1, $a0
lw $t1, 0($s0)
sw $t1, 0($s1)
lw $t1, 4($s0)
sw $t1, 4($s1)
lw $t1, 0($s0)
beqz $t1, B4_5
li $s2, 0
B4_2: lw $t1, 4($s0)
li $s3, 0
beqz $t1, B4_4
B4_3: move $a0, $s0
move $a1, $s2
move $a2, $s3
jal tablero_get_celda
move $a0, $s1
move $a1, $s2
move $a2, $s3
move $a3, $v0
jal tablero_set_celda
addiu $s3, $s3, 1
lw $t1, 4($s0)
sltu $t1, $s3, $t1
bnez $t1, B4_3
B4_4: lw $t1, 0($s0)
addiu $s2, $s2, 1
sltu $t1, $s2, $t1
bnez $t1, B4_2
B4_5: lw $s0, 20($sp)
lw $s1, 24($sp)
lw $s2, 28($sp)
lw $s3, 32($sp)
lw $ra, 36($sp)
addiu $sp, $sp, 40
jr $ra
tablero_print:
addiu $sp, $sp, -40
sw $ra, 36($sp)
sw $s4, 32($sp)
sw $s3, 28($sp)
sw $s2, 24($sp)
sw $s1, 20($sp)
sw $s0, 16($sp)
move $s0, $a0
la $a0, str000
jal print_string
lw $t1, 4($s0)
beqz $t1, B5_3
li $s2, 0
la $s1, str001
B5_2: move $a0, $s1
jal print_string
addiu $s2, $s2, 1
lw $t1, 4($s0)
sltu $t1, $s2, $t1
bnez $t1, B5_2
B5_3: la $a0, str002
jal print_string
lw $t1, 0($s0)
beqz $t1, B5_8
li $s1, 0
la $s2, str003
la $s3, str004
B5_5: move $a0, $s2
jal print_string
lw $t1, 4($s0)
li $s4, 0
beqz $t1, B5_7
B5_6: move $a0, $s0
move $a1, $s1
move $a2, $s4
jal tablero_get_celda
sll $t1, $v0, 24
sra $a0, $t1, 24
jal print_character
addiu $s4, $s4, 1
lw $t1, 4($s0)
sltu $t1, $s4, $t1
bnez $t1, B5_6
B5_7: move $a0, $s3
jal print_string
addiu $s1, $s1, 1
lw $t1, 0($s0)
sltu $t1, $s1, $t1
bnez $t1, B5_5
B5_8: la $a0, str000
jal print_string
lw $t1, 4($s0)
beqz $t1, B5_11
li $s2, 0
la $s1, str001
B5_10: move $a0, $s1
jal print_string
addiu $s2, $s2, 1
lw $t1, 4($s0)
sltu $t1, $s2, $t1
bnez $t1, B5_10
B5_11: la $a0, str002
jal print_string
lw $s0, 16($sp)
lw $s1, 20($sp)
lw $s2, 24($sp)
lw $s3, 28($sp)
lw $s4, 32($sp)
lw $ra, 36($sp)
addiu $sp, $sp, 40
jr $ra
tablero_colocar_pieza:
addiu $sp, $sp, -48
sw $ra, 44($sp)
sw $s6, 40($sp)
sw $s5, 36($sp)
sw $s4, 32($sp)
sw $s3, 28($sp)
sw $s2, 24($sp)
sw $s1, 20($sp)
sw $s0, 16($sp)
move $s0, $a3
move $s1, $a2
move $s2, $a1
lw $t1, 0($s0)
move $s3, $a0
beqz $t1, B6_6
li $s4, 0
B6_2: lw $t1, 4($s0)
beqz $t1, B6_5
addu $s5, $s4, $s2
li $s6, 0
B6_4: move $a0, $s0
move $a1, $s4
move $a2, $s6
jal tablero_get_celda
addu $a2, $s1, $s6
move $a0, $s3
move $a1, $s5
move $a3, $v0
jal tablero_set_celda
addiu $s6, $s6, 1
lw $t1, 4($s0)
sltu $t1, $s6, $t1
bnez $t1, B6_4
B6_5: lw $t1, 0($s0)
addiu $s4, $s4, 1
sltu $t1, $s4, $t1
bnez $t1, B6_2
B6_6: lw $s0, 16($sp)
lw $s1, 20($sp)
lw $s2, 24($sp)
lw $s3, 28($sp)
lw $s4, 32($sp)
lw $s5, 36($sp)
lw $s6, 40($sp)
lw $ra, 44($sp)
addiu $sp, $sp, 48
jr $ra
# Devuelve el número de celdas alrededor de la indicada cuyo
# contenido no es el carácter espacio.
# int contar_vecinos(Tablero* tablero, int fila, int columna);
contar_vecinos:
addiu $sp,$sp,-28
sw $ra,0($sp)
sw $s0,4($sp)
sw $s1,8($sp)
sw $s2,12($sp)
sw $s3,16($sp)
sw $s4,20($sp)
sw $s5,24($sp)
move $s0,$a0 #tablero
move $s1,$a1 #fila
move $s2,$a2 #columnas
li $s3,0 #n
li $s4,-1 #i=-1
cv_fori:
bgt $s4,1,cv_finfori
li $s5,-1 #j=-1
cv_forj:
bgt $s5,1,cv_finforj #j<=1
bnez $s4,cv_if1 #i != 0
bnez $s5,cv_if1 #j != 0
j cv_finif1
cv_if1:
add $a1, $s1,$s4 #fila + i
lw $t0, 0($s0) #leyendo tablero -> filas
add $a1,$a1,$t0 #filas + i + tablero -> filas
rem $a1,$a1,$t0 #la suma que tenemos % tablero -> filas
add $a2,$s2,$s5
lw $t0, 4($s0) #leyendo tablero -> columnas
add $a2,$a2,$t0 #columnas + j + tablero -> columnas
rem $a2,$a2,$t0 #la suma que tenemos % tablero -> columnas
move $a0,$s0
jal tablero_get_celda
beq $v0, ' ',cv_finif2 #tablero_get_celda(tablero, f, c) != ' '
addiu $s3,$s3,1 #n++
cv_finif2:
cv_finif1:
addiu $s5,$s5,1 #j++
j cv_forj
cv_finforj:
add $s4,$s4,1 #i++
j cv_fori
cv_finfori:
move $v0,$s3
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp)
lw $s3,16($sp)
lw $s4,20($sp)
lw $s5,24($sp)
addiu $sp,$sp,28
jr $ra
# Simula una iteración del Juego de la Vida de Conway
simular_vida:
addiu $sp, $sp, -1080
sw $ra, 1076($sp)
sw $s5, 1072($sp)
sw $s4, 1068($sp)
sw $s3, 1064($sp)
sw $s2, 1060($sp)
sw $s1, 1056($sp)
sw $s0, 1052($sp)
move $s0, $a0
addiu $a0, $sp, 16
move $a1, $s0
jal tablero_copy
lw $t1, 0($s0)
beqz $t1, B8_10
li $s1, 0
addiu $s2, $sp, 16
li $s4, 2
li $s5, 3
B8_2: lw $t1, 4($s0)
li $s3, 0
beqz $t1, B8_9
B8_3: move $a0, $s2
move $a1, $s1
move $a2, $s3
jal contar_vecinos
bne $v0, $s4, B8_5
move $a0, $s2
move $a1, $s1
move $a2, $s3
jal tablero_get_celda
move $a0, $s0
move $a1, $s1
move $a2, $s3
move $a3, $v0
j B8_8
B8_5: bne $v0, $s5, B8_7
move $a0, $s0
move $a1, $s1
move $a2, $s3
li $a3, 42
j B8_8
B8_7: move $a0, $s0
move $a1, $s1
move $a2, $s3
li $a3, 32
B8_8: jal tablero_set_celda
lw $t1, 4($s0)
addiu $s3, $s3, 1
sltu $t1, $s3, $t1
bnez $t1, B8_3
B8_9: lw $t1, 0($s0)
addiu $s1, $s1, 1
sltu $t1, $s1, $t1
bnez $t1, B8_2
B8_10: lw $s0, 1052($sp)
lw $s1, 1056($sp)
lw $s2, 1060($sp)
lw $s3, 1064($sp)
lw $s4, 1068($sp)
lw $s5, 1072($sp)
lw $ra, 1076($sp)
addiu $sp, $sp, 1080
jr $ra
# Comprueba si los tableros a y b on del mismo tamaño. Si lo son,
# devuelve true, inicializa el tablero resultado y almacena en cada
# celda del mismo un caracter '<', '>' o '=' representando el
# resultado de la comparación de las celdas respectivas de los
# tableros a y b. Devuelve false en otro caso.
# bool comparar_tableros_celda_a_celda(Tablero* resultado, Tablero* a, Tablero* b);
comparar_tableros_celda_a_celda:
addiu $sp,$sp,-32
sw $ra,0($sp)
sw $s0,4($sp)
sw $s1,8($sp)
sw $s2,12($sp)
sw $s3,16($sp)
sw $s4,20($sp)
sw $s5,24($sp)
sw $s6,28($sp)
move $s0, $a0 # $s0 = resultado
move $s1, $a1 # $s1 = a
move $s2, $a2 # $s2 = b
lw $t0, 0($a1) #leo de a->filas
lw $t1, 0($a2) #leo de b->filas
ct_if1:
beq $t0, $t1, ct_if2 #a->filas != b->filas
li $v0,0
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp)
lw $s3,16($sp)
lw $s4,20($sp)
lw $s5,24($sp)
lw $s6,28($sp)
addiu $sp,$sp,32
jr $ra
ct_if2:
lw $t2, 4($a1) # leo de a -> columnas
lw $t3, 4($a2) # leo de b -> columnas
beq $t2,$t3,ct_else1
li $v0,0
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp)
lw $s3,16($sp)
lw $s4,20($sp)
lw $s5,24($sp)
lw $s6,28($sp)
addiu $sp,$sp,32
jr $ra
ct_else1:
move $a0,$s0
#lw $a1,0($t0)
move $a1,$t0
move $a2,$t2
jal tablero_init
li $s3, 0 # f = 0
ct_for:
lw $t0,0($s1) #leemos de nuevo las filas
bge $s3,$t0,ct_finfor1
li $s4,0 # c = 0
ct_for1:
lw $t1,4($s1) #leemos de nuevo las columnas
bge $s4,$t1,ct_finfor2
move $a0, $s1
move $a1,$s3
move $a2,$s4
jal tablero_get_celda
move $s5, $v0
move $a0, $s2
move $a1,$s3
move $a2,$s4
jal tablero_get_celda
move $s6, $v0
ct_ifmenos:
bge $s5,$s6,ct_ifmas
move $a0,$s0
move $a1,$s3
move $a2,$s4
li $a3,'<'
jal tablero_set_celda
addiu $s4,$s4,1
j ct_for1
ct_ifmas:
ble $s5,$s6,ct_else2
move $a0,$s0
move $a1,$s3
move $a2,$s4
li $a3,'>'
jal tablero_set_celda
addiu $s4,$s4,1
j ct_for1
ct_else2:
move $a0,$s0
move $a1,$s3
move $a2,$s4
li $a3,'='
jal tablero_set_celda
addiu $s4,$s4,1
j ct_for1
ct_finfor2:
addiu $s3,$s3,1 #f++
j ct_for
ct_finfor1:
li $v0, 1
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp)
lw $s3,16($sp)
lw $s4,20($sp)
lw $s5,24($sp)
lw $s6,28($sp)
addiu $sp,$sp,32
jr $ra
# Clasifica los números de array entrada (de longitud n_elementos) en
# pares e impares, almacenandolos respectivamente en los arrays pares
# e impares. Devuelve el número de elementos almacenados en el array
# pares (el número de elementos almacenados en el array impares será
# lo que falte hasta n_elementos).
# int clasificar_numeros(int* entrada, int n_elementos, int* pares, int* impares);
clasificar_numeros:
move $t0,$a1
li $t6,0 #n_pares
li $t7,0 #n_impares
li $t8,0 # i
cn_for1:
bge $t8,$t0,cn_fin_for
mul $t1, $t8, 4
add $t2, $a0, $t1 #calcular la direccion de ese elemento entrada[i]
lw $t2,0($t2)
rem $t3,$t2,2
bnez $t3,cn_else
mul $t4,$t6,4
add $t5,$a2,$t4
sw $t2,0($t5)
addiu $t6,$t6,1
j cn_fin_if
cn_else:
mul $t4,$t7,4
add $t5,$a3,$t4
sw $t2,0($t5)
addiu $t7,$t7,1
cn_fin_if:
addiu $t8, $t8, 1
j cn_for1
cn_fin_for:
move $v0,$t6
jr $ra
# Elimina del tablero los caracteres presentes en el array elimina, de
# tamaño n_eliminar
# void eliminar_caracteres(Tablero* tablero, char* eliminar, int n_eliminar);
eliminar_caracteres:
addiu $sp,$sp,-32
sw $ra,0($sp)
sw $s0,4($sp)
sw $s1,8($sp)
sw $s2,12($sp)
sw $s3,16($sp)
sw $s4,20($sp)
sw $s5,24($sp)
sw $s6,28($sp)
move $s0, $a0 #tablero
move $s1, $a1 #eliminar
move $s2, $a2 #n-eliminar
li $s3, 0 #f
lw $t0, 0($s0)
ec_for1:
bge $s3, $s0, ec_finfor
li $s4, 0 #c
lw $t0, 4($s0)
ec_for2:
bge $s4, $t0, ec_finfor2
move $a1, $s3
move $a2, $s4
jal tablero_get_celda
move $s5, $v0 #celda
li $s6, 0 #i
ec_for3:
bge $s6, $s2, ec_finfor3
mul $t1, $s1, 1
add $t0, $t0, $t1
bne $s5, $t0, ec_finfor3
move $a0, $s0
move $a1, $s3
move $a2, $s4
li $a3, ' '
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp)
lw $s3,16($sp)
lw $s4,20($sp)
lw $s5,24($sp)
lw $s6,28($sp)
addiu $sp,$sp,32
jr $ra
ec_finfor3:
addiu $s4, $s4, 1
j ec_for2
ec_finfor2:
addiu $s3, $s3, 1
j ec_for1
ec_finfor:
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp)
lw $s3,16($sp)
lw $s4,20($sp)
lw $s5,24($sp)
lw $s6,28($sp)
addiu $sp,$sp,32
jr $ra
item_menor_que:
lw $v0, 100($a1)
lw $v1, 100($a0)
bne $v1, $v0, B12_2
lw $t1, 104($a1)
lw $v0, 104($a0)
slt $v0, $v0, $t1
jr $ra
B12_2: slt $v0, $v1, $v0
jr $ra
# Ordena los elementos del array, de tamaño n_items
# void ordenar_items(Item* array, int n_items);
ordenar_items:
addiu $sp, $sp, -8
sw $s1, 4($sp)
sw $s0, 0($sp)
move $s0, $a0 # array
move $s1, $a1 # n_items
li $at, 0 # it
li $s5, 108 # sizeof(Item)
B13_2: bge $at, $s1, B13_7
beqz $at, B13_3
mul $t3, $at, $s5
addu $a0, $s0, $t3
subu $a1, $a0, $s5
jal item_menor_que
bnez $v0, B13_4
B13_3: addiu $at, $at, 1
j B13_2
B13_4: la $a0, item_auxiliar
addu $a1, $s0, $s3
li $a2, 108
jal memcpy
addu $a0, $s0, $t3
subu $a1, $a0, $s5
li $a2, 108
jal memcpy
addu $a0, $s0, $t3
subu $a0, $a0, $s5
la $a1, item_auxiliar
li $a2, 108
j memcpy
addiu $at, $at, -1
j B13_2
B13_7: lw $s1, 0($sp)
lw $s0, 4($sp)
addiu $sp, $sp, 8
jr $ra
.globl main
main:
addiu $sp, $sp, -9112
sw $ra, 9108($sp)
sw $fp, 9104($sp)
sw $s7, 9100($sp)
sw $s6, 9096($sp)
sw $s5, 9092($sp)
sw $s4, 9088($sp)
sw $s3, 9084($sp)
sw $s2, 9080($sp)
sw $s1, 9076($sp)
sw $s0, 9072($sp)
move $fp, $sp
addiu $sp, $sp, -16
jal clear_screen
addiu $sp, $sp, 16
la $t1, str005
sw $t1, 96($fp)
la $t1, str006
sw $t1, 92($fp)
la $t1, str025
sw $t1, 88($fp)
la $t1, str024
sw $t1, 84($fp)
addiu $s4, $fp, 8040
la $t1, pieza1
sw $t1, 80($fp)
la $s6, str007
sw $s6, 76($fp)
la $t1, str008
sw $t1, 132($fp)
la $t1, str009
sw $t1, 128($fp)
la $t1, main.t1
sw $t1, 72($fp)
addiu $t1, $fp, 7008
sw $t1, 68($fp)
la $t1, main.t2
sw $t1, 64($fp)
addiu $t1, $fp, 5976
sw $t1, 60($fp)
la $t1, main.t3
sw $t1, 56($fp)
addiu $s7, $fp, 4944
la $t1, main.t4
sw $t1, 52($fp)
addiu $s0, $fp, 3912
la $t1, str010
sw $t1, 124($fp)
la $t1, str011
sw $t1, 120($fp)
la $t1, str012
sw $t1, 116($fp)
la $t1, str014
sw $t1, 112($fp)
la $t1, str013
sw $t1, 108($fp)
la $t1, main.test
sw $t1, 48($fp)
la $t1, str015
sw $t1, 44($fp)
la $t1, str016
sw $t1, 40($fp)
la $t1, str017
sw $t1, 36($fp)
la $t1, main.t118
sw $t1, 32($fp)
la $t1, main.t219
sw $t1, 28($fp)
la $v0, str019
sw $v0, 24($fp)
la $t1, str018
sw $t1, 20($fp)
la $t1, str020
sw $t1, 104($fp)
la $t1, str021
sw $t1, 100($fp)
la $t1, main.test24
sw $t1, 16($fp)
la $t1, str022
sw $t1, 12($fp)
la $t1, str023
sw $t1, 8($fp)
j B14_2
B14_1: addiu $sp, $sp, -16
lw $a0, 88($fp)
jal print_string
addiu $sp, $sp, 16
addiu $sp, $sp, -16
jal read_character
addiu $sp, $sp, 16
B14_2: addiu $sp, $sp, -16
lw $a0, 96($fp)
jal print_string
addiu $sp, $sp, 16
addiu $sp, $sp, -16
jal read_character
addiu $sp, $sp, 16
move $s1, $v0
addiu $sp, $sp, -16
lw $a0, 92($fp)
jal print_string
sll $t1, $s1, 24
sra $t1, $t1, 24
addiu $v0, $t1, -48
li $t1, 5
sltu $t1, $t1, $v0
addiu $sp, $sp, 16
bnez $t1, B14_1
sll $t1, $v0, 2
lw $t1, jump_table000($t1)
jr $t1
B14_4: addiu $sp, $sp, -16
lw $a0, 84($fp)
jal print_string
addiu $sp, $sp, 16
addiu $sp, $sp, -16
li $a0, 0
jal mips_exit
addiu $sp, $sp, 16
j B14_2
B14_5: addiu $sp, $sp, -16
move $a0, $s4
li $a1, 10
li $a2, 30
jal tablero_init
addiu $sp, $sp, 16
addiu $sp, $sp, -16
move $a0, $s4
li $a1, 2
li $a2, 4
lw $a3, 80($fp)
jal tablero_colocar_pieza
addiu $sp, $sp, 16
li $s2, 0
j B14_7
B14_6: addiu $sp, $sp, -16
move $a0, $s4
jal simular_vida
addiu $sp, $sp, 16
addiu $s2, $s2, 1
B14_7: addiu $sp, $sp, -16
jal clear_screen
addiu $sp, $sp, 16
addiu $sp, $sp, -16
move $a0, $s6
jal print_string
addiu $sp, $sp, 16
addiu $sp, $sp, -16
move $a0, $s2
jal print_integer
addiu $sp, $sp, 16
addiu $sp, $sp, -16
lw $a0, 132($fp)
jal print_string
addiu $sp, $sp, 16
addiu $sp, $sp, -16
move $a0, $s4
jal tablero_print
addiu $sp, $sp, 16
addiu $sp, $sp, -16
lw $a0, 128($fp)
jal print_string
addiu $sp, $sp, 16
addiu $sp, $sp, -16
jal read_character
sll $t1, $v0, 24
sra $t1, $t1, 24
ori $t1, $t1, 32
li $v0, 120
addiu $sp, $sp, 16
beq $t1, $v0, B14_2
j B14_6
B14_9: addiu $sp, $sp, -16
lw $s2, 68($fp)
move $a0, $s2
lw $a1, 72($fp)
li $a2, 1032
jal memcpy
addiu $sp, $sp, 16
addiu $sp, $sp, -16
lw $s5, 60($fp)
move $a0, $s5
lw $a1, 64($fp)
li $a2, 1032
jal memcpy
addiu $sp, $sp, 16
addiu $sp, $sp, -16
move $a0, $s7
lw $a1, 56($fp)
li $a2, 1032
jal memcpy
addiu $sp, $sp, 16
addiu $sp, $sp, -16
move $a0, $s0