Created
October 8, 2009 23:48
-
-
Save elomar/205542 to your computer and use it in GitHub Desktop.
Lista de Exercícios de Assembly
This file contains hidden or 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
| # Considerando que o ano está em $7 | |
| main: # Divisíveis por 400 são bissextos | |
| addi $8, $0, 400 | |
| div $7, $8 | |
| mfhi $9 | |
| beq $9, 0, bissexto | |
| # Divisíveis por 100 e não por 400 não são bissextos | |
| addi $8, $0, 100 | |
| div $7, $8 | |
| mfhi $9 | |
| beq $9, $0, nao_bissexto | |
| # Divisíveis por 4 e não por 100 são bissextos | |
| addi $8, $0, 4 | |
| div $7, $8 | |
| mfhi $9 | |
| beq $9, $0, bissexto | |
| # Todos os outros não são bissextos | |
| j nao_bissexto | |
| bissexto: | |
| addi $11, $0, 1 | |
| nao_bissexto: | |
| nop |
This file contains hidden or 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
| main: addi $8, $0, 10 #Calcular os 10 primeiros elementos da série de fibonacci | |
| addi $7, $0, 1 #Primeiro elemento da série de fibonacci - 1 | |
| addi $8, $8, -1 | |
| for: beq $8, $0, end | |
| add $9, $10, $0 # $9 = fib(i - 2) | |
| add $10, $7, $0 # $10 = fib(i - 1) | |
| add $7, $10, $9 # fib(i) = fib(i - 1) + fib)(i - 2) | |
| addi $8, $8, -1 | |
| j for | |
| end: nop |
This file contains hidden or 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
| # Baseado em http://astro.if.ufrgs.br/pascoa.htm | |
| # Considerando que ano está em $7 | |
| # c = a/100 | |
| # n = a - [19×(a/19)] | |
| # k = (c - 17)/25 | |
| # i = c - c/4 - [(c-k)/3] +(19×n) + 15 | |
| # i = i - [30×(i/30)] | |
| # i = i - {(i/28)×[1-(i/28)]×[29/(i+1)]×[(21-n)/11]} | |
| # j = a + a/4 + i + 2 -c + c/4 | |
| # j = j - [7×(j/7)] | |
| # l = i - j | |
| # m = 3 + [(l+40)/44] | |
| # d = l + 28 - [31×(m/4)] | |
| # $7 = ano | |
| # $8 = mês | |
| # $9 = dia | |
| # $10 = 19 | |
| # $11 = c | |
| # $12 = n | |
| # $13 = k | |
| # $14 = i | |
| # $15 = j | |
| # $16 = l | |
| main: addi $7, $0, 2000 | |
| addi $10, $0, 100 | |
| div $7, $10 | |
| mflo $11 # c = a/100 | |
| addi $10, $0, 19 | |
| div $7, $10 | |
| mflo $12 # a/19 | |
| mul $12, $12, $10 # 19 * (a/19) | |
| sub $12, $7, $12 # n = a - [19 * (a/19)] | |
| addi $13, $0, 25 | |
| addi $14, $11, -17 # c - 17 | |
| div $14, $13 # (c - 17) / 25 | |
| mflo $13 # k = (c - 17) / 25 | |
| addi $17, $0, 4 | |
| addi $15, $0, 3 | |
| sub $16, $11, $13 # (c-k) | |
| div $16, $15 | |
| mflo $15 # (c-k)/3 | |
| mul $16, $10, $12 # (19 * n) | |
| div $11, $17 | |
| mflo $17 # (c/4) | |
| sub $14, $11, $17 # c - c/4 | |
| sub $14, $14, $15 # c - (c/4) - [(c - k)/3] | |
| add $14, $14, $16 | |
| addi $14, $14, 15 # i = c - c/4 - [(c-k)/3] +(19×n) + 15 | |
| # i = i - [30 * (i / 30)] | |
| addi $15, $0, 30 | |
| div $14, $15 | |
| mflo $16 | |
| mul $16, $15, $16 | |
| sub $14, $14, $16 | |
| # i = i - { (i/28) × [1- (i/28)] × [29/(i+1)] × [(21-n)/11] } | |
| addi $15, $0, 21 | |
| sub $15, $15, $12 # 21 - n | |
| addi $16, $0, 11 | |
| div $15, $11 | |
| mflo $15 # [(21-n)/11] | |
| addi $16, $0, 29 | |
| addi $17, $14, 1 | |
| div $16, $17 | |
| mflo $16 # [29/(i+1)] | |
| addi $17, $0, 28 | |
| div $14, $17 | |
| mflo $17 # i/28 | |
| addi $18, $0, 1 | |
| sub $18, $18, $17 # 1 - (i/28) | |
| mul $19, $17, $18 # (i/28) * [1 - i/28] | |
| mul $19, $19, $16 | |
| mul $19, $19, $15 | |
| sub $14, $14, $19 | |
| # j = a + a/4 + i + 2 -c + c/4 | |
| addi $15, $0, 4 | |
| div $7, $15 | |
| mflo $16 #a/4 | |
| div $11, $15 | |
| mflo $17 #c/4 | |
| add $15, $7, $16 | |
| add $15, $15, $14 | |
| addi $15, $15, 2 | |
| sub $15, $15, $11 | |
| add $15, $15, $17 | |
| #j = j - [7×(j/7)] | |
| addi $16, $0, 7 | |
| div $15, $16 | |
| mflo $17 | |
| mul $16, $16, $17 | |
| sub $15, $15, $16 | |
| # l = i - j | |
| sub $16, $14, $15 | |
| # mês = 3 + [(l+40)/44] | |
| addi $8, $16, 40 | |
| addi $18, $0, 44 | |
| div $8, $18 | |
| mflo $8 | |
| addi $8, $8, 3 | |
| # dia = l + 28 - [31×(mês/4)] | |
| addi $17, $0, 4 | |
| div $8, $17 | |
| mflo $17 | |
| addi $18, $0, 31 | |
| mul $17, $18, $17 | |
| addi $9, $16, 28 | |
| sub $9, $9, $17 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment