<?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>Tolstenko &#187; MC404</title>
	<atom:link href="http://tolstenko.net/category/unicamp/20091/mc404/feed/" rel="self" type="application/rss+xml" />
	<link>http://tolstenko.net</link>
	<description>Sobre computação e o mundo</description>
	<lastBuildDate>Sat, 15 May 2010 22:04:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MergeSort em Assembly Faiska</title>
		<link>http://tolstenko.net/2009/06/01/mergesort-em-assembly-faiska/</link>
		<comments>http://tolstenko.net/2009/06/01/mergesort-em-assembly-faiska/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 14:06:11 +0000</pubDate>
		<dc:creator>Alexandre</dc:creator>
				<category><![CDATA[MC404]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[assembler]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[faiska]]></category>
		<category><![CDATA[Mergesort]]></category>

		<guid isPermaLink="false">http://tolstenko.net/?p=160</guid>
		<description><![CDATA[<a href="http://tolstenko.net/2009/06/01/mergesort-em-assembly-faiska/"><img align="left" hspace="5" width="150" height="150" src="http://tolstenko.net/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a><p>Fiz um trabalho interessante aqui na universidade para a matéria de Assembly e acho interessante publicar. Foi pedido que fizessemos um MergeSort em Assembly do processador Faiska. Acredito que esse meu código possa servir de base para que se faça outros MergeSort para outras arquiteturas.</p>
<p></p>

; Programa lab02
; Autor : Alexandre Tolstenko Nogueira
; Lab 07: MergeSort
&#160;
;// [...]]]></description>
			<content:encoded><![CDATA[<p>Fiz um trabalho interessante aqui na universidade para a matéria de Assembly e acho interessante publicar. Foi pedido que fizessemos um MergeSort em Assembly do processador Faiska. Acredito que esse meu código possa servir de base para que se faça outros MergeSort para outras arquiteturas.</p>
<p><span id="more-160"></span></p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">; Programa lab02</span>
<span style="color: #666666; font-style: italic;">; Autor : Alexandre Tolstenko Nogueira</span>
<span style="color: #666666; font-style: italic;">; Lab 07: MergeSort</span>
&nbsp;
<span style="color: #666666; font-style: italic;">;// Funçao em java</span>
<span style="color: #666666; font-style: italic;">;void merge(int a[], int low, int high){</span>
<span style="color: #666666; font-style: italic;">;  if (low == high)</span>
<span style="color: #666666; font-style: italic;">;    return;</span>
<span style="color: #666666; font-style: italic;">;  int length = high-low+1;</span>
<span style="color: #666666; font-style: italic;">;  int pivot = (low+high)/2;</span>
<span style="color: #666666; font-style: italic;">;  merge(a, low, pivot);</span>
<span style="color: #666666; font-style: italic;">;  merge(a, pivot+1, high);</span>
<span style="color: #666666; font-style: italic;">;  int working[] = new int[lenght];</span>
<span style="color: #666666; font-style: italic;">;  for(int i = 0; i&amp;lt; lenght; i++)</span>
<span style="color: #666666; font-style: italic;">;    working[i] = a[low+1];</span>
<span style="color: #666666; font-style: italic;">;  int m1 = 0;</span>
<span style="color: #666666; font-style: italic;">;  int m2 = pivot-low+1;</span>
<span style="color: #666666; font-style: italic;">;  for(int i = 0; i&amp;lt; length; i++){</span>
<span style="color: #666666; font-style: italic;">;    if(m2 &amp;lt;= high-low)</span>
<span style="color: #666666; font-style: italic;">;      if(m1 &amp;lt;= pivot-low)</span>
<span style="color: #666666; font-style: italic;">;	if(working[m1] &amp;gt; working[m2])</span>
<span style="color: #666666; font-style: italic;">;	  a[i+low] = working[m2++];</span>
<span style="color: #666666; font-style: italic;">;	else</span>
<span style="color: #666666; font-style: italic;">;	  a[i+low] = working[m1++];</span>
<span style="color: #666666; font-style: italic;">;      else</span>
<span style="color: #666666; font-style: italic;">;        a[i+low] = working[m2++];</span>
<span style="color: #666666; font-style: italic;">;  }</span>
<span style="color: #666666; font-style: italic;">;  return;</span>
<span style="color: #666666; font-style: italic;">;}</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; algumas constantes</span>
tamanho<span style="color: #339933;">:</span>    <span style="color: #00007f;">ds</span>      <span style="color: #0000ff;">4h</span>                              <span style="color: #666666; font-style: italic;">; posição 0000h tamanho do vetor</span>
vetor<span style="color: #339933;">:</span>	<span style="color: #00007f;">ds</span>	<span style="color: #0000ff;">4h</span>                              <span style="color: #666666; font-style: italic;">; posicao 0004h vetor a ser ordenado</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">org</span> <span style="color: #0000ff;">100h</span>
&nbsp;
Comeco<span style="color: #339933;">:</span>
&nbsp;
set 	r0<span style="color: #339933;">,</span> 	vetor
ld 	r1<span style="color: #339933;">,</span>	tamanho
<span style="color: #00007f; font-weight: bold;">add</span>	r1<span style="color: #339933;">,</span> 	r0
<span style="color: #00007f; font-weight: bold;">sub</span>	r1<span style="color: #339933;">,</span>	<span style="color: #0000ff;">1</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; =================================================================== ;</span>
<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do vetor                                    ;</span>
<span style="color: #666666; font-style: italic;">; r1 -&amp;gt; ponteiro p final do vetor (aponta para um elemento invalido)  ;</span>
<span style="color: #666666; font-style: italic;">; r2 -&amp;gt; é a média do inicio e fim do (sub)vetor                       ;</span>
<span style="color: #666666; font-style: italic;">; =================================================================== ;</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">push</span> 	r0 		<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do vetor</span>
<span style="color: #00007f; font-weight: bold;">push</span> 	r1 		<span style="color: #666666; font-style: italic;">; r1 -&amp;gt; ponteiro p final do vetor</span>
<span style="color: #00007f; font-weight: bold;">call</span> 	MERGE
<span style="color: #00007f; font-weight: bold;">add</span> 	<span style="color: #00007f;">sp</span><span style="color: #339933;">,</span>	<span style="color: #0000ff;">8</span> 	<span style="color: #666666; font-style: italic;">; arruma a pilha</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">jmp</span> FIM
&nbsp;
MERGE<span style="color: #339933;">:</span>
ld 	r0<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do vetor</span>
ld 	r1<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">; r1 -&amp;gt; ponteiro p final do vetor</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">cmp</span> 	r0<span style="color: #339933;">,</span> 	r1 	<span style="color: #666666; font-style: italic;">; compara o inicio e fim do vetor</span>
<span style="color: #00007f; font-weight: bold;">jnz</span>	ali		<span style="color: #666666; font-style: italic;">; se forem iguais, retorna</span>
<span style="color: #00007f; font-weight: bold;">ret</span>
&nbsp;
ali<span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">;media</span>
ld 	r1<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">; r1 -&amp;gt; recarrega o ponteiro p final do vetor</span>
ld 	r0<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do vetor</span>
<span style="color: #00007f; font-weight: bold;">mov</span> 	r2<span style="color: #339933;">,</span> 	r0	<span style="color: #666666; font-style: italic;">; carrega o apontador do inicio do subvetor</span>
<span style="color: #00007f; font-weight: bold;">add</span> 	r2<span style="color: #339933;">,</span>	r1	<span style="color: #666666; font-style: italic;">; soma no temporario o fim do subvetor</span>
<span style="color: #00007f; font-weight: bold;">shr</span> 	r2<span style="color: #339933;">,</span> 	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; faz a media</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; merge(pos_inicial, pos_metade)</span>
<span style="color: #666666; font-style: italic;">; passa os parametros para a pilha</span>
<span style="color: #00007f; font-weight: bold;">push</span> 	r0		<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do vetor</span>
<span style="color: #00007f; font-weight: bold;">push</span> 	r2		<span style="color: #666666; font-style: italic;">; r2 -&amp;gt; indice medio do vetor maior(final do primeiro subvetor)</span>
<span style="color: #00007f; font-weight: bold;">call</span> 	MERGE
<span style="color: #00007f; font-weight: bold;">add</span> 	<span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> 	<span style="color: #0000ff;">8</span> 	<span style="color: #666666; font-style: italic;">; arruma a pilha</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; merge(pos_metade + 1, pos_final)</span>
<span style="color: #666666; font-style: italic;">; passa os parametros para a pilha</span>
&nbsp;
<span style="color: #666666; font-style: italic;">;media</span>
ld 	r1<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">; r1 -&amp;gt; recarrega o ponteiro p final do vetor</span>
ld 	r0<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#41;</span> 	<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do vetor</span>
<span style="color: #00007f; font-weight: bold;">mov</span> 	r2<span style="color: #339933;">,</span> 	r0	<span style="color: #666666; font-style: italic;">; carrega o apontador do inicio do subvetor</span>
<span style="color: #00007f; font-weight: bold;">add</span> 	r2<span style="color: #339933;">,</span>	r1	<span style="color: #666666; font-style: italic;">; soma no temporario o fim do subvetor</span>
<span style="color: #00007f; font-weight: bold;">shr</span> 	r2<span style="color: #339933;">,</span> 	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; faz a media</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r2<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">push</span>	r2        <span style="color: #666666; font-style: italic;">; inicio</span>
<span style="color: #00007f; font-weight: bold;">push</span>	r1        <span style="color: #666666; font-style: italic;">; fim</span>
<span style="color: #00007f; font-weight: bold;">call</span>	MERGE
<span style="color: #00007f; font-weight: bold;">add</span>	<span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> 	<span style="color: #0000ff;">8</span> 	<span style="color: #666666; font-style: italic;">; arruma a pilha</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Funcao intercala</span>
&nbsp;
<span style="color: #666666; font-style: italic;">;  int m1 = 0;</span>
<span style="color: #666666; font-style: italic;">;  int m2 = pivot-low+1;</span>
<span style="color: #666666; font-style: italic;">;  for(int i = 0; i&amp;lt; length; i++){</span>
<span style="color: #666666; font-style: italic;">;    if(m2 &amp;lt;= high-low)</span>
<span style="color: #666666; font-style: italic;">;      if(m1 &amp;lt;= pivot-low)</span>
<span style="color: #666666; font-style: italic;">;	if(working[m1] &amp;gt; working[m2])</span>
<span style="color: #666666; font-style: italic;">;	  a[i+low] = working[m2++];</span>
<span style="color: #666666; font-style: italic;">;	else</span>
<span style="color: #666666; font-style: italic;">;	  a[i+low] = working[m1++];</span>
<span style="color: #666666; font-style: italic;">;      else</span>
<span style="color: #666666; font-style: italic;">;        a[i+low] = working[m2++];</span>
<span style="color: #666666; font-style: italic;">;  }</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; copio o dois subvetores para a memoria auxiliar e arrumo eles</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; =============================================================== ;</span>
<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p o inicio do primeiro subvetor                  ;</span>
<span style="color: #666666; font-style: italic;">; r1 -&amp;gt; ponteiro p o fim do primeiro subvetor                     ;</span>
<span style="color: #666666; font-style: italic;">; r2 -&amp;gt; ponteiro p o inicio do segundo subvetor                   ;</span>
<span style="color: #666666; font-style: italic;">; r3 -&amp;gt;	ponteiro p o final do segundo subvetor                    ;</span>
<span style="color: #666666; font-style: italic;">; r4 -&amp;gt; Ponteiro para o aux                                       ;</span>
<span style="color: #666666; font-style: italic;">; r5 -&amp;gt; Conteudo de r0                                            ;</span>
<span style="color: #666666; font-style: italic;">; r6 -&amp;gt; Conteudo de r2                                            ;</span>
<span style="color: #666666; font-style: italic;">; r7 -&amp;gt; Contador (Tamanho)                                        ;</span>
<span style="color: #666666; font-style: italic;">; =============================================================== ;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; inicializo os ponteiros</span>
ld	r0<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do primeiro subvetor</span>
ld	r3<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">; r3 -&amp;gt; ponteiro p final do segundo subvetor</span>
<span style="color: #00007f; font-weight: bold;">mov</span>	r1<span style="color: #339933;">,</span>	r0	<span style="color: #666666; font-style: italic;">; carrega o apontador do inicio do vetor</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r1<span style="color: #339933;">,</span>	r3	<span style="color: #666666; font-style: italic;">; soma no temporario o fim do vetor</span>
<span style="color: #00007f; font-weight: bold;">shr</span>	r1<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; faz a media que vai ser o fim do primeiro subvetor</span>
<span style="color: #00007f; font-weight: bold;">mov</span>	r2<span style="color: #339933;">,</span>	r1	<span style="color: #666666; font-style: italic;">; carrega a media anterior</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r2<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; soma um e agora o r2 é inicio do segundo subvetor</span>
set	r4<span style="color: #339933;">,</span>	aux	<span style="color: #666666; font-style: italic;">; inicializa o r4</span>
<span style="color: #00007f; font-weight: bold;">mov</span>	r7<span style="color: #339933;">,</span> r3	<span style="color: #666666; font-style: italic;">; pega o ponteiro final para calcular o tamanho do vetor</span>
<span style="color: #00007f; font-weight: bold;">sub</span>	r7<span style="color: #339933;">,</span>	r0	<span style="color: #666666; font-style: italic;">; descobre o tamanho</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r7<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; arruma o tamnho pois eh o indice maior - indice menor + 1</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; =========== Lengenda ========== ;</span>
<span style="color: #666666; font-style: italic;">; F -&amp;gt; Fim do...                  ;</span>
<span style="color: #666666; font-style: italic;">; C -&amp;gt; Continua o... (nao eh fim) ;</span>
<span style="color: #666666; font-style: italic;">; 1 -&amp;gt; Primeiro subvetor          ;</span>
<span style="color: #666666; font-style: italic;">; 2 -&amp;gt; Segundo subvetor           ;</span>
<span style="color: #666666; font-style: italic;">; =============================== ;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Desculpe o tanto de jmps, mas foi pq nao encontrei outra maneira de testar o fim. Sao dois if um dentro do outro</span>
&nbsp;
CopiaOrdendando<span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">; testa os casos de termino</span>
<span style="color: #00007f; font-weight: bold;">cmp</span>	r0<span style="color: #339933;">,</span> 	r1	<span style="color: #666666; font-style: italic;">; compara para saber se terminou o primeiro subvetor</span>
<span style="color: #00007f; font-weight: bold;">ja</span> F1
&nbsp;
C1<span style="color: #339933;">:</span>
<span style="color: #00007f; font-weight: bold;">cmp</span>	r2<span style="color: #339933;">,</span>	r3	<span style="color: #666666; font-style: italic;">; compara para saber se terminou o ultimo subvetor</span>
<span style="color: #00007f; font-weight: bold;">ja</span>	C1F2
<span style="color: #00007f; font-weight: bold;">jmp</span>	C1C2
&nbsp;
F1<span style="color: #339933;">:</span>
<span style="color: #00007f; font-weight: bold;">cmp</span>	r2<span style="color: #339933;">,</span>	r3	<span style="color: #666666; font-style: italic;">; compara para saber se terminou o ultimo subvetor</span>
<span style="color: #00007f; font-weight: bold;">ja</span>	F1F2
<span style="color: #00007f; font-weight: bold;">jmp</span>	F1C2
&nbsp;
<span style="color: #666666; font-style: italic;">; Caso onde ambos nao chegaram ao fim</span>
<span style="color: #adadad; font-style: italic;">C1C2</span><span style="color: #339933;">:</span>
ldb 	r5<span style="color: #339933;">,</span> 	<span style="color: #009900; font-weight: bold;">&#40;</span>r0<span style="color: #009900; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">; capturo o valor do ponteiro do primeiro subvetor</span>
ldb	r6<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span>r2<span style="color: #009900; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">; capturo o valor do ponteiro do segundo subvetor</span>
<span style="color: #00007f; font-weight: bold;">cmp</span>	r5<span style="color: #339933;">,</span>	r6	<span style="color: #666666; font-style: italic;">; comparo</span>
<span style="color: #00007f; font-weight: bold;">jl</span>	CopiaDaEsq
<span style="color: #00007f; font-weight: bold;">jmp</span>	CopiaDaDir
&nbsp;
<span style="color: #666666; font-style: italic;">; caso onde copia o resto do primeiro vetor para o aux</span>
<span style="color: #adadad; font-style: italic;">C1F2</span><span style="color: #339933;">:</span>
ldb   r5<span style="color: #339933;">,</span>   <span style="color: #009900; font-weight: bold;">&#40;</span>r0<span style="color: #009900; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;">; capturo o conteudo do ponteiro para o primeiro subvetor</span>
<span style="color: #00007f; font-weight: bold;">jmp</span> CopiaDaEsq
&nbsp;
<span style="color: #666666; font-style: italic;">; caso onde acabou o loop</span>
<span style="color: #adadad; font-style: italic;">F1F2</span><span style="color: #339933;">:</span>
<span style="color: #00007f; font-weight: bold;">jmp</span> FimOrdena
&nbsp;
<span style="color: #666666; font-style: italic;">; caso onde copia o resto do segundo vetor para o aux</span>
<span style="color: #adadad; font-style: italic;">F1C2</span><span style="color: #339933;">:</span>
ldb r6<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#40;</span>r2<span style="color: #009900; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;">; capturo o conteudo do ponteiro para o segundo subvetor</span>
<span style="color: #00007f; font-weight: bold;">jmp</span> CopiaDaDir
&nbsp;
CopiaDaEsq<span style="color: #339933;">:</span>
stb	<span style="color: #009900; font-weight: bold;">&#40;</span>r4<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,</span>	r5	<span style="color: #666666; font-style: italic;">; gravo no aux</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r0<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; atualizo o ponteiro para o primeiro subvetor</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r4<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; atualizo o ponteiro para o segundo subvetor</span>
<span style="color: #00007f; font-weight: bold;">jmp</span> CopiaOrdendando
&nbsp;
CopiaDaDir<span style="color: #339933;">:</span>
stb	<span style="color: #009900; font-weight: bold;">&#40;</span>r4<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,</span>	r6	<span style="color: #666666; font-style: italic;">; gravo no aux</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r2<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; atualizo o ponteiro para o primeiro subvetor</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r4<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; atualizo o ponteiro para o segundo subvetor</span>
<span style="color: #00007f; font-weight: bold;">jmp</span> CopiaOrdendando
&nbsp;
FimOrdena<span style="color: #339933;">:</span>
ldb	r0<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #00007f;">sp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">8</span><span style="color: #009900; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">; r0 -&amp;gt; ponteiro p inicio do primeiro subvetor</span>
set	r4<span style="color: #339933;">,</span>	aux	<span style="color: #666666; font-style: italic;">; restauro meu r4 para o inicio do vetor auxiliar</span>
&nbsp;
Devolve<span style="color: #339933;">:</span>
ldb	r5<span style="color: #339933;">,</span>	<span style="color: #009900; font-weight: bold;">&#40;</span>r4<span style="color: #009900; font-weight: bold;">&#41;</span>	<span style="color: #666666; font-style: italic;">; jogo num temporario o conteudo do ponteiro do aux</span>
stb	<span style="color: #009900; font-weight: bold;">&#40;</span>r0<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,</span>	r5	<span style="color: #666666; font-style: italic;">; gravo de volta o conteudo no vetor original</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r4<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; anda no vetor aux</span>
<span style="color: #00007f; font-weight: bold;">add</span>	r0<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; anda no vetor original</span>
<span style="color: #00007f; font-weight: bold;">sub</span>	r7<span style="color: #339933;">,</span>	<span style="color: #0000ff;">01h</span>	<span style="color: #666666; font-style: italic;">; atualiza o contador</span>
<span style="color: #00007f; font-weight: bold;">jnz</span> 	Devolve
&nbsp;
<span style="color: #00007f; font-weight: bold;">ret</span>
&nbsp;
FIM<span style="color: #339933;">:</span>
<span style="color: #00007f; font-weight: bold;">hlt</span>
&nbsp;
aux<span style="color: #339933;">:</span> <span style="color: #00007f;">ds</span> 	<span style="color: #0000ff;">100h</span> 	<span style="color: #666666; font-style: italic;">; vetor auxiliar</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tolstenko.net/2009/06/01/mergesort-em-assembly-faiska/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Organização de Computadores e Linguagens de Montagem</title>
		<link>http://tolstenko.net/2009/03/06/organizacao-de-computadores-e-linguagens-de-montagem/</link>
		<comments>http://tolstenko.net/2009/03/06/organizacao-de-computadores-e-linguagens-de-montagem/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 22:50:40 +0000</pubDate>
		<dc:creator>Alexandre</dc:creator>
				<category><![CDATA[MC404]]></category>

		<guid isPermaLink="false">http://tolstenko.net/?p=85</guid>
		<description><![CDATA[<a href="http://tolstenko.net/2009/03/06/organizacao-de-computadores-e-linguagens-de-montagem/"><img align="left" hspace="5" width="150" height="150" src="http://tolstenko.net/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a><p>Dados da disciplina:</p>

Professor: Ricardo Anido
Site: http://www.ic.unicamp.br/~ranido/mc404/
Turma: A

<p>Critérios de aprovação:</p>

Nota de Trabalhos: NT = média dos m trabalhos passados ao longo do curso.
Nota Final: NF = NT se NT &#60; 5,0; NF =  (2 * P1 + 4 * P3 + 4 * NT) / 10 caso contrrário.
Média Final: MF = (NF + Exame) / [...]]]></description>
			<content:encoded><![CDATA[<p>Dados da disciplina:</p>
<ul>
<li>Professor: Ricardo Anido</li>
<li>Site: <a href="http://www.ic.unicamp.br/~ranido/mc404/">http://www.ic.unicamp.br/~ranido/mc404/</a><a href="http://users.lsc.ic.unicamp.br/%7Elsamaral/"></a></li>
<li>Turma: A</li>
</ul>
<p>Critérios de aprovação:</p>
<ul>
<li>Nota de Trabalhos: NT = média dos <em>m</em> trabalhos passados ao longo do curso.</li>
<li>Nota Final: NF = NT se NT &lt; 5,0; NF =  (2 * P1 + 4 * P3 + 4 * NT) / 10 caso contrrário.</li>
<li>Média Final: MF = (NF + Exame) / 2 Se NF &lt; 5,0. MF = NF   caso contrário.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tolstenko.net/2009/03/06/organizacao-de-computadores-e-linguagens-de-montagem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->