Vous êtes sur la page 1sur 12

;1.

- Realizar un programa que mov SI,offset textos pos2 dw 040Fh


permita el ingreso de N salto
caracteres, mov aH,1 cadIni db 'Ingrese
;deberan ser guardadas en s1: int 21h caracteres:$'
dos cadenas finales donde se cmp aL,13
guarden de forma JE mostrar1 textos db 10 dup
intercalada, mov [SI],aL
;en una de las cadenas inc SI ;2.-Realizar un programa que
debera contener tambien JMP s1 permita el ingreso de una
intercaladamente fecha,
;numeros y mayusculas, ;al concluir el ingreso debera
;en otra cadena minusculas y guardarse en un registro,
caracteres especiales. mostrar1: ;posteriormente mostrar el
;Se debe mostrar ambas binario de la fecha,
cadenas resultantes en mov [SI],13 ;el anio, el mes y el dia tanto
columnas de la misma forma mov SI,offset textos en binario como en
que se almaceno. s2: cmp [SI],13 hexadecimal.
JE fin
org 100h cmp [SI],'0' org 100h
salto macro JB mostrar2
push ax cmp [SI],'9' salto macro
push dx JA comp1 push ax
mov ah,2 mov bL,[SI] push dx
mov dl,13 show bL,pos1 mov aH,2
int 21h s3: inc SI mov dL,13
mov dl,10 JMP s2 int 21h
int 21h comp1: cmp [SI],'A' mov dL,10
pop dx JB mostrar2 int 21h
pop ax cmp [SI],'Z' pop dx
endm JA comp2 pop ax
mov bL,[SI] endm
show macro car,pos show bL,pos1
push ax JMP s3 guardar macro dm
push dx comp2: cmp [SI],'a' push ax
mov ah,2 JB mostrar2 mov ax,10
add pos,0100h cmp [SI],'z' mul dm
mov dx,pos JA mostrar2 mov dm,ax
int 10h mov bL,[SI] add dm,bx
mov dL,car show bL,pos2 pop ax
int 21h JMP s3 endm
pop dx mostrar2:
pop ax mov bL,[SI] convHex2 macro dat
endm show bL,pos2 push ax
JMP s3 push dx
inicio: push cx
mov aH,9 fin: int 20h mov aH,2
mov dx,offset cadIni mov dx,dat
int 21h pos1 dw 0405h SHR dx,4
add dL,30h SHR dL,7 salto
int 21h add dL,30h
mov dx,dat int 21h mov cx,2
SHL dL,4 inc cL mov SI,offset fecha
SHR dL,4 mov dx,dat mov bx,0
call esNumLet dec bx s2: mov bL,[SI]
pop cx cmp bx,0 sub bL,30h
pop dx JNE b1 guardar d
pop ax pop cx inc SI
endm pop dx loop s2
pop ax mov cx,2
convHex4 macro dat endm s3: inc SI
local num,imp mov bL,[SI]
push ax convBin2 macro dat sub bL,30h
push dx local b1 guardar m
push cx push ax loop s3
ult: push dx add SI,2
mov aH,2 push cx mov cx,4
mov dx,dat mov aH,2 mov bx,0
SHR dx,12 mov dx,dat s4: mov bL,[SI]
add dL,30h mov bx,16 sub bL,30h
int 21h mov cx,0 guardar a
mov dx,dat b1: SHL dx,cL inc SI
SHL dx,4 SHR dx,15 loop s4
SHR dx,12 add dL,30h
call esNumLet int 21h salto
mov dx,dat inc cL
SHR dL,4 mov dx,dat mov aH,9
call esNumLet dec bx mov dx,offset hexa
mov dx,dat cmp bx,0 int 21h
SHL dL,4 JNE b1
SHR dL,4 pop cx mov bx,d
call esNumLet pop dx convHex2 bx
pop cx pop ax mov aH,2
pop dx endm mov dL,'/'
pop ax int 21h
endm inicio: mov bx,m
mov aH,9 convHex2 bx
convBin macro dat mov dx,offset cadIni mov dL,'/'
local b1 int 21h int 21h
push ax salto mov bx,a
push dx mov SI,offset fecha convHex4 bx
push cx mov aH,1
mov aH,2 mov cx,10 salto
mov dx,dat s1: int 21h mov aH,9
mov bx,8 mov [SI],aL mov dx,offset bin
mov cx,0 inc SI int 21h
b1: SHL dL,cL loop s1 mov aH,2
;3.- Realizar un programa que int 21h
convBin d solo permita el ingreso add hx,cL
mov dL,'/' ;de 3 numeros hexadecimales sub hx,30h
int 21h de dos digitos cada uno. mov bL,1
convBin m ;Mostrar el binario del JMP salir
mov dL,'/' mayor, el decimal del medio esH2:
int 21h ;y el octal del menor. mov dL,dat
convBin2 a int 21h
add hx,cL
org 100h sub hx,37h
mov bL,1
fin: int 20h salto macro salir:
push ax pop cx
push dx pop ax
esNumLet proc mov aH,2 endm
cmp dL,9 mov dL,13
JNA p1 int 21h convBin macro dat
add dL,37h mov dL,10 local b1
JMP imp int 21h push ax
p1: add dL,30h pop dx push dx
imp: int 21h pop ax push cx
ret endm mov dx,0
esNumLet endp mov aH,2
esHex macro dat,hx mov dL,dat
local mov bx,8
comp1,comp2,salir,esH1,esH mov cx,0
2 b1: SHL dL,cL
cont db 0 push ax SHR dL,7
push cx add dL,30h
d dw 0 mov cx,0 int 21h
m dw 0 mov cL,dat inc cL
a dw 0 mov aH,2 mov dL,dat
mov bL,0 dec bx
cmp dat,'0' cmp bx,0
bin db 'Binario: $' JAE comp1 JNE b1
hexa db 'Hexadecimal: $' JMP salir pop cx
comp1: pop dx
cmp dat,'9' pop ax
cadIni db 'Ingresar una JBE esH1 endm
fecha(DD/MM/AAAA):$' cmp dat,'A'
JAE comp2 convDec macro dat
fecha db 10 dup JMP salir local b1,b2
comp2: push ax
cmp dat,'F' push dx
JBE esH2 mov bx,10
JMP salir mov dx,0
esH1: mov cx,0
mov dL,dat b1: mov ax,0
mov aL,dat mov dx,offset cad1 JNE s8
div bL mov aH,9 s9: int 21h
mov dat,aL ;coc int 21h cmp aL,13
mov dL,aH ;res mov aH,7 JNE s9
push dx s1: int 21h salto
inc cL esHex aL,hex1
cmp aL,0 cmp bL,1 mov bx,0
JNE b1 JNE s1 mov bL,hex1
mov aH,2 SHL hex1,4 cmp bL,hex2
b2: pop dx s2: int 21h JA r1
add dL,30h esHex aL,hex1 xchg bL,hex2
int 21h cmp bL,1 r1: cmp bL,hex3
loop b2 JNE s2 JA r2
pop dx s3: int 21h xchg bL,hex3
pop ax cmp aL,13 r2: mov hex1,bL
endm JNE s3 mov bL,hex2
salto cmp bL,hex3
convOct macro dat JA r3
local b1,b2 mov dx,offset cad2 xchg bL,hex3
push ax mov aH,9 r3: mov hex2,bL
push dx int 21h
mov bx,8 mov aH,7 mov aH,9
mov dx,0 s4: int 21h mov dx,offset mos1
mov cx,0 esHex aL,hex2 int 21h
b1: mov ax,0 cmp bL,1
mov aL,dat JNE s4 convBin hex1
div bL SHL hex2,4 salto
mov dat,aL ;coc s5: int 21h mov dx,offset mos2
mov dL,aH ;res esHex aL,hex2 int 21h
push dx cmp bL,1
inc cL JNE s5 convDec hex2
cmp aL,0 s6: int 21h salto
JNE b1 cmp aL,13 mov dx,offset mos3
mov aH,2 JNE s6 int 21h
b2: pop dx salto
add dL,30h convOct hex3
int 21h mov dx,offset cad3
loop b2 mov aH,9
pop dx int 21h
pop ax mov aH,7
endm s7: int 21h fin: int 20h
esHex aL,hex3
inicio: mov bx,0 cmp bL,1 hex1 db 0h
mov aH,9 JNE s7 hex2 db 0h
mov dx,offset cadIni SHL hex3,4 hex3 db 0h
int 21h s8: int 21h
salto esHex aL,hex3
cmp bL,1
cadIni db 'Ingresar 3 numeros endm cmp ax,0
hexadecimales de 2 digitos:$' JE m3
cad1 db '1.- $' guardar macro num JMP m2
cad2 db '2.- $' push ax m3: mov aH,2
cad3 db '3.- $' push bx pop dx
push dx add dL,30h
mos1 db 'mayor: $' mov cx,0 int 21h
mos2 db 'medio: $' mov cL,num dec c
mos3 db 'menor: $' mov bx,[SI] cmp c,0
mov ax,10 JA m3
mul bx mov dL,'-'
inc SI int 21h
mov [SI],0 salir:
;4.- Realizar un programa que dec SI pop dx
permita el ingreso de N mov [SI],ax pop cx
numeros, add [SI],cx pop ax
;entre 1 y 3 digitos, una vez pop dx endm
ingresados los numeros pop bx
;mostrar primero los primos, pop ax
debajo los pares y endm esPar macro
;debajo los impares local salir,m2,m3
esPrimo macro push ax
org 100h local m1,m2,,m3,salir push cx
push ax push dx
salto macro push cx mov cx,2
push ax push dx mov ax,bx
push dx mov ax,bx mov dx,0
mov aH,2 mov cx,2 div cx
mov dL,13 mov dx,0 cmp dx,0
int 21h div cx JNE salir
mov dL,10 mov cx,2 ;cont mov c,0
int 21h mov c,ax ;hasta la mitad mov ax,bx
pop dx m1: mov ax,bx m2: mov dx,0
pop ax mov dx,0 mov cx,10
endm div cx div cx
cmp dx,0 push dx
esNum macro dat JE salir inc c
local comp, salir inc cx cmp ax,0
push ax dec c JE m3
mov bL,0 cmp c,0 JMP m2
mov bH,dat JNE m1 m3: mov aH,2
cmp bH,'0' pop dx
JAE comp mov ax,bx add dL,30h
comp: cmp bH,'9' m2: mov dx,0 int 21h
JA salir mov cx,10 dec c
mov bL,1 div cx cmp c,0
salir: push dx JA m3
pop ax inc c mov dL,'-'
int 21h int 21h
salir: salto mov SI,offset numeros
pop dx mov cx,0
pop cx mov SI,offset numeros mov cL,cont
pop ax mov [SI],0 s3: mov bx,[SI]
endm inc SI esPrimo
mov [SI],0 s4: inc SI
esImpar macro dec SI cmp [SI],'-'
local salir,m2,m3 s1: mov aH,7 JNE s4
push ax int 21h inc SI
push cx cmp aL,13 loop s3
push dx JE sal1 salto
mov cx,2 s2: esNum aL mov aH,9
mov ax,bx cmp bL,1 mov dx,offset cadPares
mov dx,0 JNE s1 int 21h
div cx mov aH,2
cmp dx,0 mov dL,aL mov SI,offset numeros
JE salir int 21h mov cx,0
mov c,0 sub aL,30h mov cL,cont
mov ax,bx guardar aL s5: mov bx,[SI]
m2: mov dx,0 JMP s1 esPar
mov cx,10 s6: inc SI
div cx sal1: salto cmp [SI],'-'
push dx inc cont JNE s6
inc c int 21h inc SI
cmp ax,0 cmp aL,13 loop s5
JE m3 JE sal2 salto
JMP m2 inc SI mov aH,9
m3: mov aH,2 mov dx,offset
pop dx inc SI cadImpares
add dL,30h mov [SI],'-' int 21h
int 21h inc SI
dec c mov [SI],0 mov SI,offset numeros
cmp c,0 inc SI mov cx,0
JA m3 mov [SI],0 mov cL,cont
mov dL,'-' dec SI s7: mov bx,[SI]
int 21h JMP s2 esImpar
salir: s8: inc SI
pop dx sal2: cmp [SI],'-'
pop cx inc SI JNE s8
pop ax inc SI inc SI
endm mov [SI],0 loop s7
inc SI
mov [SI],'-'
salto
inicio: mov aH,9 fin: int 20h
mov aH,9 mov dx,offset cadPrimos
mov dx,offset cadIni int 21h
int 10h pop bx
mov aH,2 pop ax
mov bH,0 endm
c dw 0 mov dx,0
flag db 0 int 10h convBin macro dat
cont db 0 pop dx local b1
pop cx push ax
pop bx push dx
pop ax push cx
cadIni db 'Ingresar N endm mov dx,0
numeros entre 1 y 3 mov aH,2
digitos:$' mov dL,dat
cadPrimos db 'Primos: $' esNum macro dat mov bx,8
cadPares db 'Pares: $' local salir mov cx,0
cadImpares db 'Impares: $' push ax b1: SHL dL,cL
mov bL,0 SHR dL,7
numeros dw 10 dup(0) mov bH,dat add dL,30h
;5.- Realizar un programa que cmp bH,'0' int 21h
muestre un menu JB salir inc cL
;1.- Ingreso de numeros, cmp bH,'9' mov dL,dat
;2.- ingreso de Operacion, JA salir dec bx
;3.- Mostrar resultado (que mov bL,1 cmp bx,0
debe mostrarse en binario, salir: JNE b1
octal, decimal y hexa) pop ax pop cx
endm pop dx
org 100h pop ax
leerNum macro endm
salto macro local m1,m2
push ax push ax convHex macro dat
push dx push bx local salir,esH1,esH2,m1
mov aH,2 m1: mov ax,10 push ax
mov dL,13 mov bL,dat1 push dx
int 21h mul bL mov aH,2
mov dL,10 add aL,[SI] mov dx,0
int 21h mov dat1,aL mov dL,dat
pop dx inc SI SHR dL,4
pop ax cmp [SI],'-' cmp dL,'9'
endm JNE m1 JA esH1
inc SI add dL,30h
limpiar macro m2: mov ax,10 int 21h
push ax mov bL,dat2 JMP m1
push bx mul bL esH1:
push cx add aL,[SI] add dL,37h
push dx mov dat2,aL int 21h
mov ax,0600h inc SI m1: mov dx,0
mov bH,71h cmp [SI],'-' mov dL,dat
mov cx,0 JNE m2 SHL dL,4
mov dx,204Fh pop dx SHR dL,4
cmp dL,'9' mov cx,0 JE IngNum
JA esH2 mov cH,dat cmp aL,'2'
add dL,30h b1: mov ax,0 JE IngOp
int 21h mov aL,cH
JMP salir div bL mostrar:
esH2: add dL,37h mov cH,aL ;coc limpiar
int 21h mov dL,aH ;res mov dx,offset cad3
salir: push dx mov aH,9
inc cL int 21h
pop dx cmp aL,0 salto
pop ax JNE b1 salto
endm mov cH,0 mov SI,offset numeros
mov aH,2 leerNum
b2: pop dx cmp op,'+'
convDec macro dat add dL,30h JE suma
local b1,b2 int 21h cmp op,'-'
push ax loop b2 JE resta
push dx pop dx cmp op,'*'
mov bx,10 pop ax JE multi
mov dx,0 endm cmp op,'/'
mov cx,0 JE divi
mov cH,dat mov aH,9
b1: mov ax,0 mov dx,offset error
mov aL,cH int 21h
div bL inicio: JMP salMostrar
mov cH,aL ;coc mov SI,offset numeros
mov dL,aH ;res menu: divi: cmp dat2,0
push dx limpiar JNE d1
inc cL mov aH,9 mov aH,9
cmp aL,0 mov dx,offset cad1 mov dx,offset error
JNE b1 int 21h int 21h
mov cH,0 salto JMP salMostrar
mov aH,2 mov dx,offset cad2 d1: mov ax,0
b2: pop dx int 21h mov bx,0
add dL,30h salto mov aL,dat1
int 21h mov dx,offset cad3 mov bL,dat2
loop b2 int 21h div bL
pop dx salto mov res,aL
pop ax salto JMP show
endm
mov aH,7 suma: mov bL,dat1
s1: int 21h add bL,dat2
convOct macro dat cmp aL,'1' mov res,bL
local b1,b2 JB s1 JMP show
push ax cmp aL,'3' resta: mov bL,dat1
push dx JA s1 cmp bL,dat2
mov bx,8 JNB r1
mov dx,0 cmp aL,'1' mov aH,9
mov dx,offset error JMP sal2
int 21h IngNum: r: mov op,aL
JMP salMostrar limpiar JMP sal2
r1: mov bL,dat1 mov dx,offset cad1 m: mov op,aL
sub bL,dat2 mov aH,9 JMP sal2
mov res,bL int 21h d: mov op,aL
JMP show salto
multi: mov ax,0 salto sal2:
mov bx,0 s2: mov aH,7 JMP menu
mov aL,dat1 int 21h
mov bL,dat2 cmp aL,13
mul bL JE sal1 fin: int 20h
mov res,aL esNum aL
JMP show cmp bL,1 op db 0
JNE s2
show: mov aH,2 dat1 db 0
mov aH,9 mov dL,aL dat2 db 0
mov dx,offset Bin int 21h res db 0
int 21h mov [SI],aL
convBin res sub [SI],30h Bin db 'Binario: $'
salto inc SI Oct db 'Octal: $'
mov dx,offset Oct JMP s2 Deci db 'Decimal: $'
int 21h sal1: Hexa db 'Hexadecimal: $'
convOct res mov [SI],'-'
salto inc SI
mov dx,offset Deci JMP menu press db 'Presione cualquier
int 21h tecla para volver al menu...$'
convDec res IngOp: error db 'Error de
salto limpiar Operacion$'
mov dx,offset cad2 cad1 db '1.- Ingreso de
mov dx,offset Hexa mov aH,9 numeros$'
int 21h int 21h cad2 db '2.- Ingreso de
convHex res salto Operacion$'
salto cad3 db '3.- Mostrar
s3: mov aH,7 Resultado$'
salMostrar: int 21h
salto cmp aL,13 numeros db dup(0)
salto JE sal2
mov aH,9 cmp aL,'+'
mov dx,offset press JE s
int 21h cmp aL,'-'
mov aH,7 JE r
int 21h cmp aL,'*'
mov dat1,0 JE m
mov dat2,0 cmp aL,'/'
mov res,0 JE d
JMP menu JMP s3
s: mov op,aL
pop bx int 21h
pop ax inc SI
;7.- Realizar un programa endm JMP m1
para ingresar N caracteres, salir:
;promediar los codigos ascii pop dx
de los numeros, queEs macro dat pop ax
;promediar los codigos ascii local char,nume,letra,salir endm
de las letras y push ax
;promediar los codigos ascii push cx
de los caracteres. mov cL,dat
;De los promedios cmp cL,'0'
determinar cual es mayor, JB char inicio:
medio y menor. cmp cL,'9' limpiar
;En ese orden de mayor a JBE nume mov aH,9
menor de los promedios cmp cL,'A' mov dx,offset cadIni
;mostrar los numeros letras y JB char int 21h
caracteres. cmp cL,'Z' salto
JBE letra
org 100h cmp cL,'a' mov SI,offset dirCar
JB char mov DI,offset dirLet
salto macro cmp cL,'z' mov BX,offset dirNum
push ax JBE letra mov aH,1
push dx s1: int 21h
mov aH,2 char: inc car cmp aL,13
mov dL,13 mov [SI],dat JE sal1
int 21h inc SI queEs aL
mov dL,10 JMP salir JMP s1
int 21h nume: inc num
pop dx mov [BX],dat sal1: salto
pop ax inc BX mov [SI],13 ;indica el
endm JMP salir final
letra: inc let mov [DI],13
limpiar macro mov [DI],dat mov [BX],13
push ax inc DI
push bx mov SI,offset dirCar
push cx salir: mov DI,offset dirLet
push dx pop cx mov BX,offset dirNum
mov ax,0600h pop ax
mov bH,71h endm cmp car,0
mov cx,0 JE sal2
mov dx,204Fh show macro dat s2: cmp [SI],13
int 10h push ax JE prom1
mov aH,2 push dx mov cL,[SI]
mov bH,0 local m1,salir add suma,cL
mov dx,0 mov aH,2 inc SI
int 10h m1: cmp [SI],13 JMP s2
pop dx JE salir prom1:
pop cx mov dL,[SI] mov ax,0
mov cx,0 int 21h
mov aL,suma mov dL,'n'
mov cL,car int 21h suma db 0
div cL mov dL,num
mov car,cL add dL,30h mayor dw 0
sal2: int 21h medio dw 0
mov suma,0 mov dL,'l' menor dw 0
cmp let,0 mov dL,let
JE sal3 add dL,30h
s3: cmp [DI],13 int 21h car db 0
JE prom2 salto num db 0
mov cL,[DI] let db 0
add suma,cL mov cL,car
inc DI mov mayor,cL
JMP s3 mov cL,num
prom2: mov medio,cL dirCar db 40 dup(0)
mov ax,0 mov cL,let dirNum db 40 dup(0)
mov cx,0 mov menor,cL dirLet db 40 dup(0)
mov aL,suma
mov cL,let mov bx,0 cadProm db 'PromediosASCII:
div cL mov bL,mayor $'
mov let,cL cmp bL,medio cadIni db 'Ingresar N
sal3: JA r1 caracteres:$'
mov suma,0 xchg bL,medio cadCar db 'Caracteres: $'
cmp num,0 r1: cmp bL,menor cadNum db 'Numeros: $'
JE sal4 JA r2 cadLet db 'Letras: $'
s4: cmp [BX],13 xchg bL,menor
JE prom3 r2: mov mayor,bL
mov cL,[BX] mov bL,medio
add suma,cL cmp bL,menor
inc BX JA r3
JMP s4 xchg bL,menor
prom3: r3: mov medio,bL
mov ax,0
mov cx,0 mov bL,car
mov aL,suma cmp mayor,bL
mov cL,num JE r4
div cL mov bL,num
mov num,cL
sal4:
mov dx,offset cadProm
mov aH,9
int 21h
mov aH,2
mov dL,'c'
int 21h
mov dL,car fin: int 20h
add dL,30h
ingresar nombre5 db n
nombre4,c4,s4 dup(' ')
´; 9.- Realizar un programa salto nombre6 db n
para ingresar nombres y ingresar dup(' ')
cargos de empleo (al menos nombre5,c5,s5 nombre7 db n
salto dup(' ')
10), preguntar si se ordena ingresar nombre8 db n
por nombre o cargo, mostrar nombre6,c6,s6 dup(' ')
en orden alfabético el salto nombre9 db n
ingresar dup(' ')
resultado. nombre7,c7,s7 nombre10 db n
salto dup(' ')
org 100h ingresar
salto macro nombre8,c8,s8
mov ah,2 salto ret
mov dl,10 ingresar
int 21h nombre9,c9,s9
mov dl,13 salto
int 21h ingresar
endm nombre10,c10,s10
salto
ingresar macro salto
nombre,ciclo,sig salto
mov ah,1 mostrar
mov cl,n nombre1,ci1,si1
mov si,0 salto
ciclo: cmp cl,0 mostrar
je sig nombre2,ci2,si2
int 21h salto
cmp al,13 mostrar
je sig nombre3,ci3,si3
mov salto
nombre[si],al mostrar
inc si nombre4,ci4,si4
dec cl salto
jmp ciclo mostrar
sig: nombre5,ci5,si5
endm salto
mostrar macro mostrar
nomb,cicl,sigu nombre6,ci6,si6
mov ah,2 salto
mov cl,n mostrar
mov si,0 nombre7,ci7,si7
cicl: cmp cl,0 salto
je sigu mostrar
mov nombre8,ci8,si8
dl,nomb[si] salto
int 21h mostrar
inc si nombre9,ci9,si9
dec cl salto
jmp cicl mostrar
sigu: nombre10,ci10,si10
endm
fin: int 20h
inicio: n equ 25
;tamano de la fila
ingresar nombre1 db n
nombre1,c1,s1 dup(' ')
salto nombre2 db n
ingresar dup(' ')
nombre2,c2,s2 nombre3 db n
salto dup(' ')
ingresar nombre4 db n
nombre3,c3,s3 dup(' ')
salto

Vous aimerez peut-être aussi