<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>brianp.de &#187; Assembler</title>
	<atom:link href="http://brianp.de/category/programmierung/assembler/feed/" rel="self" type="application/rss+xml" />
	<link>http://brianp.de</link>
	<description>Wissen ist der erste Rohstoff, der sich bei Gebrauch vermehrt! - brandeins</description>
	<lastBuildDate>Fri, 30 Jul 2010 15:39:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Berechnung der Determinante einer NxN Matrix in MIPS Assembler</title>
		<link>http://brianp.de/2010/02/06/berechnung-der-determinante-einer-nxn-matrix-in-mips-assembler/</link>
		<comments>http://brianp.de/2010/02/06/berechnung-der-determinante-einer-nxn-matrix-in-mips-assembler/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 20:10:33 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Assembler]]></category>
		<category><![CDATA[TGdI1+2]]></category>
		<category><![CDATA[Determinante]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[MIPS]]></category>

		<guid isPermaLink="false">http://brianp.de/?p=904</guid>
		<description><![CDATA[Dieser Assemblercode kann die Determinante einer NxN Matrix berechnen. Dabei wird die NxN-Matrix mit Hilfe des Laplaceschen Entwicklungssatzes in N N-1xN-1-Matrixen zerlegt (eine 4&#215;4-Matrix wird in 4 3&#215;4-Matrixen zerlegt, usw). Das Programm funktioniert leider nicht für &#8220;große&#8221; Matrixen (z.B. 10&#215;10), weil das Programm dann aus dem Heap raus schreibt. Aber für Matrixen bis 5&#215;5 funktioniert [...]]]></description>
			<content:encoded><![CDATA[<p>Dieser Assemblercode kann die Determinante einer NxN Matrix berechnen. Dabei wird die NxN-Matrix mit Hilfe des Laplaceschen Entwicklungssatzes in N N-1xN-1-Matrixen zerlegt (eine 4&#215;4-Matrix wird in 4 3&#215;4-Matrixen zerlegt, usw).</p>
<p>Das Programm funktioniert leider nicht für &#8220;große&#8221; Matrixen (z.B. 10&#215;10), weil das Programm dann aus dem Heap raus schreibt. Aber für Matrixen bis 5&#215;5 funktioniert es definitiv, eventuell auch für Größere, das habe ich aber nicht getestet.</p>
<div class="codecolorer-container asm default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="asm codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">.data</span><br />
<br />
dim<span style="color: #339933;">:</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">2</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">3</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">4</span><br />
<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">5</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">10</span><br />
<br />
matrix<span style="color: #339933;">:</span><br />
#2x2<span style="color: #339933;">-</span>Martrix<span style="color: #666666; font-style: italic;">; solution = -2</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">6</span><br />
#3x3<span style="color: #339933;">-</span>Matrixx<span style="color: #666666; font-style: italic;">; solution = 4</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><br />
#4x4<span style="color: #339933;">-</span>Matrix<span style="color: #666666; font-style: italic;">; solution = -19</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">7</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">5</span><br />
#solution = <span style="color: #0000ff;">0</span><br />
<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span><span style="color: #0000ff;">6</span><span style="color: #339933;">,</span><span style="color: #0000ff;">7</span><span style="color: #339933;">,</span><span style="color: #0000ff;">8</span><span style="color: #339933;">,</span><span style="color: #0000ff;">9</span><span style="color: #339933;">,</span><span style="color: #0000ff;">10</span><span style="color: #339933;">,</span><span style="color: #0000ff;">11</span><span style="color: #339933;">,</span><span style="color: #0000ff;">12</span><span style="color: #339933;">,</span><span style="color: #0000ff;">13</span><span style="color: #339933;">,</span><span style="color: #0000ff;">14</span><span style="color: #339933;">,</span><span style="color: #0000ff;">15</span><span style="color: #339933;">,</span><span style="color: #0000ff;">16</span><span style="color: #339933;">,</span><span style="color: #0000ff;">17</span><span style="color: #339933;">,</span><span style="color: #0000ff;">18</span><span style="color: #339933;">,</span><span style="color: #0000ff;">19</span><span style="color: #339933;">,</span><span style="color: #0000ff;">20</span><span style="color: #339933;">,</span><span style="color: #0000ff;">21</span><span style="color: #339933;">,</span><span style="color: #0000ff;">22</span><span style="color: #339933;">,</span><span style="color: #0000ff;">23</span><span style="color: #339933;">,</span><span style="color: #0000ff;">24</span><span style="color: #339933;">,</span><span style="color: #0000ff;">25</span><br />
#<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">word</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">2</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #0000ff;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">5</span><br />
<br />
det<span style="color: #339933;">:</span>&nbsp; &nbsp; <span style="color: #339933;">.</span>asciiz <span style="color: #7f007f;">&quot;Die Determinante ist: &quot;</span><br />
###############################################################################<br />
<br />
<span style="color: #339933;">.</span>text<br />
<br />
main<span style="color: #339933;">:</span><br />
###################################<br />
###################################<br />
#Hier soll <span style="color: #00007f; font-weight: bold;">das</span> Programm stehen<br />
#Das Ergebnis muss am Ende <span style="color: #00007f; font-weight: bold;">in</span> $s6 stehen<span style="color: #339933;">.</span><br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s7<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0x10040000</span> # initialize default heap pointer<br />
&nbsp;<br />
&nbsp; &nbsp; la&nbsp; &nbsp; &nbsp; $a0<span style="color: #339933;">,</span> matrix<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $a1<span style="color: #339933;">,</span> dim<br />
&nbsp; &nbsp; jal &nbsp; &nbsp; calcDet<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s6<span style="color: #339933;">,</span> $v0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
<br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; ende<br />
<br />
###################################<br />
# Calculates the determinante of a NxN matrix<span style="color: #339933;">.</span><br />
# expects<span style="color: #339933;">:</span>&nbsp; adress of array with N^<span style="color: #0000ff;">2</span> elements <span style="color: #00007f; font-weight: bold;">in</span> $a0<br />
# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dimension of matrix <span style="color: #00007f; font-weight: bold;">in</span> $a1<br />
# returns det<span style="color: #339933;">.</span> of given matrix <span style="color: #00007f; font-weight: bold;">in</span> $v0<br />
###################################<br />
# Documentation<br />
# $a0 &nbsp; <span style="color: #339933;">-</span>&gt; matrix<br />
# $a1 &nbsp; <span style="color: #339933;">-</span>&gt; dim<br />
# <span style="color: #339933;">----------------</span><br />
# $s0 &nbsp; <span style="color: #339933;">-</span>&gt; sum of det<span style="color: #339933;">.</span> of matrixes<br />
calcDet<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span><br />
&nbsp; &nbsp; slti&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $a1<span style="color: #339933;">,</span> <span style="color: #0000ff;">2</span> &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span> $a1<span style="color: #009900; font-weight: bold;">&#40;</span>=dim<span style="color: #009900; font-weight: bold;">&#41;</span> &lt; <span style="color: #0000ff;">2</span><br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> calcDetIf&nbsp; # jump to the <span style="color: #000000; font-weight: bold;">if</span> part<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span> $t0 == $t1<span style="color: #009900; font-weight: bold;">&#40;</span>=<span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #0000ff;">2</span> &lt; dim<br />
&nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $v0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$a0<span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; jr&nbsp; &nbsp; &nbsp; $ra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # jump back to caller<br />
<br />
calcDetIf<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # The <span style="color: #000000; font-weight: bold;">if</span> part<br />
&nbsp; &nbsp; # reduce maxtrix <span style="color: #00007f; font-weight: bold;">and</span> <span style="color: #00007f; font-weight: bold;">call</span> recursive <span style="color: #000000; font-weight: bold;">for</span> each<br />
&nbsp; &nbsp; # reduced matrix<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $sp<span style="color: #339933;">,</span> $sp<span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">4</span>&nbsp; &nbsp; &nbsp; &nbsp; # get some space on <span style="color: #000000; font-weight: bold;">stack</span><br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $ra<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store return adress <span style="color: #00007f; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">stack</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s0<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # initialize $s0 <span style="color: #009900; font-weight: bold;">&#40;</span>sum<span style="color: #009900; font-weight: bold;">&#41;</span> with <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # initialize $t0 <span style="color: #009900; font-weight: bold;">&#40;</span>i<span style="color: #009900; font-weight: bold;">&#41;</span> with <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; <br />
calcDetLoop<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">loop</span> over <span style="color: #000000; font-weight: bold;">all</span> <span style="color: #00007f; font-weight: bold;">sub</span><span style="color: #339933;">-</span>matrixes<br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $a1<span style="color: #339933;">,</span> calcDetLoopDone<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">while</span> $t0<span style="color: #009900; font-weight: bold;">&#40;</span>=i<span style="color: #009900; font-weight: bold;">&#41;</span> != $a1<span style="color: #009900; font-weight: bold;">&#40;</span>=dim<span style="color: #009900; font-weight: bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $sp<span style="color: #339933;">,</span> $sp<span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">16</span> &nbsp; &nbsp; &nbsp; # get some space on <span style="color: #000000; font-weight: bold;">stack</span><br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $s0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store sum<br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store $t0 <span style="color: #009900; font-weight: bold;">&#40;</span>i<span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $a0<span style="color: #339933;">,</span> <span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store $a0<br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $a1<span style="color: #339933;">,</span> <span style="color: #0000ff;">12</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; # store $a1<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # dont need to copy any adress <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">in</span> $a0 because its already there<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # dont need to copy any dimension<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # of matrix <span style="color: #00007f; font-weight: bold;">in</span> $a1 because its already there<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $a2<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # copy i <span style="color: #00007f; font-weight: bold;">into</span> $a2<br />
&nbsp; &nbsp; jal &nbsp; &nbsp; reduceMatrix&nbsp; &nbsp; &nbsp; &nbsp; # jump to reduceMatrix<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $a0<span style="color: #339933;">,</span> $v0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # copy result adress of reduceMatrix<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">into</span> argument register <span style="color: #000000; font-weight: bold;">for</span> recursive <span style="color: #00007f; font-weight: bold;">call</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">sub</span> &nbsp; &nbsp; $a1<span style="color: #339933;">,</span> $a1<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $a1 = dim <span style="color: #339933;">-</span> <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; jal &nbsp; &nbsp; calcDet &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">call</span> myself recursively<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $a1<span style="color: #339933;">,</span> <span style="color: #0000ff;">12</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; # load $a1<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $a0<span style="color: #339933;">,</span> <span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load $a0<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load $t0 <span style="color: #009900; font-weight: bold;">&#40;</span>i<span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $s0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load sum<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $sp<span style="color: #339933;">,</span> $sp<span style="color: #339933;">,</span> <span style="color: #0000ff;">16</span>&nbsp; &nbsp; &nbsp; &nbsp; # clean up the <span style="color: #000000; font-weight: bold;">stack</span><br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # initialise pow<span style="color: #009900; font-weight: bold;">&#40;</span>er<span style="color: #009900; font-weight: bold;">&#41;</span> with <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">and</span> &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t1 = $t0 &amp; <span style="color: #0000ff;">0x00000001</span><br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> calcDetLoopJump<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # skip one line<span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">if</span> $t0 <span style="color: #339933;">%</span> <span style="color: #0000ff;">2</span> = <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # set power to <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><br />
calcDetLoopJump<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t1<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t1 = <span style="color: #0000ff;">4</span> <span style="color: #009900; font-weight: bold;">&#40;</span>because one <span style="color: #000000; font-weight: bold;">word</span> = <span style="color: #0000ff;">4</span> bytes<span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # i <span style="color: #339933;">*</span> $t1<span style="color: #009900; font-weight: bold;">&#40;</span>=<span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # get result <span style="color: #00007f; font-weight: bold;">in</span> $t3<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> &nbsp; &nbsp; $t3<span style="color: #339933;">,</span> $a0<span style="color: #339933;">,</span> $t3 &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">add</span> calulated <span style="color: #000000; font-weight: bold;">offset</span> to start adress of matrix<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $t3<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$t3<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load value <span style="color: #000000; font-weight: bold;">at</span> calulated adress<br />
<br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # power <span style="color: #339933;">*</span> <span style="color: #009900; font-weight: bold;">&#40;</span>i<span style="color: #339933;">-</span>th element <span style="color: #00007f; font-weight: bold;">in</span> matrx <span style="color: #009900; font-weight: bold;">&#40;</span>always <span style="color: #00007f; font-weight: bold;">in</span> first row<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # get result <span style="color: #00007f; font-weight: bold;">in</span> $t4<br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $t4<span style="color: #339933;">,</span> $v0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # multiply calcDet<span style="color: #339933;">-</span>result with calculated stuff<br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # get result <span style="color: #00007f; font-weight: bold;">in</span> $t4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> &nbsp; &nbsp; $s0<span style="color: #339933;">,</span> $s0<span style="color: #339933;">,</span> $t4 &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">add</span> to sum<br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t0<span style="color: #339933;">++</span> <span style="color: #00007f; font-weight: bold;">or</span> i<span style="color: #339933;">++</span><br />
<br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; calcDetLoop<br />
<br />
<br />
calcDetLoopDone<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">loop</span> finished<span style="color: #339933;">,</span> calculated <span style="color: #000000; font-weight: bold;">all</span> matrixes<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $v0<span style="color: #339933;">,</span> $s0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # copy sum <span style="color: #00007f; font-weight: bold;">into</span> return register<br />
<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $ra<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$sp<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load return adress from <span style="color: #000000; font-weight: bold;">stack</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $sp<span style="color: #339933;">,</span> $sp<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # get some space on <span style="color: #000000; font-weight: bold;">stack</span><br />
<br />
&nbsp; &nbsp; jr&nbsp; &nbsp; &nbsp; $ra<br />
###################################<br />
<br />
<br />
###################################<br />
# Extracts _one_ <span style="color: #009900; font-weight: bold;">&#40;</span>N<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span> matrix from a<br />
# NxN matrix<span style="color: #339933;">.</span> The argument<br />
# $a2 says which <span style="color: #009900; font-weight: bold;">&#40;</span>N<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span> matrix should<br />
# be returned<span style="color: #339933;">.</span><br />
# expects<span style="color: #339933;">:</span>&nbsp; adress of array with N^<span style="color: #0000ff;">2</span> elements <span style="color: #00007f; font-weight: bold;">in</span> $a0<br />
# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dimension of matrix <span style="color: #00007f; font-weight: bold;">in</span> $a1<br />
# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index of the smaller matrix <span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #339933;">-</span>based<span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #00007f; font-weight: bold;">in</span> $a2<br />
# returns adress of <span style="color: #009900; font-weight: bold;">&#40;</span>N<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span> matrix <span style="color: #00007f; font-weight: bold;">in</span> $v0<br />
###################################<br />
# Documentation<br />
# $a0 &nbsp; <span style="color: #339933;">-</span>&gt; matrix<br />
# $a1 &nbsp; <span style="color: #339933;">-</span>&gt; dim<br />
# $a2 &nbsp; <span style="color: #339933;">-</span>&gt; index of matrix that should be returned<br />
# <span style="color: #339933;">----------------</span><br />
# $s0 &nbsp; <span style="color: #339933;">-</span>&gt; dim <span style="color: #339933;">-</span> <span style="color: #0000ff;">1</span><br />
# $s1 &nbsp; <span style="color: #339933;">-</span>&gt; counter <span style="color: #000000; font-weight: bold;">for</span> the current position <span style="color: #00007f; font-weight: bold;">in</span> the SOURCE matrix<br />
# $s2 &nbsp; <span style="color: #339933;">-</span>&gt; counter <span style="color: #000000; font-weight: bold;">for</span> the current position <span style="color: #00007f; font-weight: bold;">in</span> the TARGET matrix<br />
reduceMatrix<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s0<span style="color: #339933;">,</span> $a1<span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">1</span>&nbsp; &nbsp; &nbsp; &nbsp; # $s0 = dim <span style="color: #339933;">-</span> <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $s0<span style="color: #339933;">,</span> $s0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $s0<span style="color: #339933;">*</span>$s0 <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #009900; font-weight: bold;">&#40;</span>N<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span>^<span style="color: #0000ff;">2</span> <span style="color: #00007f; font-weight: bold;">or</span> <span style="color: #009900; font-weight: bold;">&#40;</span>dim<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span>^<span style="color: #0000ff;">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # is also the <span style="color: #000000; font-weight: bold;">size</span> of the<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # new matrix<br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # get result <span style="color: #00007f; font-weight: bold;">into</span> $t1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t1 contains now the number of words required<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s1<span style="color: #339933;">,</span> $a0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # copy start adress of source matrix <span style="color: #00007f; font-weight: bold;">in</span> $s1<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s2<span style="color: #339933;">,</span> $s7<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # save current position of heap pointer <span style="color: #00007f; font-weight: bold;">in</span> $s2<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $v0<span style="color: #339933;">,</span> $s7<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # copy target array adress <span style="color: #00007f; font-weight: bold;">in</span> return register<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # set $t0 = <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $t1<span style="color: #339933;">,</span> $t0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # multiply $t0<span style="color: #009900; font-weight: bold;">&#40;</span>=<span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #339933;">*</span> $t1<span style="color: #009900; font-weight: bold;">&#40;</span>=<span style="color: #009900; font-weight: bold;">&#40;</span>dim<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span>^<span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #339933;">-</span>&gt; amount of necessary bytes<br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # copy result <span style="color: #00007f; font-weight: bold;">in</span> $t0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> &nbsp; &nbsp; $s7<span style="color: #339933;">,</span> $s7<span style="color: #339933;">,</span> $t0 &nbsp; &nbsp; &nbsp; # get <span style="color: #009900; font-weight: bold;">&#40;</span>N<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span>^<span style="color: #0000ff;">2</span> space of heap<br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # set $t0 = <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $a1<span style="color: #339933;">,</span> $t0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $a1<span style="color: #009900; font-weight: bold;">&#40;</span>=dim<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">*</span>$t0<span style="color: #009900; font-weight: bold;">&#40;</span>=<span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # number of bytes that must be skipped to<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # skip the first row of source matrix<br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> &nbsp; &nbsp; $s1<span style="color: #339933;">,</span> $s1<span style="color: #339933;">,</span> $t0 &nbsp; &nbsp; &nbsp; # skip dim<span style="color: #339933;">-</span>elements <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # skip the first row of source matrix<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $s0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; # initialize counter <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #00007f; font-weight: bold;">loop</span> <span style="color: #0000ff;">1</span><span style="color: #666666; font-style: italic;">; used as i</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> $a2 &nbsp; &nbsp; &nbsp; # $t2 = $t0 <span style="color: #339933;">+</span> $a2 <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t2 = i <span style="color: #339933;">+</span> index<br />
reduceMatrixLoop1<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">loop</span> <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> reduceMatrixLoop1Done<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">while</span> index != i<br />
<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$s1<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load next entry from source matrix <span style="color: #00007f; font-weight: bold;">in</span> $t1<br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$s2<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store the entry <span style="color: #00007f; font-weight: bold;">in</span> the target matrix<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s1<span style="color: #339933;">,</span> $s1<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # increase pointer $s1 = $s1 <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s2<span style="color: #339933;">,</span> $s2<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # increase pointer $s2 = $s2 <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span><br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t0 = $t0 <span style="color: #339933;">+</span> <span style="color: #0000ff;">1</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t0<span style="color: #339933;">++</span> <span style="color: #009900; font-weight: bold;">&#40;</span>i<span style="color: #339933;">++</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; reduceMatrixLoop1 &nbsp; # jump up to the beginning of the <span style="color: #00007f; font-weight: bold;">loop</span><br />
reduceMatrixLoop1Done<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # endloop <span style="color: #0000ff;">1</span><br />
reduceMatrixLoop2<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">loop</span> <span style="color: #0000ff;">2</span><br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $a1<span style="color: #339933;">,</span> $a1<br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t1<br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t1<span style="color: #339933;">,</span> reduceMatrixLoop2Done<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">while</span> i &lt; dim^<span style="color: #0000ff;">2</span><br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s1<span style="color: #339933;">,</span> $s1<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # skip one element <span style="color: #00007f; font-weight: bold;">in</span> SOURCE matrix<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t0 = $t0 <span style="color: #339933;">+</span> <span style="color: #0000ff;">1</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t0<span style="color: #339933;">++</span> <span style="color: #00007f; font-weight: bold;">or</span> i<span style="color: #339933;">++</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $a1<span style="color: #339933;">,</span> $a1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $a1^<span style="color: #0000ff;">2</span> <span style="color: #00007f; font-weight: bold;">or</span> dim^<span style="color: #0000ff;">2</span><br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # get the result <span style="color: #00007f; font-weight: bold;">in</span> $t2<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">sub</span> &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t2<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">sub</span> <span style="color: #0000ff;">1</span> from $t2<span style="color: #339933;">,</span> because I want to compare<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # it with $t0 <span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #0000ff;">0</span><span style="color: #339933;">-</span>based<span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #009900; font-weight: bold;">&#40;</span>dim^<span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">sub</span> &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t2<span style="color: #339933;">,</span> $t0 &nbsp; &nbsp; &nbsp; # $t2<span style="color: #339933;">-</span>$t0 <span style="color: #00007f; font-weight: bold;">or</span> <span style="color: #009900; font-weight: bold;">&#40;</span>dim^<span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">-</span>i<br />
&nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span><br />
&nbsp; &nbsp; slt &nbsp; &nbsp; $t3<span style="color: #339933;">,</span> $t2<span style="color: #339933;">,</span> $s0 &nbsp; &nbsp; &nbsp; # <span style="color: #009900; font-weight: bold;">&#40;</span>dim^<span style="color: #0000ff;">2</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #339933;">-</span>i &lt; dim<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span> $t3 == <span style="color: #0000ff;">1</span><span style="color: #339933;">,</span> you reached the last<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # row <span style="color: #00007f; font-weight: bold;">and</span> already skipped<br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t3<span style="color: #339933;">,</span> $<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> reduceMatrixLoop2Else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # jumps<span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900; font-weight: bold;">&#40;</span>dim<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span>^<span style="color: #0000ff;">2</span> <span style="color: #339933;">-</span> i &lt; dim <span style="color: #339933;">-</span> <span style="color: #0000ff;">1</span> is false<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">in</span> human words<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">if</span> the programm<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # is <span style="color: #00007f; font-weight: bold;">NOT</span> <span style="color: #00007f; font-weight: bold;">in</span> the last row of the source matrix<br />
&nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span> case<br />
&nbsp; &nbsp; # copy the last elements of source <span style="color: #00007f; font-weight: bold;">into</span> target <span style="color: #00007f; font-weight: bold;">and</span> <span style="color: #000000; font-weight: bold;">exit</span> function! <span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; mult&nbsp; &nbsp; $a1<span style="color: #339933;">,</span> $a1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # dim^<span style="color: #0000ff;">2</span><br />
&nbsp; &nbsp; mflo&nbsp; &nbsp; $t2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # get result <span style="color: #00007f; font-weight: bold;">in</span> $t2<br />
reduceMatrixLoop2Loop1<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> reduceMatrixLoop2Done<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # jump <span style="color: #000000; font-weight: bold;">if</span> dim^<span style="color: #0000ff;">2</span><span style="color: #339933;">-</span><span style="color: #0000ff;">1</span> == i <span style="color: #00007f; font-weight: bold;">or</span> jump <span style="color: #000000; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">end</span> of source matrix is reached<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$s1<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load next entry from source matrix <span style="color: #00007f; font-weight: bold;">in</span> $t1<br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$s2<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store the entry <span style="color: #00007f; font-weight: bold;">in</span> the target matrix<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s1<span style="color: #339933;">,</span> $s1<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # increase pointer $s1 = $s1 <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s2<span style="color: #339933;">,</span> $s2<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # increase pointer $s2 = $s2 <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span><br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t0 = $t0 <span style="color: #339933;">+</span> <span style="color: #0000ff;">1</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t0<span style="color: #339933;">++</span> <span style="color: #00007f; font-weight: bold;">or</span> i<span style="color: #339933;">++</span><br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; reduceMatrixLoop2Loop1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # jump up again<span style="color: #339933;">,</span> because its a <span style="color: #00007f; font-weight: bold;">loop</span>!<br />
<br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; reduceMatrixLoop2Endif<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #00007f; font-weight: bold;">leave</span> <span style="color: #000000; font-weight: bold;">if</span> case<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # never used because <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #00007f; font-weight: bold;">loop</span> is finished<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # it will jump to the <span style="color: #000000; font-weight: bold;">end</span> of the function<br />
<br />
reduceMatrixLoop2Else<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">else</span> case<br />
&nbsp; &nbsp; # copy dim <span style="color: #339933;">-</span> <span style="color: #0000ff;">1</span> elements<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> $s0 &nbsp; &nbsp; &nbsp; # $t2 = $t0<span style="color: #009900; font-weight: bold;">&#40;</span>=i<span style="color: #009900; font-weight: bold;">&#41;</span> <span style="color: #339933;">+</span> $s0<span style="color: #009900; font-weight: bold;">&#40;</span>=dim<span style="color: #339933;">-</span><span style="color: #0000ff;">1</span><span style="color: #009900; font-weight: bold;">&#41;</span><br />
reduceMatrixLoop2ElseLoop<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; beq &nbsp; &nbsp; $t2<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> reduceMatrixLoop2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">if</span> $t2 = $t0 jump to main <span style="color: #00007f; font-weight: bold;">loop</span><br />
<br />
&nbsp; &nbsp; lw&nbsp; &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$s1<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # load next entry from source matrix <span style="color: #00007f; font-weight: bold;">in</span> $t1<br />
&nbsp; &nbsp; sw&nbsp; &nbsp; &nbsp; $t1<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#40;</span>$s2<span style="color: #009900; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; # store the entry <span style="color: #00007f; font-weight: bold;">in</span> the target matrix<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s1<span style="color: #339933;">,</span> $s1<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # increase pointer $s1 = $s1 <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $s2<span style="color: #339933;">,</span> $s2<span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; # increase pointer $s2 = $s2 <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t0 = $t0 <span style="color: #339933;">+</span> <span style="color: #0000ff;">1</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t0<span style="color: #339933;">++</span> <span style="color: #00007f; font-weight: bold;">or</span> i<span style="color: #339933;">++</span><br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; reduceMatrixLoop2ElseLoop<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # jump up to the beginning of the <span style="color: #00007f; font-weight: bold;">loop</span><br />
<br />
reduceMatrixLoop2Endif<span style="color: #339933;">:</span> &nbsp; &nbsp; &nbsp; &nbsp; # <span style="color: #000000; font-weight: bold;">endif</span><br />
<br />
<br />
&nbsp; &nbsp; addi&nbsp; &nbsp; $t0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; # $t0 = $t0 <span style="color: #339933;">+</span> <span style="color: #0000ff;">1</span> <span style="color: #00007f; font-weight: bold;">or</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # $t0<span style="color: #339933;">++</span> <span style="color: #00007f; font-weight: bold;">or</span> i<span style="color: #339933;">++</span><br />
&nbsp; &nbsp; j &nbsp; &nbsp; &nbsp; reduceMatrixLoop2 &nbsp; # jump up to the beginning of the <span style="color: #00007f; font-weight: bold;">loop</span><br />
reduceMatrixLoop2Done<span style="color: #339933;">:</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # endloop <span style="color: #0000ff;">2</span><br />
&nbsp; &nbsp; jr&nbsp; &nbsp; &nbsp; $ra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # jump to caller function<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # return value <span style="color: #009900; font-weight: bold;">&#40;</span>$v0<span style="color: #009900; font-weight: bold;">&#41;</span> is set <span style="color: #000000; font-weight: bold;">at</span> beginning<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # of <span style="color: #000000; font-weight: bold;">this</span> function<br />
###################################<br />
<br />
###################################<br />
###################################<br />
<br />
ende<span style="color: #339933;">:</span><br />
#Ausgabe<br />
<br />
la $a0 det<br />
li $v0 <span style="color: #0000ff;">4</span><br />
<span style="color: #000000; font-weight: bold;">syscall</span><br />
<br />
move $a0<span style="color: #339933;">,</span> $s6<br />
li $v0<span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span><br />
<span style="color: #000000; font-weight: bold;">syscall</span><br />
<br />
###################################<br />
#Ende<br />
li $v0<span style="color: #339933;">,</span> <span style="color: #0000ff;">10</span><br />
<span style="color: #000000; font-weight: bold;">syscall</span></div></div>
<p><!-- wp_ad_camp_1 --></p>
<p><a href="http://brianp.de/wp-content/uploads/2010/02/calcDet.png"><img src="http://brianp.de/wp-content/uploads/2010/02/calcDet-300x193.png" alt="" title="calcDet" width="300" height="193" class="alignnone size-medium wp-image-907" /></a></p>
<p><a href="http://brianp.de/wp-content/uploads/2010/02/reduceMatrix.png"><img src="http://brianp.de/wp-content/uploads/2010/02/reduceMatrix-300x238.png" alt="" title="reduceMatrix" width="300" height="238" class="alignnone size-medium wp-image-908" /></a></p>
<div class="pdf24Plugin-cp-box"><form method="post" action="http://doc2pdf.pdf24.org/doc2pdf/wordpress.php" target="pdf24PopWin" onsubmit="window.open('about:blank', 'pdf24PopWin', 'scrollbars=yes,width=400,height=200,top=0,left=0'); return true;"><input type="hidden" name="blogCharset" value="VVRGLTg=" /><input type="hidden" name="blogPosts" value="MQ==" /><input type="hidden" name="blogUrl" value="aHR0cDovL2JyaWFucC5kZQ==" /><input type="hidden" name="blogName" value="YnJpYW5wLmRl" /><input type="hidden" name="blogValueEncoding" value="base64" /><input type="hidden" name="postTitle_0" value="QmVyZWNobnVuZyBkZXIgRGV0ZXJtaW5hbnRlIGVpbmVyIE54TiBNYXRyaXggaW4gTUlQUyBBc3NlbWJsZXI=" /><input type="hidden" name="postLink_0" value="aHR0cDovL2JyaWFucC5kZS8yMDEwLzAyLzA2L2JlcmVjaG51bmctZGVyLWRldGVybWluYW50ZS1laW5lci1ueG4tbWF0cml4LWluLW1pcHMtYXNzZW1ibGVyLw==" /><input type="hidden" name="postAuthor_0" value="QnJpYW4=" /><input type="hidden" name="postDateTime_0" value="MjAxMC0wMi0wNiAyMTowMjozMw==" /><input type="hidden" name="postContent_0" value="PHA+RGllc2VyIEFzc2VtYmxlcmNvZGUga2FubiBkaWUgRGV0ZXJtaW5hbnRlIGVpbmVyIE54TiBNYXRyaXggYmVyZWNobmVuLiBEYWJlaSB3aXJkIGRpZSBOeE4tTWF0cml4IG1pdCBIaWxmZSBkZXMgTGFwbGFjZXNjaGVuIEVudHdpY2tsdW5nc3NhdHplcyBpbiBOIE4tMXhOLTEtTWF0cml4ZW4gemVybGVndCAoZWluZSA0JiMyMTU7NC1NYXRyaXggd2lyZCBpbiA0IDMmIzIxNTs0LU1hdHJpeGVuIHplcmxlZ3QsIHVzdykuPC9wPgo8cD5EYXMgUHJvZ3JhbW0gZnVua3Rpb25pZXJ0IGxlaWRlciBuaWNodCBmw7xyICYjODIyMDtncm/Dn2UmIzgyMjE7IE1hdHJpeGVuICh6LkIuIDEwJiMyMTU7MTApLCB3ZWlsIGRhcyBQcm9ncmFtbSBkYW5uIGF1cyBkZW0gSGVhcCByYXVzIHNjaHJlaWJ0LiBBYmVyIGbDvHIgTWF0cml4ZW4gYmlzIDUmIzIxNTs1IGZ1bmt0aW9uaWVydCBlcyBkZWZpbml0aXYsIGV2ZW50dWVsbCBhdWNoIGbDvHIgR3LDtsOfZXJlLCBkYXMgaGFiZSBpY2ggYWJlciBuaWNodCBnZXRlc3RldC48L3A+CjxkaXY+OjpDT0RFQ09MT1JFUl9CTE9DS18yOjo8L2Rpdj4KPHA+PCEtLSB3cF9hZF9jYW1wXzEgLS0+PC9wPgo8cD48YSBocmVmPSJodHRwOi8vYnJpYW5wLmRlL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEwLzAyL2NhbGNEZXQucG5nIj48aW1nIHNyYz0iaHR0cDovL2JyaWFucC5kZS93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8wMi9jYWxjRGV0LTMwMHgxOTMucG5nIiBhbHQ9IiIgdGl0bGU9ImNhbGNEZXQiIHdpZHRoPSIzMDAiIGhlaWdodD0iMTkzIiBjbGFzcz0iYWxpZ25ub25lIHNpemUtbWVkaXVtIHdwLWltYWdlLTkwNyIgLz48L2E+PC9wPgo8cD48YSBocmVmPSJodHRwOi8vYnJpYW5wLmRlL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEwLzAyL3JlZHVjZU1hdHJpeC5wbmciPjxpbWcgc3JjPSJodHRwOi8vYnJpYW5wLmRlL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEwLzAyL3JlZHVjZU1hdHJpeC0zMDB4MjM4LnBuZyIgYWx0PSIiIHRpdGxlPSJyZWR1Y2VNYXRyaXgiIHdpZHRoPSIzMDAiIGhlaWdodD0iMjM4IiBjbGFzcz0iYWxpZ25ub25lIHNpemUtbWVkaXVtIHdwLWltYWdlLTkwOCIgLz48L2E+PC9wPgo=" /><a href="http://de.pdf24.org" target="_blank" title="PDF erstellen"><img src="http://brianp.de/wp-content/plugins/pdf24-post-to-pdf/img/sheep_16x16.gif" alt="PDF erstellen" border="0" /></a> <span class="pdf24Plugin-cp-space">&nbsp;&nbsp;</span> <span class="pdf24Plugin-cp-text">Sende Artikel als PDF an</span> <input class="pdf24Plugin-cp-input" style="margin: 0px;" type="text" name="sendEmailTo" value="Emailadresse" onmousedown="this.value = '';" /> <input class="pdf24Plugin-cp-submit" style="margin: 0px;" type="submit" value="Senden" /></form></div>
]]></content:encoded>
			<wfw:commentRss>http://brianp.de/2010/02/06/berechnung-der-determinante-einer-nxn-matrix-in-mips-assembler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
