TRABAJO INDIVIDUAL FINAL ARQUITECTURA DE COMPUTADORES 301302A_360
JOHAN ELVIS LASSO GALEANO Código: 80919291
GRUPO: 301302_38
TUTOR: ANYELO GERLEY QUINTERO
UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA UNAD ESCUELA DE CIENCIAS BÁSICAS TECNOLOGÍA E INGENIERÍA INGENIERÍA DE SISTEMAS MAYO 2017
INTRODUCCIÓN
En el siguiente trabajo se encontrará el desarrollo de un código en lenguaje ensamblador donde implementaremos los conocimientos adquiridos en e l semestre, este que permite leer los datos del autor y realizar las operaciones matemáticas básicas (Suma, Resta, Multiplicación y División) además verificar si un número es par e impar.
OBJETIVOS
Aplicar y apropiarse de los conceptos fundamentados en las lecturas de las unidades del curso arquitectura de computadores. crear un prototipo funcional en lenguaje Ensamblador donde pongamos en práctica los conocimientos adquiridos.
Realice el prototipo funcional en lenguaje Ensamblador, que incluya el siguiente menú de opciones: MENÚ 1. Datos del autor 2. Suma de dos números 3. Resta de dos números 4. Multiplicación de dos números 5. División de dos números 6. Validar si un número es positivo o negativo
CODIGO: Data segment mens1 DB 13,10,13,10," MENU --EXAMEN FINAL-- $" mens2 DB 13,10,13,10,"1. DATOS DEL AUTOR $" mens3 DB 13,10,13,10,"JOHAN ELVIS LASSO GALEANO",13,10,"CODIGO 80919291",13,10,"UNIVERSIDAD NACIONAL Y A DISTANCIA UNAD",13,10,"MAYO 2017 $" mens4 DB 13,10,"2. SUMA DE DOS NUMEROS $" mens5 DB 13,10,"3. RESTA DE DOS NUMEROS $" mens6 DB 13,10,"4. MULTIPLICACION DE DOS NUMEROS $" mens7 DB 13,10,"5. DIVISION DE DOS NUMEROS $" mens8 DB 13,10,"6. VALIDAR SI EL NUMERO ES POSITIVO O NEGATIVO $" mens9 DB 13,10,"7. SALIR $" mens10 DB 13,10,13,10,"SELECCIONE UNA OPCION: $" mens11 DB 13,10,13,10,"INGRESE NUMERO: $", mens12 DB 13,10,"EL RESULTADO ES: $" mens13 DB "COCIENTE = $" mens14 DB "RESIDUO = $" result DB 0 quotient DB 0 residue DB 0 numero DB 0 signox DB 0 r2 DB ? ac DB 0 Data ends
pila segment stack DW 256 DUP (?) pila ends code segment menu proc far assume cs:code,ds:data,ss:pila push ds xor ax,ax push ax mov ax,data mov ds,ax xor dx,dx mov ax,0600h
mov ah,09h mov dx,offset mens1 int 21h mov ah,09h mov dx,offset mens2 int 21h mov ah,09h mov dx,offset mens4 int 21h mov ah,09h mov dx,offset mens5 int 21h mov ah,09h mov dx,offset mens6 int 21h
mov ah,09h mov dx,offset mens7 int 21h mov ah,09h mov dx,offset mens8 int 21h mov ah,09h mov dx,offset mens9 int 21h mov ah,09h mov dx,offset mens10 int 21h ;lee mov ah,01h int 21h ;ajustar el teclado xor ah,ah sub al,30h mov cx,2 ;verifica opcion cmp al,1 jz autor cmp al,2 jz suma cmp al,3 jz resta cmp al,4 jz mult cmp al,5 jz divi
cmp al,6 jz posneg cmp al,7 jz fin autor: mov ah,09h mov dx,offset mens3 int 21h jmp menu suma: mov ah,09h mov dx,offset mens11 int 21h ;lee teclado mov ah,01h int 21h ;verificar si es negativo cmp al,2dh je signo ;ajustar teclado sub al,30h add result,al jmp return1
signo: mov ah,01h int 21h sub al,30h neg al add result,al je return1
return1: loop suma imp1: cmp result,00 jl imp2
mov ah,02h mov dl,10 int 21h mov ah,02h mov dl,13 int 21h mov ah,09h mov dx,offset mens12 int 21h jmp imprime
imp2: neg result
mov ah,02h mov dl,10 int 21h mov ah,02h mov dl,13 int 21h mov ah,09h mov dx,offset mens12 int 21h mov ah,02h mov dl,'-' int 21h jmp imprime imprime:
mov ah,0 mov al,result mov cl,10 div cl add al,30h add ah,30h; pasa a decimal mov bl,ah mov dl,al mov ah,02h int 21h mov dl,bl mov ah,02h int 21h mov cx,2 jmp menu resta: mov ah,09h mov dx,offset mens11 int 21h ;lee teclado mov ah,01h int 21h ;verificando si es negativo cmp al,2dh je signor
sub al,30h cmp cx,2 je etiqueta1 sub result,al jmp return2
etiqueta1: mov result,al jmp return2 signor: mov ah,01h int 21h sub al,30h neg al cmp cx,2 je etiqueta1 sub result,al je return2 return2: loop resta jmp imp1 mult: mov ah,09h mov dx,offset mens11 int 21h ;lee teclado mov ah,01h int 21h ;verificando si es negativo cmp al,2dh je signom sub al,30h cmp cx,2 je etiqueta2 mov ah,0 mul result jmp return3 etiqueta2: mov result,al jmp return3
signom: mov ah,01h int 21h sub al,30h neg al cmp cx,2 je etiqueta2 mov ah,0 mul result jmp return3 return3: loop mult mov result,al jmp imp1 mov signox,0 posneg: mov ah,09h mov dx,offset mens11 int 21h ;lee teclado mov ah,01h int 21h ;verificar si es negativo cmp al,2dh je signo jmp menu divi: mov ah,09h mov dx,offset mens11 int 21h ;lee teclado
mov ah,01h int 21h ;verificando si es negativo cmp al,2dh je signod sub al,30h cmp cx,2 je etiqueta3 cmp al,0 mov ah,0 mov numero,al mov al,result div numero jmp return4 etiqueta3: mov result,al jmp return4 signod: mov ah,01 int 21h sub al,30h inc signox cmp cx,2 je etiqueta3 mov ah,0 mov numero,al mov al,result div numero jmp return4 return4:loop divi mov quotient,al mov residue,ah mov result,al jmp imp3 imp3:
mov ah,02h mov dl,10 int 21h mov ah,02h mov dl,13 int 21h mov ah,09h mov dx,offset mens12 int 21h jmp imprimedivi imprimedivi: mov al,result mov ch,30h add al,ch add ah,ch mov bl,ah mov ah,9 mov dx,offset mens13 int 21h cmp signox,1 jz cambio jmp termina cambio: mov dl,"-" mov ah,02h int 21h mov signox,0 termina: mov dx,0 add quotient,30h mov dl,quotient mov ah,02h int 21h
mov ah,9 mov dx,offset mens14 int 21h mov dx,0 add residue,30h mov dl,residue mov ah,02h int 21h jmp menu fin: ret menu endp code ends end menu
Pantallazos:
CONCLUSIONES Gracias a la elaboración de este curso se ha implementado un código en lenguaje ensamblador que permite mostrar un menú muy personalizado como lo indico la guía de actividades. Finalmente, con esta actividad final se afianzarán los temas y se resolverán las dudas adquiridas en cualquier tema de curso.
BIBLIOGRAFÍA
Vega Jesús E (2008), Modulo Arquitectura de computadores, UNAD 2000 Silvina Ferradal (2000) Departamento de Sistemas e Informática, Conceptos básicos sobre la programación en Assembler.