Agenda

Una agenda sin documentar enviada por Hector Torres.

Búsqueda de ejemplos en Ensamblador
;Autor Hector Torres
;URL

imprime macro mensaje
mov ah,09h
lea dx,mensaje
int 21h
endm
.model small
.stack
.data

      agenda struct
      nombre db 20 dup(' '),'$'
      domicilio db 20 dup (' '),'$'
      telefono db 20 dup (' '),'$'
      agenda ends
      var agenda <>

      agenda2 struct
      nombre2 db 20 dup(' '),'$'
      domicilio2 db 20 dup (' '),'$'
      telefono2 db 20 dup (' '),'$'
      agenda2 ends
      var2 agenda2 <>


      bajar db 'Desea eliminarlo$'
      punteroc dw ?
      nel db 'No esta el contacto$'
      cade1 db 60 dup (' '),'$'
      ent db 600 dup (' '),'$'
      flecha db ?
      agreg  db ':::Agregar:::$'
      cosul db ':::Consultar:::$'
      elimi db ':::Eliminar:::$'
      salir    db ':::Salir:::$'
     
      nom db '::::Ingrese el  Nombre: $'
      domi db '::::Ingrese el  Domicilio: $'
      edad db '::::Ingrese el  Telefono: $'
      nom2 db '::::Nombre: $'
      domi2 db '::::Domicilio: $'
      edad2 db '::::Telefono: $'


      menu  db '°°A=Abre menu  O=Crear archivo   G= Agregar   C= Consultar  S= Salir°°$'
      read db '­Desea salir­$'
      nelo db '!Contacto Encontrado$'
      opto db '°°Presione ESC para continuar°°$'
      contac db 'Buscar a:$'
      titu db 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎ ::AGENGA:: ÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ$'
      linea db 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ$'
      video db ?
      pag2 db ?
      pag db ?
      puntero dw ?
      puntero2 dw ?
      cadena1 db '¨desea contiunuar agregando?$'
      prese db 'MI AGENDITA$'
      arch  db '::ABRIR::>>>O$'
      contro dw ?
      controla2 dw ?
      busca db 20 dup (' '),'$'
      ruta db 'c:\estructura.txt',00H
      arc db 'c:\estructura.txt',00H
.code
.startup
leer proto c, cuantos:byte, cad:word
gotoxy proto c, fila:byte, colu:byte



;<<<<<<<<<<<<<<<<<<<<<<Realizo la presentacion de la agenda>>>>>>>>>>>>>>>>>>>>>
call limpia

presentacion:

invoke gotoxy,20,4
imprime menu
invoke gotoxy,19,9
imprime linea

invoke gotoxy, 0,10
imprime titu
invoke gotoxy, 1,10
imprime linea

invoke gotoxy,2,19
imprime arch
invoke gotoxy,2,22


invoke gotoxy,2,5
imprime prese
invoke gotoxy,2,8

mov ah,07h
int 21h

.if al==65 || al==97
jmp sg1
.else
.if al==79 || al==111
jmp crear
.endif
jmp presentacion
.endif

sg1:
invoke gotoxy,4,6
imprime agreg

invoke gotoxy,6,6
imprime cosul

;invoke gotoxy,8,6
;imprime elimi

invoke gotoxy,8,6
imprime salir
invoke gotoxy,8,9



mov ah,07h
int 21h
 

.if al==71
jmp abrir
.else

.if al==83
jmp salida
.endif

.if al==67
jmp consultas
.endif

call limpia
jmp presentacion
.endif


;.if al==83 || al==115
;jmp salida
;.endif




;::::::::::::::::::::::::::::::::::::AGREGAR::::::::::::::::::::::::::::::::::

crear:
mov puntero,0
mov ah,3ch
mov cx,00
lea dx,ruta
int 21h
jc error
mov contro,ax
jmp presentacion

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<abrir>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

abrir:

mov ah,3dh
mov al,010
lea dx,ruta
int 21h
jc error
mov contro,ax

mov ah,3fh
mov bx,contro
mov cx,600
lea dx,ent
int 21h
jc error



.if ax==60
jmp regis1
.endif

.if ax==120
jmp regis2
.endif

.if ax==180
jmp regis3
.endif

.if ax==240
jmp regis4
.endif

.if ax==300
jmp regis5
.endif

.if ax==360
jmp regis6
.endif

.if ax==420
jmp regis7
.endif

.if ax==480
jmp regis8
.endif

.if ax==540
jmp regis9
.endif

.if ax==600
jmp regis10
.endif

.if ax==660
jmp regis11
.endif

.if ax==720
jmp regis12
.endif

.if ax==780
jmp regis13
.endif

.if ax==840
jmp regis14
.endif

.if ax==900
jmp regis15
.endif

.if ax==960
jmp regis16
.endif


.if ax==1020
jmp regis17
.endif

.if ax==1080
jmp regis18
.endif

.if ax==2040
jmp regis19
.endif

.if ax==2100
jmp regis20
.endif


regis1:
mov puntero,ax
jmp ini

regis2:
mov puntero,ax
jmp ini

regis3:
mov puntero,ax
jmp ini

regis4:
mov puntero,ax
jmp ini


regis5:
mov puntero,ax
jmp ini

regis6:
mov puntero,ax
jmp ini

regis7:
mov puntero,ax
jmp ini

regis8:
mov puntero,ax
jmp ini

regis9:
mov puntero,ax
jmp ini


regis10:
mov puntero,ax
jmp ini

regis11:
mov puntero,ax
jmp ini

regis12:
mov puntero,ax
jmp ini

regis13:
mov puntero,ax
jmp ini

regis14:
mov puntero,ax
jmp ini

regis15:
mov puntero,ax
jmp ini

regis16:
mov puntero,ax
jmp ini

regis17:
mov puntero,ax
jmp ini

regis18:
mov puntero,ax
jmp ini

regis19:
mov puntero,ax
jmp ini

regis20:
mov puntero,ax
jmp ini

ini:
call limpia


;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<leer>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
invoke gotoxy,8,0
imprime nom
invoke gotoxy,8,25
invoke leer,20,addr var.nombre

invoke gotoxy,9,0
imprime domi
invoke gotoxy, 9,27

invoke leer,20,addr var.domicilio


invoke gotoxy,10,0
imprime edad
invoke gotoxy, 10,25

invoke leer,20,addr var.telefono







;<<<<<<<<<<<<<<<<<<<<<<<<<<<<escribir en archivo>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

mov ah,40h
mov bx,contro
mov cx,60
lea dx,var
int 21h

.if ax==60
mov bx,puntero
add bx,ax
mov puntero,ax
.endif

;<<<<<<<<<<<<<<<<<<<<pregunta si continua>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
invoke gotoxy,20,8

mov ah,09h
lea dx,cadena1
int 21h

invoke gotoxy,20,39
lb1:

mov ah,01h
int 21h


.if al==83 || al==115
jmp mueve
.endif
.if al==110 || al==78
jmp cerrar
.endif

jmp lb1
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<CONSULTAR>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



consultas:
call limpia
invoke gotoxy,1,13
imprime titu
invoke gotoxy,2,13
imprime linea
invoke gotoxy,4,10
imprime contac
invoke gotoxy,4,19


lea si,busca
mov cx,20

reade:           
mov ah,07h
int 21h
;cmp al,13
;je conti1
cmp al,27
je salida
.if al==13
jmp conti1
.else
mov [si],al
inc si
mov dl,al
mov ah,02h
int 21h
loop reade
.endif       


conti1:
call limpia
   
mov dx,03
mov ah,3Dh
mov al,00
lea dx,arc
int 21h
jc error
mov controla2,ax

lec:
mov ah,3fh
mov bx,controla2
mov cx,20
lea dx,var2.nombre2
int 21h


mov ah,3fh
mov bx,controla2
mov cx,20
lea dx,var2.domicilio2
int 21h

mov ah,3fh
mov bx,controla2
mov cx,20
lea dx,var2.telefono2
int 21h

.if ax==60
mov bx,puntero
add bx,ax
mov puntero,ax
.endif

.if ax==0
imprime nel
jmp sale
.endif

;AQUI IBA CERRAR

   compa:
      push es
      mov ax,ds
      mov es,ax
      mov cx,9
      lea si,busca
      lea di,var2.nombre2
      repe cmpsb
      je lista
      jne c2
      pop es


c2:
call limpia2


mov ah,42h
mov al,01
mov bx,controla2
mov cx,00
mov dx,puntero
int 21h
jc error
jmp lec


lista:


mov ah,3eh
mov bx,controla2
int 21h



invoke gotoxy,5,17
imprime nom2
invoke gotoxy,5,33
imprime var2.nombre2

invoke gotoxy,9,17
imprime domi2

invoke gotoxy,9,33
imprime var2.domicilio2

invoke gotoxy,13,17
imprime edad2

invoke gotoxy,13,33
imprime var2.telefono2

invoke gotoxy,16,33
imprime nelo

invoke gotoxy,22,14
imprime linea
invoke gotoxy,23,17
imprime opto

sale:
mov ah,07h
int 21h

.if al==17 || al==27
invoke gotoxy,20,35
imprime read
.endif

mov ah,07h
int 21h
.if al==115 || al==83
call limpia
jmp presentacion
.endif

;.endif

.if al==78 || al==110
call limpia
jmp consultas
.endif


cerrar:
mov ah,3eh
mov bx,contro
int 21h
call limpia
jmp presentacion



;<<<<<<<<<<<<<<<<<<<<<<<<<<<mover puntero>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

mueve:

mov ah,42h
mov al,01
mov bx,contro
mov cx,00
mov dx,puntero
int 21h
jc error

jmp ini
;<<<<<<<<<<<<<<<<<<<<<<<<<<<cerrar archivo>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

salida:
invoke gotoxy,25,4
mov ax,4c00h
int 21h

error:
mov ax,4c00h
int 21h




.exit

leer proc c, cuantos:byte, cad:word

mov cl,0
mov di,0
mov di,cad

       .repeat
            mov ah,01h
            int 21h

            mov [di],al
            .if al==08
            dec di
            dec cl
            .else
            inc di
            inc cl
           .if al==13
            mov cl,20
           .endif
           .endif
       .until cl==cuantos
ret
leer endp


gotoxy proc c, fila:byte, colu:byte

mov ah,02h
mov bh,00
mov dh,fila
mov dl,colu
int 10h

ret

gotoxy endp


limpia proc c

mov ah,06h
mov al,00h
mov bh,01h
mov cx,0000h
mov dx,184fh
int 10h

lea si,var.nombre
call limpiaCad
lea si,var.domicilio
call limpiaCad
lea si,var.telefono
call limpiaCad

ret
limpia endp



limpiaCad proc c
mov cx,0
.repeat
   mov ah,' '
  ; mov al,'$'
   mov [si],ax
   inc si
   inc cx
   .until cx==20
ret
limpiaCad endp


limpia2 proc c

mov ah,06h
mov al,00h
mov bh,01h
mov cx,0000h
mov dx,184fh
int 10h

lea si,var.nombre
call limpiaCad2
lea si,var.domicilio
call limpiaCad2
lea si,var.telefono
call limpiaCad2

ret
limpia2 endp



limpiaCad2 proc c
mov cx,0
.repeat
   mov ah,' '
  ; mov al,'$'
   mov [si],ax
   inc si
   inc cx
   .until cx==20
ret
limpiaCad2 endp


end