blob: d894e9701fe1fc976fda7bb1ae71a8ad294198ad (
plain)
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
|
;;;;;;;;
;;; implements an in-place exchange sort on arr.
.data
arr -1362730308 -872277507 -428207790 -941553397 -1598094038 1974624033 -1023445566 -2080082285 -923134851 -1566240461 -1015340602 -1840967109 -1320204443 -1255079578 -886379600 -1573834452 2039974821 1330348037 1608315931 -1295186270 131044420 -1433812756 -922234346 1598417089 735427708 635903155 1569604371 -562127942 -924744759 698462480 -1884861317 -563050478 -345537893 -1085501738 -435655749 -1124847962 2145012083 -1170900749 161470395 -2111474271 1503126015 196966013 -2062067967 1740464917 -269353906 -1897933998 1261942063 1059929304 1067855519 -250523970 241872895 1281389764 1852161461 -1560128834 1786124392 -637257380 -843034909 1150435871 2081601518 1542146259 1327726019 -1858807612 -140499217 -1137051775 -1068052074 -1678857264 -1071753505 199320895 -690155418 -287121940 -870957689 339456407 2002330132 21075212 -2016551521 15520446 -1134383159 -1780761451 1490972082 2115158665 -1078584313 297773402 561760825 738409507 655500270 -332947946 1366792327 112835948 -1273819073 1021096789 -1774784117 -947010402 2115283666 1717202093 1452135996 -54487080 1717651857 1522369941 -893887752 439187044 -406323467 -1273927863 -1329133016 -202298058 103069212 -1915503516 1252841801 728074832 1142337457 1334108268 -726745964 1441905653 1588542745 444296900 -2013981738 -1814505881 -469411089 -2130475878 108443485 729903658 1791457223 926764161 -129386873 1584131511 -1345425721 1688948848 -1699574300 651080752 -925568864 104040896 730061899 385751087 -755456646 -1693738409 204442842 1524821403 2037647773 1030060963 506136369 -571563033 348426459 581320901 -188232889 -1768171104 -1697729180 1715238 1514252729 743825527 -449657448 510478883 -1877844199 461474387 -1964433907 1889809122 -1675157910 1959882863 -2067802134 2051637044 -2100900259 2118136708 -600236722 136189407 1523070943 -1965302836 2110878765 1786328911 733175046 239948065 1152594322 1060992913 995611456 -298589267 1436761773 30569959 -715760388 98687682 -1343464390 -1681595823 -1050409673 -1818081506 1209228343 788014959 600262365 1097041129 1918996745 -151023184 429761410 1405733069 111990530 -1616782425 2079744796 1583595563 1051032661 1308306658 -1408566876 1249731067 -1622063679 -2029893039 -1722929645 1167107851 1889261879 -1572785381 -7391814 -78172020 -881887606 -910103844 -606016475 1138136825 -1874892885 -1835927850 1716661051 1100442090 -46152451 474684878 -847793729 -1753081840 165477382 -451325316 -492853177 -1474352226 -1648522737 1737879668 -2038487379 -233660944 -1939546861 -1750845390 178574641 -1526857389 1153291572 912019707 -992762823 -1056947826 -1294342273 -1180455072 -86503967 -1042241441 645842003 -11328727 -1332024322 1505009408 -1981585867 -619472311 146412895 1025960881 2093148272 1889679929 481800688 -1140929631 167278957 1776297035 -1397313988 1807631337 -336235580 -1973628694 1293639653 1529446773 -1847587086 -1610949391 -1644606709 -907527462 -743628618 529270662 1741437443 -1952098999 -1750240540 938846222 -834665869 -1368046301 224040467 1815385197 533500010 -536267157 1876776622 -1853275279 -71543747 810664644 -1789264715 1711706602 1936047920 -1429367902 1130196476 -179957335 613333150 -1149960419 956302520 1581237860 890276900 1188399414 333753266 248210421 332459606 -75050909 1097408976 -1259137452 2112290562 -657314840 563767443 331032662 -984535423 1140929189 846283349 323970621 -378317659 169025930 2093532898 1627630326 -747624330 -7410463 -1625085325 1452816434 852045011 -1333216692 1854830091 1461923345 426210607 1516266791 1318699158 1940219664 -1556159770 -655573511 -950528326 -840637295 -1603109235 1969543451 1593269452 -893203116 896667458 -1487471364 -1834420670 -1140959014 -1574875917 311037812 2071076127 -549236127 -436903364 -1002829447 -525785893 -834424824 -2017596693 1141790060 -1509251112 1183074275 1781215690 788801204 607572507 -1453121006 -392623629 587405476 -253971868 -31009803 391225684 -1799617321 -559349627 1219920638 254705470 -1954819038 1378535841 2072745444 325612157 -438561307 711611713 946755951 1540986741 247828908 -1362069852 1744310823 -128881800 1694816287 -2080983202 552088317 -1486684042 594856162 -152315027 1137451186 1856386339 1370411469 -326752521 271489903 -2075833719 1686247832 1641108834 -1291090669 1108557247 1675028092 -202746051 1334464014 -972360106 1070341653 -1872774591 2079357384 372404484 213640718 -1879543649 -214794970 944232427 -938285649 689788589 -1792238966 1821919351 -654271060 1862717399 -670653248 -1196164932 -1347322166 -1606798991 2071575624 1340347640 2084746766 -87384856 597770903 1053726827 -1057930655 1243115189 705074932 -907568688 545785490 624322701 -783788734 1894042169 1896969343 -1990144617 -1848687938 -530927554 1862455751 185500285 -1636203527 -379228991 792054617 -2029632336 1328212106 1030361884 -2123610883 -1190897350 1376001236 -1893066070 1790913847 -1453691950 -1232779594 -24352156 243106065 -395635710 168659855 93188709 -1389466954 564417586 1654830267 1353911285 1729604989 -1161244206 -1278888836 1669376941 42811658 458669139 -396258009 1224429504 884224969 -616317942 2109686352 721506797 -974536309 -767262154 -2054917408 1328176486 1034469095 -154001770 2095872925 -1651693507 -1558269942 -1795470686 1885578862 375342326 826670162 148525452 -1926386883 -1618870407 -263477780 -246800209 13999380 -1933456001 145678701 -2009684684 963722667 -1584839768 -410346509 522505873 -192695979 1421908367 -85849345 2132771702 -1278676573 -1746405443 1967220995 1571109807 511558372 -302770207 1329541601 1471450783 -1428226637 -1961974532 2095648123 1765173476 -2060976853 -1987441225 463763590 -1205792891 535752923 -159999436 -1097041462 1352060453 -1723451594 1575319249 752585619 1675929952 -1323250632 255616556 2078649523 -985873658 -241200362 -700576061 1731136551 -15226171 -2031522472 -1792733497 -850438762 -936938859 -1893900957 -1795141775 244967024 -685356731 -1047586984 -1633665492 -1651440102 35196544 -402398034 -19430462 -900399140 -1321238862 924691092 -1255324820 1236740122 -2130338936 -1107552561 -1566538632 -5540093 555345656 696940744 1937114922 -1926281392 1202038325 -897266030 -1072703886 1671211593 2020038018 -181090782 1125200315 -1526457511 -1571332166 -1635319906 -869032182 -2030523908 -286745820 1989055081 2093038421 1764053017 300340659 2014930705 208640730 1575823896 -1193154479 -1105884939 -1040981564 473864186 594903082 -322092777 -1391940298 372497083 -823937652 -1760344925 -1320056791 2017894431 -1630868643 714640651 2041748547 -872059074 -722081181 1848909188 -114252418 -1004517480 -1683237274 2144090053 605157490 -196683839 1115455688 1066259207 972993499 -53399305 -1992030611 -1538736557 -3769339 -690146824 1119060552 -1928548076 1251577776 2051552851 -176568761 -93284524 840791444 -1650845476 278276857 1805533361 -1936819703 83921672 -1763804193 1541188189 597924045 547229536 -779774850 -1235937192 -1688149960 1136750512 -1704440658 -951822116 -909802962 1961142856 -1995406370 -656070173 -1674016082 -291033385 375516481 1851477506 1563568205 -1115118281 -1662735945 1485162889 -1772245388 -1562219914 1964116999 471438291 1464979310 -1076369139 -126338275 1948255454 -1059893188 1606033534 -713413217 -806608675 644046057 -865933132 -595009187 1869803686 2196575 2065107807 1719549225 -522713864 -2065017443 -120815680 -107547671 122255160 -786279330 -1763942492 2131284443 -471572515 1960548118 1408376814 243995851 78303322 -1932383535 -897308055 -434915570 467829288 -661291397 -198618427 1189946498 1189732797 5246383 1594901750 -1370210710 -1393813870 -1475974348 1944355941 1530946214 80433189 -2048301407 -97390908 155533667 -1966555202 849320066 -1857608809 -573342503 223485123 256907380 1413100892 -2105499251 1339813186 -221611936 412937228 1882786073 -1561891366 384169555 1753672835 -1188447040 -909914355 1759676433 -584493505 -375676384 -1265318567 -510277282 -911569239 -86264954 344669096 -1060786190 -2093261971 2117274047 1412514404 -1792713760 1053022835 -2005130395 1675737775 1625891427 -519397838 2093806258 1167718281 -1958559556 373564603 1479980177 -947782290 482253789 -1026494785 1774671205 -72544500 -399770732 -1182448360 -742084510 840118588 1335261861 -1606744715 -788619625 1857936294 869148698 429950344 -1263055109 -835942701 450831961 -2103241460 1053405229 -1738550473 1835829081 -1039612940 1558391017 1193882917
s 750 ; array size
.text
addi $5 $2 0x0 ; establish frame pointer
jmp MAIN
;;; accepts two arguments, corresponding to offsets into `arr'
;;; compares the corresponding values.
;;; if the first index is greater than the second, swaps the two values
;;; in place.
SWAPPER:
push $5 ;function preamble
addi $5 $2 0x0
subi $2 $2 0x0
load $7 +2($5) ; access args
load $6 +1($5)
load $8 arr($7) ; index array
load $9 arr($6)
cmp $9 $8
bgt EXIT
store $9 arr($7) ; perform swap
store $8 arr($6)
EXIT:
addi $2 $5 0x0 ; function postamble
pop $5
ret
MAIN:
push $5 ; function preamble
addi $5 $2 0x0
subi $2 $2 0x4
load $6 s($0) ; inner loop termination condition
subi $7 $6 0x1 ; outer loop termination condition
addi $8 $0 0x0 ; outer loop iterator
jrl OCON
O:
addi $9 $8 0x1 ; inner loop iterator
jrl ICON
I:
store $9 -1($5) ; caller-saved registers
store $8 -2($5)
store $7 -3($5)
store $6 -4($5)
push $8
push $9 ; push args
jal SWAPPER
addi $2 $2 0x2 ; cleanup args
load $9 -1($5) ; restore registers
load $8 -2($5)
load $7 -3($5)
load $6 -4($5)
addi $9 $9 0x1
ICON:
cmp $6 $9
bgt I
addi $8 $8 0x1
OCON:
cmp $7 $8
bgt O
nop
nop
nop
nop
|