Created
February 7, 2009 19:04
-
-
Save locks/59981 to your computer and use it in GitHub Desktop.
Exame Modelo, prática (ARQCP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ESTÁ AINDA UM BOCADO INCOMPLETO, nomeadamente faltam preencher rotinas xD | |
.file "exame_1.s" | |
.include "lib/auxil.s" | |
.include "lib/Biblioteca1.s" | |
.org 0x1000 | |
br inicio | |
difHora:: | |
call converte_para_segundos | |
pop lstack | |
call converte_para_segundos | |
push lstack | |
; (total1 total2) | |
call verificar_24h | |
call converte_final ; (segundos_resultado -- seg3 min3 hor3) | |
ret | |
converte_para_segundos:: | |
push.l #3600 | |
call mymulu | |
pop | |
xcg | |
push.l #60 | |
call mymulu | |
pop | |
add | |
add | |
ret | |
verificar_24h:: | |
; (seg_total_1 seg_total_2) | |
pop lstack | |
pop lstack ; (r1:seg_total_2 r0:seg_total_1) | |
push r0 | |
push r1 | |
mxm | |
xcg | |
pop | |
push r1 | |
AND | |
bz hora2_eh_maior | |
push lstack | |
push lstack | |
sub | |
ret | |
hora2_eh_maior:: | |
; | |
; acrescenta 24h ao total_1: | |
; 1:30 (t1) - 2:40 (t2) daria erro, o relógio precisa "dar a volta" | |
; 24h+1h30 - 2h40 | |
; | |
push lstack | |
push.l #24horas | |
ld [] | |
add | |
push lstack | |
sub | |
ret | |
inicio:: | |
push.n #seg1 | |
ld [] | |
push.n #min1 | |
ld [] | |
push.n #hor1 | |
ld [] | |
push.n #seg2 | |
ld [] | |
push.n #min2 | |
ld [] | |
push.n #hor2 | |
ld [] | |
call difHora | |
halt | |
.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; rotina: | |
; eIndiceValido (mat iColuna iLinha -- 0|-1) | |
; getEnderecoElemento (mat iC iL -- end_elem) | |
; getNumeroLinhasMatriz (mat -- nL) | |
; getNumeroColunasMatriz (mat -- nC) | |
; getTamanhoElementoMatriz (mat -- tamElem) | |
.file "exame_ex_2.s" | |
.include "Biblioteca1.s" | |
.include "auxil.s" | |
.include "Biblioteca6.s" | |
.include "Biblioteca4.s" | |
.org 0x1000 | |
br main | |
matr1:: | |
.long 2,2,1,2,3,4 | |
verifica1:: | |
pop lstack | |
pop lstack | |
pop lstack | |
verificanegativos:: | |
push r1 | |
push.n #0 | |
mxm | |
bz negativo | |
pop | |
push r2 | |
push.n #0 | |
mxm | |
bz negativo | |
pop | |
verifica:: | |
push r0 | |
call getNcolunas | |
push.n #1 | |
sub | |
push r1 | |
mxm | |
push r0 | |
call getNcolunas | |
push.n #1 | |
sub | |
sub | |
bz verificaLinhas | |
push lstack | |
push lstack | |
push lstack | |
pop | |
pop | |
pop | |
pop | |
push.n #-1 | |
ret | |
verificaLinhas:: | |
pop | |
push r0 | |
call getNlinhas | |
push.n #1 | |
sub | |
push r2 | |
mxm | |
push r0 | |
call getNlinhas | |
push.n #1 | |
sub | |
sub | |
bz valido | |
push lstack | |
push lstack | |
push lstack | |
pop | |
pop | |
pop | |
pop | |
push.n #-1 | |
ret | |
valido:: | |
push lstack | |
push lstack | |
push lstack | |
pop | |
pop | |
pop | |
pop | |
push.n #0 | |
ret | |
negativo:: | |
push lstack | |
push lstack | |
push lstack | |
pop | |
pop | |
pop | |
pop | |
push.n #-1 | |
ret | |
main:: | |
push #matr1 | |
push #1 | |
push #-2 | |
call verifica1 | |
halt | |
.end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment