Last active
December 1, 2017 22:39
-
-
Save ovictoraurelio/1ce9d99588310302a1c16f58d9903321 to your computer and use it in GitHub Desktop.
Códigos de resolução de provas de IHS
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
; ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ | |
; ♥ | |
; ♥ | |
; ♥ @author ovictoraurelio | |
; ♥ @github http://github.com/ovictoraurelio | |
; ♥ @website http://victoraurelio.com | |
; ♥ | |
; ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ | |
SECTION .data | |
raio: dq 4.0 | |
altura: dq 3.0 | |
teste: db "Calculado: %f", 10, 0, | |
SECTION .bss | |
vol: resq 1 | |
SECTION .text | |
global main | |
extern printf | |
main: | |
finit | |
fldpi ; empilha PI | |
fld qword[raio] ; empilha o raio | |
fmul st0,st0 ; calcula e empilha: raio^2 | |
fmulp st1,st0 ; calcula e empilha: PI * raio^2 e desempilha PI | |
fld qword[altura] ; empilha altura | |
fmulp st1,st0 ; calcula e empilha: altura * PI * raio^2 e desempilha antigo ST0 | |
mov eax, 3 ; armazena o inteiro 3 em eax | |
push eax ; push na memória pq fld só funciona com memória | |
fild dword[esp] ; empilha o inteiro 3 | |
fdivp st1, st0 ; calcula e empilha: altura * PI * raio^2 / 3 | |
fstp qword[vol] ; armazena na memoria | |
push dword[vol + 4] | |
push dword[vol] | |
push dword teste | |
call printf | |
pop eax | |
pop eax | |
pop eax | |
popa | |
mov eax, 1 | |
mov ebx, 0 | |
int 80h |
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
// ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ | |
// ♥ | |
// ♥ | |
// ♥ @author ovictoraurelio | |
// ♥ @github http://github.com/ovictoraurelio | |
// ♥ @website http://victoraurelio.com | |
// ♥ | |
// ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <omp.h> | |
#define N 10 | |
int main(){ | |
double vetor[N]; | |
int i; | |
#pragma omp parallel | |
{ | |
#pragma omp single | |
{ | |
printf("\nThreads nos calculos de fibonnaci: "); | |
vetor[0] = 0; | |
vetor[1] = 1; | |
for(i=2; i<N; i++){ | |
vetor[i] = vetor[i-1] + vetor[i-2]; | |
printf("|%d|", omp_get_thread_num()); | |
} | |
} | |
/** Código para calcular sequencia de Fibonnaci */ | |
printf("\nThreads nos calculos de potencia: "); | |
#pragma omp for | |
for (i=0; i<N; i++){ | |
printf("|%d|", omp_get_thread_num()); | |
vetor[i] = pow(vetor[i],i); | |
} | |
} | |
printf("\nVetor eh igual: \n"); | |
for(i=0; i<N; i++){ | |
printf("%.2f\n", vetor[i]); | |
} | |
printf("\n"); | |
return 0; | |
} |
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
// ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ | |
// ♥ | |
// ♥ | |
// ♥ @author ovictoraurelio | |
// ♥ @github http://github.com/ovictoraurelio | |
// ♥ @website http://victoraurelio.com | |
// ♥ | |
// ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ ♥ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <omp.h> | |
#define N 10 | |
int main(){ | |
double vetor[N]; | |
int i; | |
#pragma omp parallel shared(vetor) private(i) | |
{ | |
printf("\nThreads nos calculos de fibonnaci: "); | |
vetor[0] = 0; | |
vetor[1] = 1; | |
for(i=2; i<N; i++){ | |
vetor[i] = vetor[i-1] + vetor[i-2]; | |
printf("|%d|", omp_get_thread_num()); | |
} | |
/** Código para calcular sequencia de Fibonnaci */ | |
printf("\nThreads nos calculos de potencia: "); | |
#pragma omp barrier | |
#pragma omp for | |
for (i=0; i<N; i++){ | |
printf("|%d|", omp_get_thread_num()); | |
vetor[i] = pow(vetor[i],i); | |
} | |
} | |
printf("\nVetor eh igual: \n"); | |
for(i=0; i<N; i++){ | |
printf("%.2f\n", vetor[i]); | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment