You are on page 1of 24

PROYECTO FINAL

ARQUITECTURA DEL COMPUTADOR


INTEGRANTES:
1.
2.
3.
4.

LEANDRO POMA ALANOCA


EDSON RODRIGO RODRGUEZ HUARACHI
DIEGO MAMANI SOLIZ
LEONEL CUENTAS MAMANI

1. RESUMEN
Este proyecto consiste en realizar el manejo de cadenas en lenguaje ensamblador,
primeramente crearemos macros que son un conjunto de instrucciones que nos
ayudaran a optimizar el cdigo posteriormente pasaremos a lo que es la declaracin de
las variables en la seccin de datos, y empezaremos mostrando algunas variables que
simularan una caratula de presentacin para posteriormente pasar al men del proyecto,
en este men veremos las opciones de contar las vocales de una cadena ,comparar si
una cadena es parte de otra, convertir la cadena ingresada en maysculas o minsculas
y la ltima opcin es la de salir del programa.
2. CUERPO DEL INFORME
2.1 INTRODUCCIN
A continuacin detallaremos algunos procedimientos y macros que se utilizo en el
programa
1- Este macro nos permite ver el contenido de una variable que recibe como parmetro
muestra MACRO CADENA
push ax
push dx
mov ah,09h

lea dx,CADENA
INT 21h
pop dx
pop ax
endM:
2- este macro limpia toda la pantalla con fondo negro
LIMPIAR MACRO
MOV AH,06h
MOV BH,00h
MOV AL,00h
MOV CH,00H
MOV CL,00h
MOV DH,22H
MOV DL,4fh
INT 10h
endM
3- este macro posiciona el cursor en una determinada ubicacin y se utilizara solo para
los textos del men del programa
cursorTEXTO MACRO
MOV AH,02H
MOV BH,00H
MOV DX,040AH
INT 10H

ENDM
4- con esta macro solo lo utilizaremos para la cartula
cursor MACRO
MOV AH,02H
MOV BH,00H
MOV DH,01H
MOV DL,02H
INT 10H
ENDM
5- con este macro limpiaremos la pantalla con fondo azul y letras color rojo y es solo
para la caratula
clrscr MACRO
MOV AH,06h
MOV BH,14h
MOV AL,00h
MOV CH,02H
MOV CL,05h
MOV DH,17H
MOV DL,47h
INT 10h
endM
6- este macro limpia la pantalla y pone el fondo rojo y letras color verde
clrscrMenu MACRO

MOV AH,06h
MOV BH,42h
MOV AL,00h
MOV CH,02H
MOV CL,08h
MOV DH,12H
MOV DL,40h
INT 10h
endM
7- este macro permite cerrar la pantalla actual con un tecleo
getch MACRO
MOV AH,07h
INT 21h
endM
8- este procedimiento nos permite revertir el valor de nuestra cadena
rev proc near
mov si,02h
mov cl,tam
rever:
mov bh,auxn[si]
mov cade[si],bh
mov bh,00h
inc si

loop rever
mov cl,tam
mov cade[1],cl
ret
rev endp
9- con este procedimiento copiamos la cadena en otra variable para poder ser revertida
o recuperado
Copia proc near
;copiando a dos variables
mov auxn[1],cl
mov auxcade[1],cl
l:
mov bh,cade[si]
mov auxn[si],bh
mov auxcade[si],bh
mov bh,00h
inc si
loop l
ret
Copia endp
Estos dos procedimientos solo se utilizaran en la opcin 3 del men
3. PROCEDIMIENTO EXPERIMENTAL
a continuacin veremos el cdigo del proyecto

;// macro para ver cadenas


muestra MACRO CADENA
push ax ;// GUARDAR LOS REGISTROS AX Y DX EN LA PILA
push dx ;
mov ah,09h
lea dx,CADENA
INT 21h
pop dx
pop ax ;// RECUPERAR DX Y AX DE LA PILA
endM
;// limpiar la pantalla con fondo negro
LIMPIAR MACRO
MOV AH,06h
MOV BH,00h
MOV AL,00h
MOV CH,00H
MOV CL,00h
MOV DH,22H
MOV DL,4fh
INT 10h
endM
;// cursor para texto
cursorTEXTO MACRO
MOV AH,02H
MOV BH,00H
MOV DX,040AH

INT 10H
ENDM
cursor MACRO
MOV AH,02H
MOV BH,00H
MOV DH,01H
MOV DL,02H
INT 10H
ENDM
;// Pantalla para caratula con fondo celeste y letras rojos
clrscr MACRO
MOV AH,06h
MOV BH,94h
MOV AL,00h
MOV CH,02H
MOV CL,05h
MOV DH,17H
MOV DL,47h
INT 10h
endM
;// pantalla para las opciones del menu con fondo azul y letras verde
clrscrMenu MACRO
MOV AH,06h
MOV BH,12h
MOV AL,00h
MOV CH,02H

MOV CL,08h
MOV DH,12H
MOV DL,40h
INT 10h
endM
;//////////////////////
getch MACRO
MOV AH,07h
INT 21h
endM
;// INICIO DEL PROGRAMA
.MODEL SMALL
.STACK 64
.DATA ;// DECLARACION DE LAS VARIABLES
V0 DB "$"
V1

DB "

>>>>>>>>>>>>>>>>>>>>>>>>> PROYECTO FINAL

<<<<<<<<<<<<<<<<<<<<<<<<<<$"
V2 DB "

\\

/$"

V3 DB "

\\ ===============================

V4 DB "

\\ |=================================|

\ \___ / |

V5 DB "

\\ | UNIVERSIDAD PUBLICA DE EL ALTO |

/- _ `-/ '

V6 DB "

\\ |

V7 DB "

\\ |

V8 DB "

\\ | ARQUITECTURA DEL COMPUTADOR

\\ ---------------------------------

/$"

INGENIERIA DE SISTEMAS
|

// |`

/(

(/\/ \ \ /\

/$"
/$"
/$"

/$"

/$"

$"
V9 DB "

)`

`-^--'`<

'

OO )/

V10 DB "

\\

(_.) _ ) /

/$"

V11 DB "

\\

`.___/`

/$"

V12 DB "

\\ INTEGRANTES:

V13 DB "

\\

V14 DB "

`-----' /

<----.

__ / __ \

\\ 1: LEANDRO POMA ALANOCA

/$"

/$"
<----|====O)))==) \) /====

/$"
V15 DB "

\\ 2: EDSON RODRIGUEZ HUARACHI <----'

`--' `.__,' \

$"
V16 DB "

\\ 3: DIEGO MAMANI SOLIZ

V17 DB "

\\ 4: LEONEL CUENTAS MAMANI

V18 DB "

\\

V19 DB "

\\ PARALEO: 6 " B "

V20 DB "

\\

V21 DB "

\\

|
\

/$"
/

/$"

______( (_ / \______ /$"


,' ,-----' |
`--{__________)

\/ /$"

EL ALTO BOLIVIA

V22

\ /$"

/$"
DB

"

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<><<<<<<<<<<<<<<<<<<<<<<
<<<<<<$"
msg1

db "ingrese cadena : $"

msg2

db "cadena convertida : $"

cade db 50 dup("$")
cade5

db 5 dup("$")

auxcade db 50 dup("$")
auxn

db 50 dup("$")

cadconv db 50 dup("$")
espacio db 20H,"$"
tam

db 0

db 0

titulo DB "

66******************** INICIO ********************$"

linea DB "

66

op1 DB "

66 1.CONTAR VOCALES

op2 DB "

*$"
*$"

66 2.COMPARAR SI UNA CADENA ES PARTE DE OTRA

*$"
op3

DB

"

66 3.CONVERTIR CADENA EN MINUSCULAS O

MAYUSCULAS *$"
op4 DB "
finMenu DB "

66 4.SALIR

*$"

66************************************************$"

escoje DB "

ESCOJA UNA OPCION:_$"

tSalir DB " GRACIAS POR SU TIEMPO :) $"


error DB "*
opc

VUELVA A INTENTAR CON UNA DE LAS OPCIONES $"

DB 0

enter DB 10,13,"$"
;------------------------------------------------------------cantidadA db "

CANTIDAD DE LA VOCAL a => $"

cantidadE db "

CANTIDAD DE LA VOCAL e => $"

cantidadI db "

CANTIDAD DE LA VOCAL i => $"

cantidadO db "

CANTIDAD DE LA VOCAL o => $"

cantidadU db "

CANTIDAD DE LA VOCAL u => $"

a db 0
e db 0
i db 0
o db 0

u db 0
;------------------------------------------------------------.CODE
INICIO:
MOV AX,@DATA
MOV DS,AX
CARATULA: ;// MOSTRAR LA CARATULA
cursor
clrscr
muestra V0
muestra enter
muestra V1
muestra enter
muestra V2
muestra enter
muestra V3
muestra enter
muestra V4
muestra enter
muestra V5
muestra enter
muestra V6
muestra enter
muestra V7
muestra enter
muestra V8

muestra enter
muestra V9
muestra enter
muestra V10
muestra enter
muestra V11
muestra enter
muestra V12
muestra enter
muestra V13
muestra enter
muestra V14
muestra enter
muestra V15
muestra enter
muestra V16
muestra enter
muestra V17
muestra enter
muestra V18
muestra enter
muestra V19
muestra enter
muestra V20
muestra enter
muestra V21

muestra enter
muestra V22
getch
;;;;;;;;;;;;;;;;;;;;;;
clrscr

;;

cursortexto

;;

muestra msg1

;;aqui ingresamos una cadena para ir al menu

mov ah,0ah

;;

lea dx,cade

;;(presionar dos veces enter)

int 21h

;;

getch

,;

;;;;;;;;;;;;;;;;;;;;;;
MENU: ; // MOSTRANDO EL MENU DEL PROGRAMA
LIMPIAR
cursor
clrscrmenu
muestra enter
muestra titulo
muestra enter
muestra linea
muestra enter
muestra op1
muestra enter
muestra linea
muestra enter
muestra op2

muestra enter
muestra linea
muestra enter
muestra op3
muestra enter
muestra linea
muestra enter
muestra op4
muestra enter
muestra linea
muestra enter
muestra finMenu
muestra enter
muestra enter
muestra enter
muestra escoje
getch ;// TECLEAR UNA OPCION
MOV OPC,AL ;//guardar en opc lo que se tecleo
CMP OPC,31h ;// comparar con 1 (pero en hexadecimal)
JGE COMPARAR_OPCIONES: ;// salatar si es mayor o igual
muestra enter
muestra enter
muestra error
getch
JMP MENU ;// volver al menu
;////////////////////////////

COMPARAR_OPCIONES:
CMP OPC,34h ;//comparar con 4 (en hexa)
JL OPCION1 ;// ir a opcion 1 si es menor a 4 (34 en hexa)
JE SALIR

;// si es igual saltar a la opcion de SALIR

muestra enter
muestra enter
muestra error
getch
JMP MENU
;//OPCION #:1 = MUESTRA VOCALES QUE CONTIENE LA CADENA
OPCION1:
CMP OPC,31h
JNE OPCION2 ;// si no es 1 ir a la opcion 2
LIMPIAR

;limpiar pantalla

cursor
clrscrmenu ;limpiar pantalla de menu
;************ A *************
mov ax,00h ;cereamos todos los registros que utlizaremos
mov dx,00h
mov bx,00h
mov si,00h
mov cx,00h

mov si,02h ;inicialisamos el registro SI = 2


mov cl,cade[1] ;guardamos en CL el tamo de la cadena
forA:

;contamos todas las A

mov bh,00h
mov bh,cade[si]
cmp bh,41h
je igualA
cmp bh,61h
je igualA
jmp salirA
igualA:
inc a
salirA:
inc si
loop forA
muestra enter
muestra cantidadA ;mostramos la cantidad de A
mov dl,a
add dl,30h
mov ah,02h
int 21h
;************ E *************
mov ax,00h
mov dx,00h
mov bx,00h
mov si,00h

mov si,02h
mov cl,cade[1]

forE:

;contamos todas las E

mov bh,00h
mov bh,cade[si]
cmp bh,45h
je igualE
cmp bh,65h
je igualE
jmp salirE
igualE:
inc e
salirE:
inc si
loop forE
muestra enter
muestra cantidadE ;mostramos la cantidad de E
mov dl,e
add dl,30h
mov ah,02h
int 21h
;************ I *************
mov ax,00h
mov dx,00h
mov bx,00h
mov si,00h

mov si,02h

mov cl,cade[1]
forI:

;contamos todas las I

mov bh,00h
mov bh,cade[si]
cmp bh,49h
je igualI
cmp bh,69h
je igualI
jmp salirI
igualI:
inc i
salirI:
inc si
loop forI
muestra enter
muestra cantidadI ;mostramos la cantidad de I
mov dl,i
add dl,30h
mov ah,02h
int 21h
;************ O *************
mov ax,00h
mov dx,00h
mov bx,00h
mov si,00h

mov si,02h
mov cl,cade[1]
forO:

;contamos todas las O

mov bh,00h
mov bh,cade[si]
cmp bh,4fh
je igualO
cmp bh,6fh
je igualO
jmp salirO
igualO:
inc o
salirO:
inc si
loop forO
muestra enter
muestra cantidadO ;mostramos la cantidad de O
mov dl,o
add dl,30h
mov ah,02h
int 21h
;*********** U ***************
mov ax,00h
mov dx,00h
mov bx,00h
mov si,00h

mov si,02h
mov cl,cade[1]
forU:

;contamos todas las U

mov bh,00h
mov bh,cade[si]
cmp bh,55h
je igualU
cmp bh,75h
je igualU
jmp salirU
igualU:
inc u
salirU:
inc si
loop forU
muestra enter
muestra cantidadU ;mostramos la cantidad de U
mov dl,u
add dl,30h
mov ah,02h
int 21h
getch
JMP MENU ;volvemos al menu de inicio
;//OPCION # 2: COMPARAR SI UNA CADENA ES SUBCADENA DE OTRA
OPCION2:

CMP OPC,32h
JNE OPCION3
;;;;;;;;;;;;;;;;;;;;;;
clrscrmenu

;;

cursortexto

;;

muestra msg1

;;aqui ingresamos una cadena de 5 caracteres alo sumo

mov ah,0ah

;;para hacer la comparacion con la primera cadena (cade)

lea dx,cade5

;:

int 21h

;;

;;;;;;;;;;;;;;;;;;;;;;
getch
JMP MENU
;//OPCION #:3 = CONVERTIR CADENA EN MINUSCULAS O MAYUSCULAS
OPCION3:
muestra enter
mov si,02H
mov ch,00h
mov cl,cade[1] ;cl tiene el pamao de la cadena (cade)
mov tam ,cl ;gurdamos en TAM el tamao de la cadena
call copia ;llamamos al procedimiento copia
mov si,02h
mov ch,00h
mov cl,auxcade[1]
r:
mov bh,auxcade[si]
cmp bh,40h

jg may
jmp menor
p:
add bh,20h
jmp f
may:
cmp bh,5bh
jl p
menor:
sub bh,20h
f:
mov cadconv[si],bh
mov bh,00H
ADD SI ,01h ;incrementa en una unidad

loop r
call rev;llamar al procedimiento rev para revertir
MOSTRAR:
LIMPIAR
clrscrmenu
cursorTEXTO
muestra cade+2 ;mostrar cadena original
MOV AH,02H
MOV BH,00H
MOV DX,060AH
INT 10H

muestra cadconv+2 ;mostramos cadena convertida


getch
JMP MENU
;//////////////// OPCION #:4 SALIR DEL PROGRAMA
SALIR:
clrscrmenu
cursortexto
muestra tSalir
MOV AH,02H
MOV DL,02H
INT 21H
getch
jmp fin
;///////////////Fin del programa
FIN:
mov ah,4ch
int 21h
;/////////////////procedimiento para revertir una cadena
rev proc near
mov si,02h
mov cl,tam
rever:
mov bh,auxn[si]
mov cade[si],bh
mov bh,00h
inc si

loop rever
mov cl,tam
mov cade[1],cl
ret
rev endp

Copia proc near ;procedimiento para copiar la cadena en dos variables


mov auxn[1],cl
mov auxcade[1],cl
l:
mov bh,cade[si]
mov auxn[si],bh
mov auxcade[si],bh
mov bh,00h
inc si
loop l
ret
Copia endp
end INICIO

You might also like