-
Notifications
You must be signed in to change notification settings - Fork 0
/
nameology.asm
1175 lines (1055 loc) · 19.8 KB
/
nameology.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
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
#有使用chatgpt-4跟claude AI 生成程式跟加註解
#ID: .string "s1111111\n"
strchoise: .string "(Two characters last name + Two characters first name):1 \n(One character last name + Two characters first name):2 \n((Two characters last name + One character first name):3 \n(One character last name + One character first name):4 \n"
str1: .string "Please enter the strokes of the first character of the last name="
str2: .string "Please enter the strokes of the second character of the last name="
str3: .string "Please enter the strokes of the first character of the first name="
str4: .string "Please enter the strokes of the second character of the first name="
str5: .string "Please enter the strokes of the last name="
str6: .string "Please enter the strokes of the first name="
sky_str: .string "Sky"
people_str: .string "People"
land_str: .string "Land"
outside_str: .string "Outside"
total_str: .string "Total"
wood_str: .string " Wood"
water_str: .string " Water"
earth_str: .string " Earth"
fire_str: .string " Fire"
metal_str: .string " Metal"
equal: .string "= "
newline: .string "\n"
peoplegeneratesky: .string "People generate Sky"
peoplerestraintsky: .string "People restraint Sky"
skyequalpeople: .string "Sky equal People"
skygeneratepeople: .string "Sky generate People"
skyrestraintpeople: .string "Sky restraint People"
skyrestraintland:.string "Sky restraint Land"
landgeneratesky:.string "Land generate Sky"
landrestraintsky:.string "Land restraint Sky"
skyequalland: .string "Sky equal Land"
skygenerateland: .string "Sky generate Land"
skyrestraintout: .string "Sky restraint Outside"
outgeneratesky: .string "Outside generate Sky"
outrestraintsky: .string "Outside restraint Sky"
skyequalout: .string "Sky equal Outside"
skygenerateout: .string "Sky generate Outside"
skyrestrainttotal: .string "Sky restraint Total"
skygeneratetotal: .string "Sky generate Total"
totalrestraintsky: .string "Total restraint Total"
totalgeneratesky: .string "Total generate Total"
skyequaltotal: .string "Sky equal Total"
peoplerestraintout: .string "People restraint Outside"
outgeneratepeople: .string "Outside generate People"
outrestraintpeople: .string "Outside restraint People"
peopleequalout: .string "People equal Outside"
peoplegenerateout: .string "People generate Outside"
peoplerestraintland: .string "People restraint Land"
landgeneratepeople: .string "Land generate People"
landrestraintpeople: .string "Land restraint People"
peopleequalland: .string "People equal Land"
peoplegenerateland: .string "People generate Land"
peoplerestrainttotal:.string "People restraint Total"
totalgeneratepeople:.string "Total generate People"
totalrestraintpeople:.string "Total restraint People"
peopleequaltotal:.string "People equal Total"
peoplegeneratetotal:.string "People generate Total"
outgenerateland:.string "Outside generate Land"
outrestraintland:.string "Outside restraint Land"
landequalout:.string "Land equal Outside"
landgenerateout:.string "Land generate Outside"
landrestraintout:.string "Land restraint Outside"
totalrestraintland:.string "Total restraint Land"
totalgenerateland:.string "Total generate Land"
landequaltotal:.string "Land equal Total"
landgeneratetotal:.string "Land generate Total"
landrestrainttotal:.string "Land restraint Total"
outgeneratetotal:.string "Outside generate Total"
totalgenerateout:.string "Total generate Outside"
totalrestraintout:.string "Total restraint Outside"
outequaltotal:.string "Outside equal Total"
outrestrainttotal:.string "Outside restraint Total"
#有使用chatgpt-4跟claude AI 生成程式跟加註解
.text
main:
# Display ID
#la a0, ID
#jal printString
la a0 strchoise
jal printString
jal input
mv s0,a0
li a0,0
j mode_loop
mode_loop:
li t0,1
beq s0,t0, mode1
li t0,2
beq s0,t0, mode2
li t0,3
beq s0,t0, mode3
li t0,4
beq s0,t0, mode4
# If none of the modes are selected, execute default behavior
jal CAL
mode1:
mv t0, ra
la a0, str1
jal printString
jal input
mv s1,a0
la a0, str2
jal printString
jal input
mv s2,a0
la a0, str3
jal printString
jal input
mv s3,a0
la a0, str4
jal printString
jal input
mv s4,a0
add s6,s1,s2
add s6,s6,s3
add s6,s6,s4
mv ra, t0
ret
mode2:
mv t0, ra
li s1 1
la a0, str5
jal printString
jal input
mv s2,a0
la a0, str3
jal printString
jal input
mv s3,a0
la a0, str4
jal printString
jal input
mv s4,a0
add s6,s2,s3
add s6,s6,s4
mv a0,s6
mv ra ,t0
ret
mode3:
mv t0,ra
la a0, str1
jal printString
jal input
mv s1,a0
la a0, str2
jal printString
jal input
mv s2,a0
la a0, str6
jal printString
jal input
mv s3,a0
li s4 1
add s6,s1,s2
add s6,s6,s3
mv ra ,t0
ret
mode4:
mv t0,ra
li s1 1
la a0, str5
jal printString
jal input
mv s2,a0
la a0, str6
jal printString
jal input
mv s3,a0
li s4 1
add s6,s2,s3
mv ra ,t0
ret
printString:
li a7, 4
ecall
ret
printInt:
li a7, 1
ecall
ret
input:
li a7 5
ecall
ret
CAL:
# 打印一個換行
la a0, newline
li a7, 4
ecall
# 打印 "Sky"
la a0, sky_str
jal printString
# 打印 "="
la a0, equal
jal printString
# 計算 s5 = s1 + s2
add s5, s1, s2
# 獲取 s5 的最後一位數字
li t6, 10
rem s7, s5, t6
# 調用 output 函數更新 s7 (s5 的最後一位數字)
mv a0, s7
jal output
mv s7, a0
# 打印 s5 的值
mv a0, s5
jal printInt
# 調用 computeWuXin 函數來確定 s5 對應的五行
jal computeWuXin
mv t1, a1
# 重複上述步驟計算 People、Land、Outside 和 Total
# ...
la a0 people_str
jal printString
la a0 equal
jal printString
li s5 0
add s5,s2,s3
li t6,10
rem s8,s5,t6
mv a0,s8
jal output
mv s8,a0
mv a0 s5
jal printInt
jal computeWuXin
mv t2,a1
la a0 land_str
jal printString
la a0 equal
jal printString
li s5 0
add s5,s3,s4
li t6,10
rem s9,s5,t6
mv a0,s9
jal output
mv s9,a0
mv a0 s5
jal printInt
jal computeWuXin
mv t3,a1
la a0 outside_str
jal printString
la a0 equal
jal printString
li s5 0
add s5,s1,s4
li t6,10
rem s10,s5,t6
mv a0,s10
jal output
mv s10,a0
mv a0 s5
jal printInt
jal computeWuXin
mv t4,a1
la a0 total_str
jal printString
la a0 equal
jal printString
li t6,10
rem s11,s6,t6
mv a0,s11
jal output
mv s11,a0
mv a0,s6
jal printInt
jal computeWuXin
mv t5,a1
# 打印一個換行
la a0, newline
li a7, 4
ecall
# 計算並打印五行之間的生克關係
sub a0, s7, s8
jal sky_to_people
sub a0, s7, s9
jal sky_to_land
sub a0,s7,s10
jal sky_to_out
sub a0,s7,s11
jal sky_to_total
sub a0,s8,s9
jal people_to_land
sub a0,s8,s10
jal people_to_out
sub a0,s8,s11
jal people_to_total
sub a0,s9,s10
jal land_to_out
sub a0,s9,s11
jal land_to_total
sub a0,s10,s11
jal out_to_total
j end
computeWuXin:
li t1 10
rem t0,a0,t1
beq t0, zero, return_water
li t1 1
beq t0, t1, return_wood
li t1 2
beq t0, t1, return_wood
li t1 3
beq t0, t1, return_fire
li t1 4
beq t0, t1, return_fire
li t1 5
beq t0, t1, return_earth
li t1 6
beq t0, t1, return_earth
li t1 7
beq t0, t1, return_metal
li t1 8
beq t0, t1, return_metal
li t1 9
beq t0, t1, return_water
mv ra, t0
ret
return_wood:
la a0 wood_str
li a7, 4
li a1 0
ecall
li a0, '\n'
li a7, 11
ecall
ret
return_fire:
la a0 fire_str
li a7, 4
li a1 1
ecall
li a0, '\n'
li a7, 11
ecall
ret
return_earth:
la a0 earth_str
li a7, 4
li a1 2
ecall
li a0, '\n'
li a7, 11
ecall
ret
return_metal:
la a0 metal_str
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
return_water:
la a0 water_str
li a7, 4
li a1 4
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_to_total:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, out_equal_total
beq a0, a2, total_generate_out
beq a0, a3, total_restraint_out
beq a0, a4, out_restraint_total
beq a0, a5, out_generate_total
beq a0, a6, out_generate_total
beq a0, a7, out_restraint_total
beq a0, t0, total_restraint_out
beq a0, t1, total_generate_out
j end
land_to_total:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, land_equal_total
beq a0, a2, total_generate_land
beq a0, a3, total_restraint_land
beq a0, a4, land_restraint_total
beq a0, a5, land_generate_total
beq a0, a6, land_generate_total
beq a0, a7, land_restraint_total
beq a0, t0, total_restraint_land
beq a0, t1, total_generate_land
j end
land_to_out:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, land_equal_out
beq a0, a2, out_generate_land
beq a0, a3, out_restraint_land
beq a0, a4, land_restraint_out
beq a0, a5, land_generate_out
beq a0, a6, land_generate_out
beq a0, a7, land_restraint_out
beq a0, t0, out_restraint_land
beq a0, t1, out_generate_land
j end
people_to_total:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, people_equal_total
beq a0, a2, total_generate_people
beq a0, a3, total_restraint_people
beq a0, a4, people_restraint_total
beq a0, a5, people_generate_total
beq a0, a6, people_generate_total
beq a0, a7, people_restraint_total
beq a0, t0, total_restraint_people
beq a0, t1, total_generate_people
j end
people_to_out:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, people_equal_out
beq a0, a2, out_generate_people
beq a0, a3, out_restraint_people
beq a0, a4, people_restraint_out
beq a0, a5, people_generate_out
beq a0, a6, people_generate_out
beq a0, a7, people_restraint_out
beq a0, t0, out_restraint_people
beq a0, t1, out_generate_people
j end
people_to_land:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, people_equal_land
beq a0, a2, land_generate_people
beq a0, a3, land_restraint_people
beq a0, a4, people_restraint_land
beq a0, a5, people_generate_land
beq a0, a6, people_generate_land
beq a0, a7, people_restraint_land
beq a0, t0, land_restraint_people
beq a0, t1, land_generate_people
j end
sky_to_total:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, sky_equal_total
beq a0, a2, total_generate_sky
beq a0, a3, total_restraint_sky
beq a0, a4, sky_restraint_total
beq a0, a5, sky_generate_total
beq a0, a6, sky_generate_total
beq a0, a7, sky_restraint_total
beq a0, t0, total_restraint_sky
beq a0, t1, total_generate_sky
j end
sky_to_out:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, sky_equal_out
beq a0, a2, out_generate_sky
beq a0, a3, out_restraint_sky
beq a0, a4, sky_restraint_out
beq a0, a5, sky_generate_out
beq a0, a6, sky_generate_out
beq a0, a7, sky_restraint_out
beq a0, t0, out_restraint_sky
beq a0, t1, out_generate_sky
j end
sky_to_land:
li a1, 0
li a2, 1
li a3, 2
li a4, 3
li a5, 4
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, sky_equal_land
beq a0, a2, land_generate_sky
beq a0, a3, land_restraint_sky
beq a0, a4, sky_restraint_land
beq a0, a5, sky_generate_land
beq a0, a6, sky_generate_land
beq a0, a7, sky_restraint_land
beq a0, t0, land_restraint_sky
beq a0, t1, land_generate_sky
j end
sky_to_people:
li a1, 0 # 將t1設置為1
li a2, 1 # 將t2設置為2
li a3, 2 # 將t3設置為3
li a4, 3 # 將t4設置為4
li a5, 4 # 將t5設置為5
li a6, -1
li a7, -2
li t0, -3
li t1, -4
beq a0, a1, sky_equal_people
beq a0, a2, people_generate_sky
beq a0, a3, people_restraint_sky
beq a0, a4, sky_restraint_people
beq a0, a5, sky_generate_people
beq a0, a6, sky_generate_people
beq a0, a7, sky_restraint_people
beq a0, t0, people_restraint_sky
beq a0, t1, people_generate_sky
j end
out_restraint_total:
la a0 outrestrainttotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_generate_out:
la a0 totalgenerateout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_restraint_out:
la a0 totalrestraintout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_equal_total:
la a0 outequaltotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_generate_total:
la a0 outgeneratetotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_restraint_total:
la a0 landrestrainttotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_generate_land:
la a0 totalgenerateland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_restraint_land:
la a0 totalrestraintland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_equal_total:
la a0 landequaltotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_generate_total:
la a0 landgeneratetotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_restraint_out:
la a0 landrestraintout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_generate_land:
la a0 outgenerateland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_restraint_land:
la a0 outrestraintland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_equal_out:
la a0 landequalout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_generate_out:
la a0 landgenerateout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_restraint_total:
la a0 peoplerestrainttotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_generate_people:
la a0 totalgeneratepeople
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_restraint_people:
la a0 totalrestraintpeople
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_equal_total:
la a0 peopleequaltotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_generate_total:
la a0 peoplegeneratetotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_restraint_out:
la a0 peoplerestraintout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_generate_people:
la a0 outgeneratepeople
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_restraint_people:
la a0 outrestraintpeople
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_equal_out:
la a0 peopleequalout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_generate_out:
la a0 peoplegenerateout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_restraint_land:
la a0 peoplerestraintland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_generate_people:
la a0 landgeneratepeople
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
land_restraint_people:
la a0 landrestraintpeople
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_equal_land:
la a0 peopleequalland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
people_generate_land:
la a0 peoplegenerateland
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
sky_restraint_total:
la a0 skyrestrainttotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_generate_sky:
la a0 totalgeneratesky
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
total_restraint_sky:
la a0 totalrestraintsky
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
sky_equal_total:
la a0 skyequaltotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
sky_generate_total:
la a0 skygeneratetotal
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
sky_restraint_out:
la a0 skyrestraintout
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_generate_sky:
la a0 outgeneratesky
li a7, 4
li a1 3
ecall
li a0, '\n'
li a7, 11
ecall
ret
out_restraint_sky: