Sie sind auf Seite 1von 4

UNIVERSIDAD NACIONAL DE COLOMBIA SEDE MEDELLN

FACULTAD DE MINAS
ESCUELA DE MECATRNICA
Asignatura:ARQUITECTURA DE COMPUTADORES
Examen: PRIMER PARCIAL
Nombre del estudiante:
Nombre del docenteHUGO DE JESS MESA YEPES

Grupo: 01
Nota:
Valor: 25%
Documento:
Fecha: Octubre 25 de 2012

Dados los siguientes programas en lenguaje C. transformarlo a lenguaje ensamblador. No es


indispensable tener en cuenta los aspectos de presentacin de los datos.
1. (25%)

2. (25%)

#include <stdio.h>
void main(void){
int n, i = 1, m;
float fact, suma =
printf("Ingrese el
scanf("%d",&n);
do {
fact = 1;
m = i;
while(m > 1){
fact *= m;
m--;
}
suma+=fact;
printf("\t %d!
i++;
}while(i <= n);
printf("\n\tsuma =
}

#include <stdio.h>
#define SIZE 3
void main(void) {
double matriz[SIZE][SIZE];
double vector[SIZE];
double solucion[SIZE];
double sum;
int i,j;
printf("Introduce los datos de la matriz:\n");
for(i=0; i<SIZE ; i++) {
for(j=0; j<SIZE; j++) {
printf("\nElemento (%d,%d): ", (i+1), (j+1));
scanf(" %lf", &matriz[i][j]);
}
}
printf("\n\nIntroduce los datos del vector:\n");
for(i=0; i<SIZE ; i++) {
printf("\nElemento %d: ", (i+1));
scanf("%lf", &vector[i]);
}
for(i=0; i<SIZE; i++) {
sum=0;
for(j=0; j<SIZE; j++) {
sum+=matriz[i][j]*vector[j];
}
solucion[i]=sum;
}
printf("\nEl vector solucion es:\n");
for(i=0; i<SIZE; i++) {
printf("Elemento %d = %lf\n", i+1, solucion[i]);
}
}

0;
valor de n: ");

= %0.f \n",i,fact);

%0.f\n\n",suma);

3. Transformar el siguiente pseudocdigo a un


programa en lenguaje ensamblador (25%)
Pseudocdigo
Inicio
Haga c_num,c_div, num=0, c_mod=0, c_npr=0
,c_pr=0
Para (c_num=0,c_num<=5,c_num++)
Mostrar Digite numero
Capturar num
Para (c_div=1,c_div<=num,c_div++)
si ((num mod c_div)=0) entonces
Haga c_mod=c_mod+1
Fin si
Fin Para
si ((num mod c_div)=0) entonces
Haga c_pr=c_pr+1
Si no
Haga c_npr=c_npr+1
Fin si
Fin Para
Mostrar Cantidad de primos es: ,c_pr
Mostrar Cantidad de no primos es: , c_npr
Fin

4. Elaborar el pseudocdigo del siguiente programa


dado en lenguaje ensamblador (25%)
TITLE XXXXXX
INCLUDE Irvine32.inc
.data
intArray SWORD 0,0,0,0,1,20,35,-12,66,4,0
;intArray SWORD 1,0,0,0
;intArray SWORD 0,0,0,0
;intArray SWORD 0,0,0,1
noneMsg BYTE "A non-zero value was not found",0
.code
main PROC
mov
mov

ebx,OFFSET intArray
ecx,LENGTHOF intArray

cmp
jnz
add
loop
jmp

WORD PTR [ebx],0


found
ebx,2
L1
notFound

L1:

found:
movsx eax,WORD PTR [ebx]
call WriteInt
jmp
quit
notFound:
mov
call

edx,OFFSET noneMsg
WriteString

call
exit

crlf

quit:

main ENDP
END main

UNIVERSIDAD NACIONAL DE COLOMBIA SEDE MEDELLN


FACULTAD DE MINAS
ESCUELA DE MECATRNICA
Asignatura:ARQUITECTURA DE COMPUTADORES
Examen: PRIMER PARCIAL
Nombre del estudiante:
Nombre del docenteHUGO DE JESS MESA YEPES

Grupo: 02
Nota:
Valor: 25%
Documento:
Fecha: Octubre 25 de 2012

Dados los siguientes programas en lenguaje C. transformarlo a lenguaje ensamblador. No es


indispensable tener en cuenta los aspectos de presentacin de los datos.
1. (25%)

2. (25%)

int main(){
int n, num = 2, esPrimo, limite;
while(num<=100){
esPrimo = 1;
n = 2;
limite = (num);
while(n <= limite && esPrimo){
if(num % n == 0) //divisible entre n
esPrimo = 0;
n++;
}
if(esPrimo)
cout << num << " ";
num++;
}
getch();
return 0;
}

/* fichero determin.c */
#include <stdio.h>
#define SIZE 3
void main(void) {
double mat[SIZE][SIZE];
double det;
int i, j;
FILE *fi;
printf("Introduzca los elementos de la mat 3x3:\n");
for (i=0; i<SIZE; i++)
for (j=0; j<SIZE; j++) {
scanf("%lf", &mat[i][j]);
}
det = mat[0][0]*mat[1][1]*mat[2][2];
det += mat[0][1]*mat[1][2]*mat[2][0];
det += mat[1][0]*mat[2][1]*mat[0][2];
det -= mat[0][2]*mat[1][1]*mat[2][0];
det -= mat[0][1]*mat[1][0]*mat[2][2];
det -= mat[0][0]*mat[2][1]*mat[1][2];
printf("La mat introducida es:\n");
for (i=0; i<SIZE; i++) {
for (j=0; j<SIZE; j++)
printf("%8.2lf", mat[i][j]);
printf("\n");
}
printf("\nY su det es: %12.4lf\n", det);
}

3. Transformar el siguiente pseudocdigo a un


programa en lenguaje ensamblador (25%)
Pseudocdigo
Inicio
Haga c_num=0,c_div=1, num=0,
c_mod=0, c_npr=0 , c_pr=0
Mientras que c_num<=5
Mostrar Digite numero
Capturar num
Repetir
si ((num mod c_div)=0) entonces
c_mod=c_mod+1
Fin si
c_div=c_div+1
Hasta que (c_div>num)
si ((num mod c_div)=0) entonces
Haga c_pr=c_pr+1
Si no
Haga c_npr=c_npr+1
Haga c_num=c_num+1
Fin si
Fin mq
Mostrar Cantidad de primos es: ,c_pr
Mostrar Cantidad de no primos es: , c_npr
Fin

4. Elaborar el pseudocdigo del siguiente programa


dado en lenguaje ensamblador (25%)
TITLE XXXXXXX
INCLUDE Irvine32.inc
.data
COUNT = 4
BlueTextOnGray = blue + (lightGray * 16)
DefaultColor = lightGray + (black * 16)
arrayD SDWORD 12345678h,1A4B2000h,3434h,7AB9h
prompt BYTE "Enter a 32-bit signed integer: ",0
.code
main PROC
mov

L1:

mov
mov
call
call
call

Loop

main ENDP
END main

eax,BlueTextOnGray
call SetTextColor
call Clrscr
mov
esi,OFFSET arrayD
mov
ebx,TYPE arrayD
mov
ecx,LENGTHOF arrayD
call
DumpMem
call
Crlf
ecx,COUNT
edx,OFFSET prompt
WriteString
ReadInt
Crlf
call
WriteInt
call
Crlf
call
WriteHex
call
Crlf
call
WriteBin
call
Crlf
call
Crlf
L1
call
WaitMsg
mov
eax,DefaultColor
call
SetTextColor
call
Clrscr
exit

Das könnte Ihnen auch gefallen