Programa que realice la multiplicación de dos valores ingresados por el teclado
Codigo:
.model small ;se define el modelo de memoria
.stack ;se define el tamano de la pila
datos segment ;se define las variables
nombre db, 13,10, "Multiplicacion de dos numeros ingresados por teclado",13,10,13,10,'$' ;nombre del programa
mensaje1 db "Ingrese el primer numero:",13,10,'$' ;primer numero de la multiplicacion
mensaje2 db "Ingrese el segundo numero:",13,10,'$' ;segundo numero de la multiplicacion
mensaje3 db "El resultado de la multiplicacion es: ",'$' ;resultado en pantalla
suma db 0
n1 db 0
n2 db 0
byteh db 0
bytel db 0
salto db " ",13,10,'$' ;salto de fila
datos ends
codigo segment ;comienzo de codigo
assume cs:codigo, ds: datos
inicio proc far
mov ax,datos ;direccionamiento
mov ds,ax ;aqui es donde se guarda
;Limpiar Pantalla
mov ah, 00
mov al, 03h
int 10h
;Inicializacion de resgistros en 0
mov ah,02h
mov dl,00
int 10h
mov ah, 09h ;lee el mensaje
lea dx,nombre
int 21h
;Instrucciones para la realizacion de la multiplicacion.
mov ah,09h
lea dx,mensaje1 ;mensaje de solicitud del primer numero
int 21h
mov ah,01h ;lee los caracteres del teclado
int 21h
;Conversion del numero.
sub al,30h ;hace la conversion ascii
mov n1,al ; se pasaa la variable n1
int 21h
mov ah,09h ;impresion de caracteres
lea dx, salto ;saltar de fila
int 21h
mov ah,09h
lea dx, mensaje2 ;mensaje del segundo numero
int 21h
mov ah,01h ;leer y mostrar numero digitado
int 21h
sub al,30h ;conversion ASCII
mov n2,al ;se pasa ala variable n2
int 21h
;Operacion de sumas sucesivas
mov cl,n2
sumar:
mov al,n1 ;movemos el registro al a el valor del numero 1
add al,suma ;sumamos a al el valor de la suma
mov suma,al ;movemos a suma el valor del resultado
loop sumar
mov ah, 09h ;impresion de caracteres
lea dx, mensaje3 ;impresion del mensaje 3
int 21h
mov al,suma
aam ;corrige el resultado de la multiplicacion de datos ASCII en el registro ax
mov bytel,al
mov byteh,ah
mov ah,02h
mov dl,byteh
add dl,30h
int 21h
mov dl,bytel
add dl,30h
int 21h
mov ah,09h ;ipresion de caracteres
lea dx,salto ;salto de fila
int 21h
salir: ;retorna el mando al DOS
mov ax, 4c00h
int 21h
inicio endp
end inicio
martes, 20 de marzo de 2018
Verificación de texto en una cadena
Código:
org 100h
mov si, 0
comienzo:
mov al,msg2[0]
cmp msg[si],"$"
jz final
cmp msg[si], al
jne seguir
mov di, 1
comprobar:
mov al, msg2[di]
mov bx, di
cmp msg[si+bx], al
jne seguir
inc di
cmp msg2[di],"$"
jz resultado
loop comprobar
seguir:
inc si
loop comienzo
resultado:
mov dx, offset msg3
mov ah, 9
int 21h
final:
ret
msg db "tecnologico$"
msg2 db "tec$"
msg3 db "si se encuentran$"
Código:
org 100h
mov si, 0
comienzo:
mov al,msg2[0]
cmp msg[si],"$"
jz final
cmp msg[si], al
jne seguir
mov di, 1
comprobar:
mov al, msg2[di]
mov bx, di
cmp msg[si+bx], al
jne seguir
inc di
cmp msg2[di],"$"
jz resultado
loop comprobar
seguir:
inc si
loop comienzo
resultado:
mov dx, offset msg3
mov ah, 9
int 21h
final:
ret
msg db "tecnologico$"
msg2 db "tec$"
msg3 db "si se encuentran$"
Programa que multiplica 2 números en EMU8086
Codigo:
.model small ;Modelo de memoria
.stack
.data ;Definicion de datos(variables), donde se almacenara informacion
.code
;Variables del primer numero ingresado
unidades_n1 db ?
decenas_n1 db ?
;Variables del segundo numero ingresado
unidades_n2 db ?
decenas_n2 db ?
;Variables temporales para los resultados de la primera multiplicacion
res_temp_dec_n1 db ?
res_temp_cen_n1 db ?
;Variables temporales paara los resultados de la segunda multiplicacion
res_temp_dec_n2 db ?
res_temp_cen_n2 db ?
;Variables para los resultados
res_unidades db ?
res_decenas db ?
res_centenas db ?
res_uni_millar db ?
;Variable de acarreo en multiplicacion
acarreo_mul db 0
;Variable de acarreo en suma
acarreo_suma db 0
.startup
;cls
mov ah,00h ;Function(Set video mode)
mov al,03 ;Mode 80x25 8x8 16
int 10h ;Interruption Video
mov ah,01h ;Function(character read)
int 21h ;Interruption DOS functions
sub al,30h ;ajustamos valores
mov decenas_n1,al ;[chr1].chr2 * chr3 = ac.r1.r2
mov ah,01h ;Function(character read)
int 21h ;Interruption DOS functions
sub al,30h ;Ajustamos valores
mov unidades_n1,al ;chr1.[chr2] * chr3 = ac.r1.r2
mov ah,02h ;Function(character to send to standard output)
mov dl,'*' ;Character to show
int 21h
mov ah,01h ;Function(Read character)
int 21h ;Interruption DOS Functions
sub al,30h ;Transform(0dec = 30hex)
mov decenas_n2,al ;chr1.chr2 * [chr3] = ac.r1.r2
mov ah,01h ;Function(Read character)
int 21h ;Interruption DOS Functions
sub al,30h ;Transform(0dec = 30hex)
mov unidades_n2,al
mov ah,02h ;Character to send to standar output
mov dl,'=' ;
int 21h ;Interruption DOS functions
;Realizamos las operaciones
;Primera multiplicacion ; Explicacion utilizando la multiplicacion de 99*99 ->(n1*n2)
mov al,unidades_n1 ; al=9
mov bl,unidades_n2 ; bl=9
mul bl ; 9*9=81 -> (al=81)
mov ah,00h ;
AAM ; Separa el registro ax en su parte alta y baja
mov acarreo_mul,ah ; acarreo_mul = 8
mov res_unidades,al ; res_unidades= 1 -> Reultado de unidades
;Segunda multiplicacion
mov al,decenas_n1 ; al=9
mov bl,unidades_n2 ; bl=9
mul bl ; 9*9=81 -> (al=81)
mov res_temp_dec_n1,al ; res_temp_dec_n1= 81
mov bl,acarreo_mul ; bl= 8
add res_temp_dec_n1,bl ; res_temp_dec_n1= 81+8= 89
mov ah,00h ;
mov al,res_temp_dec_n1 ; al= 89
AAM ; Separa el registro ax en su parte alta y baja
mov res_temp_cen_n1,ah ; res_temp_cen_n1= 8
mov res_temp_dec_n1,al ; res_temp_dec_n1= 9
;Tercera multiplicacion ; Resultado actual = 000>1
mov al,unidades_n1 ; al= 9
mov bl,decenas_n2 ; bl= 9
mul bl ; 9*9=81 -> (al=81)
mov ah,00h ;
AAM ; Separa el registro ax en su parte alta y baja
mov acarreo_mul,ah ; acarreo_mul= 8
mov res_temp_dec_n2,al ; res_temp_dec_n2= 1
;
mov bl, res_temp_dec_n1 ; bl= 9
add res_temp_dec_n2,bl ; res_temp_dec_n2= 1+9= 10
mov ah,00h ;
mov al, res_temp_dec_n2 ; al = 10
AAM ; Separa el registro ax en su parte alta y baja
mov acarreo_suma, ah ; acarreo_suma = 1
mov res_decenas,al ; res_decenas = 0 -> Reultado de decenas
;Tercera multiplicacion ; Resultado actual = 00>01
mov al,decenas_n1 ; al= 9
mov bl,decenas_n2 ; bl= 9
mul bl ; 9*9=81 -> (al=81)
mov res_temp_cen_n2,al ; res_temp_cen_n2= 81
mov bl,acarreo_mul ; bl= 8
add res_temp_cen_n2,bl ; res_temp_cen_n2= 89
mov ah,00h ;
mov al,res_temp_cen_n2 ; al= 89
AAM ; Separa el registro ax en su parte alta y baja
mov res_uni_millar,ah ; res_uni_millar = 8
mov res_temp_cen_n2,al ; res_temp_cen_n2= 9
;
mov bl, res_temp_cen_n1 ; bl= 8
add res_temp_cen_n2, bl ; res_temp_cen_n2= 17
mov bl, acarreo_suma ; bl= 1
add res_temp_cen_n2,bl ; res_temp_cen_n2= 17+1= 18
mov ah,00h ;
mov al,res_temp_cen_n2 ; al= 18
AAM ;
mov acarreo_suma,ah ; acarreo_suma= 1
mov res_centenas,al ; res_centenas= 8 -> Resultado de centenas
; Resultado actual= 0>801
mov bl, acarreo_suma ; bl= 1
add res_uni_millar, bl ; res_uni_millar= 8+1= 9 -> Resultado de unidades de millar
; Reultado actual 9801
;Mostramos resultados
mov ah,02h
mov dl,res_uni_millar
add dl,30h
int 21h
mov ah,02h
mov dl,res_centenas
add dl,30h
int 21h
mov ah,02H
mov dl,res_decenas
add dl,30h
int 21h
mov ah,02H
mov dl,res_unidades
add dl,30h
int 21h
.exit
end
Codigo:
.model small ;Modelo de memoria
.stack
.data ;Definicion de datos(variables), donde se almacenara informacion
.code
;Variables del primer numero ingresado
unidades_n1 db ?
decenas_n1 db ?
;Variables del segundo numero ingresado
unidades_n2 db ?
decenas_n2 db ?
;Variables temporales para los resultados de la primera multiplicacion
res_temp_dec_n1 db ?
res_temp_cen_n1 db ?
;Variables temporales paara los resultados de la segunda multiplicacion
res_temp_dec_n2 db ?
res_temp_cen_n2 db ?
;Variables para los resultados
res_unidades db ?
res_decenas db ?
res_centenas db ?
res_uni_millar db ?
;Variable de acarreo en multiplicacion
acarreo_mul db 0
;Variable de acarreo en suma
acarreo_suma db 0
.startup
;cls
mov ah,00h ;Function(Set video mode)
mov al,03 ;Mode 80x25 8x8 16
int 10h ;Interruption Video
mov ah,01h ;Function(character read)
int 21h ;Interruption DOS functions
sub al,30h ;ajustamos valores
mov decenas_n1,al ;[chr1].chr2 * chr3 = ac.r1.r2
mov ah,01h ;Function(character read)
int 21h ;Interruption DOS functions
sub al,30h ;Ajustamos valores
mov unidades_n1,al ;chr1.[chr2] * chr3 = ac.r1.r2
mov ah,02h ;Function(character to send to standard output)
mov dl,'*' ;Character to show
int 21h
mov ah,01h ;Function(Read character)
int 21h ;Interruption DOS Functions
sub al,30h ;Transform(0dec = 30hex)
mov decenas_n2,al ;chr1.chr2 * [chr3] = ac.r1.r2
mov ah,01h ;Function(Read character)
int 21h ;Interruption DOS Functions
sub al,30h ;Transform(0dec = 30hex)
mov unidades_n2,al
mov ah,02h ;Character to send to standar output
mov dl,'=' ;
int 21h ;Interruption DOS functions
;Realizamos las operaciones
;Primera multiplicacion ; Explicacion utilizando la multiplicacion de 99*99 ->(n1*n2)
mov al,unidades_n1 ; al=9
mov bl,unidades_n2 ; bl=9
mul bl ; 9*9=81 -> (al=81)
mov ah,00h ;
AAM ; Separa el registro ax en su parte alta y baja
mov acarreo_mul,ah ; acarreo_mul = 8
mov res_unidades,al ; res_unidades= 1 -> Reultado de unidades
;Segunda multiplicacion
mov al,decenas_n1 ; al=9
mov bl,unidades_n2 ; bl=9
mul bl ; 9*9=81 -> (al=81)
mov res_temp_dec_n1,al ; res_temp_dec_n1= 81
mov bl,acarreo_mul ; bl= 8
add res_temp_dec_n1,bl ; res_temp_dec_n1= 81+8= 89
mov ah,00h ;
mov al,res_temp_dec_n1 ; al= 89
AAM ; Separa el registro ax en su parte alta y baja
mov res_temp_cen_n1,ah ; res_temp_cen_n1= 8
mov res_temp_dec_n1,al ; res_temp_dec_n1= 9
;Tercera multiplicacion ; Resultado actual = 000>1
mov al,unidades_n1 ; al= 9
mov bl,decenas_n2 ; bl= 9
mul bl ; 9*9=81 -> (al=81)
mov ah,00h ;
AAM ; Separa el registro ax en su parte alta y baja
mov acarreo_mul,ah ; acarreo_mul= 8
mov res_temp_dec_n2,al ; res_temp_dec_n2= 1
;
mov bl, res_temp_dec_n1 ; bl= 9
add res_temp_dec_n2,bl ; res_temp_dec_n2= 1+9= 10
mov ah,00h ;
mov al, res_temp_dec_n2 ; al = 10
AAM ; Separa el registro ax en su parte alta y baja
mov acarreo_suma, ah ; acarreo_suma = 1
mov res_decenas,al ; res_decenas = 0 -> Reultado de decenas
;Tercera multiplicacion ; Resultado actual = 00>01
mov al,decenas_n1 ; al= 9
mov bl,decenas_n2 ; bl= 9
mul bl ; 9*9=81 -> (al=81)
mov res_temp_cen_n2,al ; res_temp_cen_n2= 81
mov bl,acarreo_mul ; bl= 8
add res_temp_cen_n2,bl ; res_temp_cen_n2= 89
mov ah,00h ;
mov al,res_temp_cen_n2 ; al= 89
AAM ; Separa el registro ax en su parte alta y baja
mov res_uni_millar,ah ; res_uni_millar = 8
mov res_temp_cen_n2,al ; res_temp_cen_n2= 9
;
mov bl, res_temp_cen_n1 ; bl= 8
add res_temp_cen_n2, bl ; res_temp_cen_n2= 17
mov bl, acarreo_suma ; bl= 1
add res_temp_cen_n2,bl ; res_temp_cen_n2= 17+1= 18
mov ah,00h ;
mov al,res_temp_cen_n2 ; al= 18
AAM ;
mov acarreo_suma,ah ; acarreo_suma= 1
mov res_centenas,al ; res_centenas= 8 -> Resultado de centenas
; Resultado actual= 0>801
mov bl, acarreo_suma ; bl= 1
add res_uni_millar, bl ; res_uni_millar= 8+1= 9 -> Resultado de unidades de millar
; Reultado actual 9801
;Mostramos resultados
mov ah,02h
mov dl,res_uni_millar
add dl,30h
int 21h
mov ah,02h
mov dl,res_centenas
add dl,30h
int 21h
mov ah,02H
mov dl,res_decenas
add dl,30h
int 21h
mov ah,02H
mov dl,res_unidades
add dl,30h
int 21h
.exit
end
Programa letras de colores en EMU8086
OS EQU 10H
DOS EQU 21H
FIN EQU 4C00H
.DATA
TITULO DB 'FANY ESQUIVEL :'
COLORES DB 5BH
DB 5FH
DB 3DH
DB 5FH
DB 00H
DB 5BH
DB 0F0H
DB 05DH
DB 09FH
DB 03BH
DB 09FH
DB 00H
DB 08AH
DB 01BH
.CODE
INICIO PROC NEAR:
MOV AX, @DATA
MOV DS, AX
;Esta parte de aqui no es necesaria
INT BIOS
MOV CX, 15
BUCLE:
;Ponemos esto para no agarrar basura
MOV DX,SI
ADD DX,35 ;Columna
MOV DH, 12 ;Renglon
CALL COLOCA
MOV AL, [SI+OFFSET TITULO]
MOV BL, [SI+OFFSET COLORES]
CALL COLOR
INC SI
LOOPNZ BUCLE
MOV AH, 0
INT DOS
CALL COLOCA
MOV AX, FIN
INT DOS
COLOR PROC
MOV AH, 9
INT BIOS
RET
COLOCA PROC
MOV AH,2
INT BIOS
RET
END INICIO
OS EQU 10H
DOS EQU 21H
FIN EQU 4C00H
.DATA
TITULO DB 'FANY ESQUIVEL :'
COLORES DB 5BH
DB 5FH
DB 3DH
DB 5FH
DB 00H
DB 5BH
DB 0F0H
DB 05DH
DB 09FH
DB 03BH
DB 09FH
DB 00H
DB 08AH
DB 01BH
.CODE
INICIO PROC NEAR:
MOV AX, @DATA
MOV DS, AX
;Esta parte de aqui no es necesaria
INT BIOS
MOV CX, 15
BUCLE:
;Ponemos esto para no agarrar basura
MOV DX,SI
ADD DX,35 ;Columna
MOV DH, 12 ;Renglon
CALL COLOCA
MOV AL, [SI+OFFSET TITULO]
MOV BL, [SI+OFFSET COLORES]
CALL COLOR
INC SI
LOOPNZ BUCLE
MOV AH, 0
INT DOS
CALL COLOCA
MOV AX, FIN
INT DOS
COLOR PROC
MOV AH, 9
INT BIOS
RET
COLOCA PROC
MOV AH,2
INT BIOS
RET
END INICIO
lunes, 5 de marzo de 2018
Programa de menú en pantalla
Código en TURBO
Pila segment stack 'stack' ;Segmento de la pila
db 100h dup (?)
Pila ends
datos segment
titulo db 13,10,'MENU PARA CAMBIAR EL FONDO DE PANTALLA ',13,10,'$'
mensaje db 'Presione ENTER para color AQUA ',13,10,'Presione 1 para color AZUL ' ,13,10,'Presione 2 para color MORADO ',13,10,'Presione 3 para color VERDE',13,10,'Presione 4 para color ROJO ',13,10,'Presione 5 para color NARANJA ',13,10,'Para SALIR',' Presione cualquier tecla',13,10,'$'
datos ends
codigo segment ;segmento de codigo
assume cs:codigo, ss:pila, ds:datos
Inicio:
mov ah,0
mov al,3h ; Modo Texto
int 10h ; Interrupcion de Video
mov ax,0600h ; Limpiar Pantalla
mov bh,0fh ; O Color de fondo negro, el color de letra blanco
mov cx,0000h
mov dx,184Fh
int 10h
mov ah,02h
mov bh,00
mov dh,00
mov dl,00
int 10h
;****************************** MOSTRAR MENSAJE
mov ax,datos
mov ds,ax
lea dx,titulo
mov ah,9h
int 21h
lea dx,mensaje
mov ah,9h
int 21h
;****************************** CAPTURA DE TECLAS
mov ah,08 ; Pausa y captura de datos db espera que el usuario presiona una tecla
int 21h
cmp al,13 ; Verifica al presionar ENTER, el cual tiene un codigo ascii 13 en decimal
je llamarAqua ; Salto Condicional jump equals opcion 1 saltar si es igual a la opcion 1
cmp al,49 ; Verifica al presionar 1, el cual tiene un codigo ascii 49 en decimal
je llamarAzul
cmp al,50 ; Ascii 50 = numero 2 compara lo que tiene el regisro ah con el ascii 50 en el reg a1
je llamarMorado ; 2 TIENE UN CODIGO ASCCI 50 EN DECIMAL
cmp al,51
je llamarverde ;3 TIENE UN CODIGO ASCCI 51 EN DECIMAL
cmp al,52
je llamarrojo ;4 TIENE UN CODIGO ASCCI 52 EN DECIMAL
cmp al,53
je llamarnaranja ;5 TIENE UN CODIGO ASCCI 53 EN DECIMAL
jmp fin ; Si no escoge ni ENTER ni 2, Sale del programa
fin: ; Saca el mensaje por pantalla
mov ax,4c00h
int 21h
llamarAqua:
CALL AQUAPROC
llamarAzul:
CALL AZULPROC
llamarMorado:
CALL MORADOPROC
llamarverde:
CALL VERDEPROC
llamarrojo:
CALL ROJOPROC
llamarnaranja:
CALL NARANJAPROC
;******************************
AQUAPROC PROC NEAR
mov ah,0
mov al,3h ; Modo Texto
int 10h ; Interrupcion de video
mov ax,0600h ; Limpiar Pantalla
mov bh,0fh ; Color de fondo negro, f color de letra blanco
mov cx,0000h
mov dx,184Fh
int 10h
mov ah,02h
mov bh,00
mov dh,00
mov dl,00
int 10h
mov ah,06h
mov bh,3fh ;2fh VERDE COLOR AQUA 3,,1 AZUL
mov cx,0000h
mov dx,184fh
int 10h
mov ax,4c00h
int 21h
RET
AQUAPROC ENDP
;*****************************************
AZULPROC PROC NEAR
mov ah,06h
mov bh,1fh ;2fh VERDE ;3 para azul AQUA, 4 para ROJO, 5 morado
mov cx,0000h
mov dx,184fh
int 10h
mov ax,4c00h
int 21h
RET
AZULPROC ENDP
;*****************************************
MORADOPROC PROC NEAR
mov ah,06h
mov bh,5fh ;2fh VERDE ;3 para azul AQUA, 4 para ROJO, 5 morado
mov cx,0000h
mov dx,184fh
int 10h
mov ax,4c00h
int 21h
RET
MORADOPROC ENDP
;**********************************
VERDEPROC PROC NEAR
mov ah,06h
mov bh,2fh ;2fh VERDE ,3 para AQUA, 4 para ROJO, 5 morado
mov cx,0000h
mov dx,184fh
int 10h
mov ax,4c00h
int 21h
RET
VERDEPROC ENDP
;**********************************
ROJOPROC PROC NEAR
mov ah,06h
mov bh,4fh ;2fh VERDE ;3 para azul AQUA, 4 para ROJO, 5 morado
mov cx,0000h
mov dx,184fh
int 10h
mov ax,4c00h
int 21h
RET
ROJOPROC ENDP
;**********************************
NARANJAPROC PROC NEAR
mov ah,06h
mov bh,6fh ;2fh VERDE ;3 para azul AQUA, 4 para ROJO, 5 morado
mov cx,0000h
mov dx,184fh
int 10h
mov ax,4c00h
int 21h
RET
NARANJAPROC ENDP
codigo ends
end inicio ; Podemos Asignar desde se inicia PC
Suscribirse a:
Entradas (Atom)
Conclusión del equipo #1: Puertos paralelos Un puerto paralelo es una interfaz entre un ordenador y un periférico. El puerto paralelo ...

-
from turtle import * def curvemove(): for i in range ( 200 ): right( 1 ) forward( 1 ) color( 'red' , 'pink...
-
Registro de bandera. El Registro de banderas es el que informa al usuario el estado actual del microcontrolador. De los 16 bits de...
-
Octagono import turtle import tkSimpleDialog t = turtle.Turtle() c1=tkSimpleDialog.askstring(" Color","Contorno") ...