Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 64
- .data
- ; Prompt msgs
- msgTitle db 10,13,' MENU'
- msgOp1 db 10,13,'1. Crear directorio$'
- msgOp2 db 10,13,'2. Eliminar directorio$'
- msgOp3 db 10,13,'3. Renombrar directorio$'
- msgOp4 db 10,13,'4. Salir$'
- msgSelect db 10,13,'Elija Opcion: $'
- msgCrear db 10,13,' Nombre de directorio a crear: $'
- msgBorrar db 10,13,' Nombre de directorio a borrar: $'
- msgRenombrar db 10,13,' Nombre de directorio a renombrar: $'
- msgRenombrar2 db 10,13,' Nuevo nombre de directorio: $'
- ; Variables generales
- opcion db ?
- nombreDirectorio db 100 dup(0)
- nuevoDirectorio db 100 dup(0)
- nombreLength dw ?
- ; Variables pantalla
- x1 db 0
- y1 db 0
- x2 db 0
- y2 db 0
- row db 0
- column db 0
- ; Debug variables
- msg db 10,13,' <<ENTRO ACA>>>>$'
- .code
- begin: call main
- ; Programa principal
- ; ------------------
- main proc
- mov ax, @data
- mov ds, ax
- mov es, ax
- xMain:
- mov row, 0
- mov column, 0
- mov x1, 0
- mov y1, 0
- mov x2, 0
- mov y2, 0
- call clear_screen
- call set_cursor
- ; Pinta la palabra menu
- mov x1, 0
- mov x2, 0
- mov x2, 1
- mov y2, 60
- mov bh, 1aH
- call paint_region
- ; Pinta las opciones
- mov x1, 2
- mov y1, 0
- mov x2, 6
- mov y2, 60
- mov bh, 2bH
- call paint_region
- ; Pinta seleccion
- mov x1, 7
- mov y1, 0
- mov x2, 7
- mov y2, 12
- mov bh, 3bH
- call paint_region
- ; Pinta entrada de texto seleccion
- mov x1, 7
- mov y1, 13
- mov x2, 7
- mov y2, 60
- mov bh, 4bH
- call paint_region
- call show_menu
- call read_char
- cmp al, '1'
- je opcion1
- cmp al, '2'
- je opcion2
- cmp al, '3'
- je opcion3
- jne fin
- opcion1:
- ; Pinta su menu
- call option1
- lea dx, msgCrear
- call print_string
- call read_string
- call create_dir
- ; poner todos los valores en 0
- call restart_string
- jmp xMain
- opcion2:
- call option1
- lea dx, msgBorrar
- call print_string
- call read_string
- call remove_dir
- jmp xMain
- opcion3:
- call option1
- lea dx, msgRenombrar
- call print_string
- call read_string
- lea dx, msgRenombrar2
- call print_string
- call read_string2
- call rename_dir
- jmp xMain
- fin:
- mov row, 0
- mov column, 0
- call set_cursor
- call clear_screen
- mov ax, 4c00H
- int 21H
- main endp
- ; Muestra el menu de la app
- ; -------------------------
- show_menu proc
- lea dx, msgTitle
- call print_string
- lea dx, msgOp1
- call print_string
- lea dx, msgOp2
- call print_string
- lea dx, msgOp3
- call print_string
- lea dx, msgOp4
- call print_string
- lea dx, msgSelect
- call print_string
- ret
- show_menu endp
- ; Muestra un mensaje de texto
- ; Requiere valor en dx
- ; ---------------------------
- print_string proc
- push ax
- mov ah, 09H
- int 21H
- pop ax
- ret
- print_string endp
- ; Lee un caracter
- ; salida en ah
- ; ---------------
- read_char proc
- mov ah, 01H
- int 21H
- ret
- read_char endp
- ; Lee una cadena
- ; --------------
- read_string proc
- push si
- push ax
- mov si, 0
- x10:
- mov ah, 01H
- int 21H
- cmp al, 13
- je end10
- mov nombreDirectorio[si], al
- inc si
- jmp x10
- end10:
- mov nombreLength, si
- pop ax
- pop si
- ret
- read_string endp
- ; Lee una cadena
- ; --------------
- read_string2 proc
- push si
- push ax
- mov si, 0
- x11:
- mov ah, 01H
- int 21H
- cmp al, 13
- je end11
- mov nuevoDirectorio[si], al
- inc si
- jmp x11
- end11:
- mov nombreLength, si
- pop ax
- pop si
- ret
- read_string2 endp
- ; Para realizar depuracion
- ; ------------------------
- debug proc
- push dx
- lea dx, msg
- call print_string
- pop dx
- ret
- debug endp
- ; Restart String
- ; --------------
- restart_string proc
- push si
- mov si, 0
- mov nombreLength, 0
- x20:
- mov nombreDirectorio[si], 0
- mov nuevoDirectorio[si], 0
- inc si
- cmp si, 100
- je x20_fin
- loop x20
- x20_fin:
- pop si
- ret
- restart_string endp
- ; ------------------------------------------------------
- ; METODOS PARA EL TRABAJO CON DIRECTORIOS |
- ; ------------------------------------------------------
- ; Crea un directorio
- ; ------------------
- create_dir proc
- mov ah, 39H
- lea dx, nombredirectorio
- int 21H
- ret
- create_dir endp
- ; Elimina un directorio
- ; ---------------------
- remove_dir proc
- mov ah, 3aH
- lea dx, nombreDirectorio
- int 21H
- ret
- remove_dir endp
- ; Renombra un directorio
- ; ----------------------
- rename_dir proc
- mov ah, 56H
- lea dx, nombreDirectorio
- lea di, nuevoDirectorio
- int 21H
- ret
- rename_dir endp
- ; ------------------------------------------------------
- ; METODOS PARA EL TRABAJO CON PANTALLA |
- ; ------------------------------------------------------
- ; Limpia la pantalla
- ; ------------------
- clear_screen proc
- mov ax, 0600H
- mov bh, 07H
- mov cx, 0000
- mov dx, 184fH
- int 10h
- ret
- clear_screen endp
- ; Establece la posicion del cursor
- ; --------------------------------
- set_cursor proc
- mov ah, 02H
- mov bh, 0
- mov dh, row
- mov dl, column
- int 10H
- ret
- set_cursor endp
- ; Pinta una region
- ; Requiere valores de color en BH
- ; -------------------------------
- paint_region proc
- mov ax, 0600H
- ; mov bh, 4aH
- mov ch, x1
- mov cl, y1
- mov dh, x2
- mov dl, y2
- int 10h
- ret
- paint_region endp
- ; Opcion 1
- ; --------
- option1 proc
- ; Pinta su menu
- mov row, 5
- mov column, 5
- call set_cursor
- mov x1, 5
- mov y1, 5
- mov x2, 7
- mov y2, 60
- mov bh, 1aH
- call paint_region
- ret
- option1 endp
- end begin
Add Comment
Please, Sign In to add comment