Guest User

Untitled

a guest
Aug 30th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .model small
  2. .stack 64
  3. .data
  4.     ; Prompt msgs
  5.     msgTitle db 10,13,'          MENU'
  6.     msgOp1 db 10,13,'1. Crear directorio$'
  7.     msgOp2 db 10,13,'2. Eliminar directorio$'
  8.     msgOp3 db 10,13,'3. Renombrar directorio$'
  9.     msgOp4 db 10,13,'4. Salir$'
  10.     msgSelect db 10,13,'Elija Opcion: $'
  11.    
  12.     msgCrear db 10,13,'     Nombre de directorio a crear: $'
  13.     msgBorrar db 10,13,'    Nombre de directorio a borrar: $'
  14.     msgRenombrar db 10,13,'    Nombre de directorio a renombrar: $'
  15.     msgRenombrar2 db 10,13,'   Nuevo nombre de directorio: $'
  16.    
  17.     ; Variables generales
  18.     opcion db ?
  19.     nombreDirectorio db 100 dup(0)
  20.     nuevoDirectorio db 100 dup(0)
  21.     nombreLength dw ?
  22.    
  23.     ; Variables pantalla
  24.     x1 db 0
  25.     y1 db 0
  26.     x2 db 0
  27.     y2 db 0
  28.    
  29.     row db 0
  30.     column db 0
  31.    
  32.     ; Debug variables
  33.     msg db 10,13,'  <<ENTRO ACA>>>>$'
  34. .code
  35. begin: call main
  36. ; Programa principal
  37. ; ------------------
  38. main proc
  39.     mov ax, @data
  40.     mov ds, ax
  41.     mov es, ax
  42.    
  43.     xMain:
  44.         mov row, 0
  45.         mov column, 0
  46.         mov x1, 0
  47.         mov y1, 0
  48.         mov x2, 0
  49.         mov y2, 0
  50.         call clear_screen
  51.         call set_cursor
  52.        
  53.         ; Pinta la palabra menu
  54.         mov x1, 0
  55.         mov x2, 0
  56.         mov x2, 1
  57.         mov y2, 60
  58.         mov bh, 1aH
  59.         call paint_region
  60.        
  61.         ; Pinta las opciones
  62.         mov x1, 2
  63.         mov y1, 0
  64.         mov x2, 6
  65.         mov y2, 60
  66.         mov bh, 2bH
  67.         call paint_region
  68.        
  69.         ; Pinta seleccion
  70.         mov x1, 7
  71.         mov y1, 0
  72.         mov x2, 7
  73.         mov y2, 12
  74.         mov bh, 3bH
  75.         call paint_region
  76.        
  77.         ; Pinta entrada de texto seleccion
  78.         mov x1, 7
  79.         mov y1, 13
  80.         mov x2, 7
  81.         mov y2, 60
  82.         mov bh, 4bH
  83.         call paint_region
  84.        
  85.         call show_menu
  86.         call read_char
  87.        
  88.         cmp al, '1'
  89.         je opcion1
  90.         cmp al, '2'
  91.         je opcion2
  92.         cmp al, '3'
  93.         je opcion3
  94.         jne fin
  95.        
  96.         opcion1:
  97.             ; Pinta su menu
  98.             call option1
  99.        
  100.             lea dx, msgCrear
  101.             call print_string
  102.            
  103.             call read_string
  104.             call create_dir
  105.            
  106.             ; poner todos los valores en 0
  107.             call restart_string
  108.            
  109.             jmp xMain
  110.         opcion2:
  111.             call option1
  112.            
  113.             lea dx, msgBorrar
  114.             call print_string
  115.            
  116.             call read_string
  117.             call remove_dir
  118.            
  119.             jmp xMain
  120.         opcion3:
  121.             call option1
  122.        
  123.             lea dx, msgRenombrar
  124.             call print_string
  125.            
  126.             call read_string
  127.            
  128.             lea dx, msgRenombrar2
  129.             call print_string
  130.            
  131.             call read_string2
  132.            
  133.             call rename_dir
  134.            
  135.             jmp xMain
  136.     fin:
  137.         mov row, 0
  138.         mov column, 0
  139.         call set_cursor
  140.         call clear_screen
  141.         mov ax, 4c00H
  142.         int 21H
  143. main endp
  144. ; Muestra el menu de la app
  145. ; -------------------------
  146. show_menu proc
  147.     lea dx, msgTitle
  148.     call print_string
  149.    
  150.     lea dx, msgOp1
  151.     call print_string
  152.    
  153.     lea dx, msgOp2
  154.     call print_string
  155.    
  156.     lea dx, msgOp3
  157.     call print_string
  158.    
  159.     lea dx, msgOp4
  160.     call print_string
  161.    
  162.     lea dx, msgSelect
  163.     call print_string
  164.     ret
  165. show_menu endp
  166. ; Muestra un mensaje de texto
  167. ; Requiere valor en dx
  168. ; ---------------------------
  169. print_string proc
  170.     push ax
  171.     mov ah, 09H
  172.     int 21H
  173.     pop ax
  174.     ret
  175. print_string endp
  176. ; Lee un caracter
  177. ; salida en ah
  178. ; ---------------
  179. read_char proc
  180.     mov ah, 01H
  181.     int 21H
  182.     ret
  183. read_char endp
  184. ; Lee una cadena
  185. ; --------------
  186. read_string proc
  187.     push si
  188.     push ax
  189.     mov si, 0
  190.    
  191.     x10:
  192.         mov ah, 01H
  193.         int 21H
  194.         cmp al, 13
  195.         je end10
  196.         mov nombreDirectorio[si], al
  197.         inc si
  198.         jmp x10
  199.    
  200.     end10:
  201.         mov nombreLength, si
  202.         pop ax
  203.         pop si
  204.         ret
  205. read_string endp
  206. ; Lee una cadena
  207. ; --------------
  208. read_string2 proc
  209.     push si
  210.     push ax
  211.     mov si, 0
  212.    
  213.     x11:
  214.         mov ah, 01H
  215.         int 21H
  216.         cmp al, 13
  217.         je end11
  218.         mov nuevoDirectorio[si], al
  219.         inc si
  220.         jmp x11
  221.    
  222.     end11:
  223.         mov nombreLength, si
  224.         pop ax
  225.         pop si
  226.         ret
  227. read_string2 endp
  228. ; Para realizar depuracion
  229. ; ------------------------
  230. debug proc
  231.     push dx
  232.     lea dx, msg
  233.     call print_string
  234.     pop dx
  235.     ret
  236. debug endp
  237. ; Restart String
  238. ; --------------
  239. restart_string proc
  240.     push si
  241.     mov si, 0
  242.     mov nombreLength, 0
  243.     x20:
  244.         mov nombreDirectorio[si], 0
  245.         mov nuevoDirectorio[si], 0
  246.         inc si
  247.         cmp si, 100
  248.         je x20_fin
  249.         loop x20
  250.    
  251.     x20_fin:
  252.         pop si
  253.     ret
  254. restart_string endp
  255. ; ------------------------------------------------------
  256. ;     METODOS PARA EL TRABAJO CON DIRECTORIOS          |
  257. ; ------------------------------------------------------
  258. ; Crea un directorio
  259. ; ------------------
  260. create_dir proc
  261.     mov ah, 39H
  262.     lea dx, nombredirectorio
  263.     int 21H
  264.     ret
  265. create_dir endp
  266. ; Elimina un directorio
  267. ; ---------------------
  268. remove_dir proc
  269.     mov ah, 3aH
  270.     lea dx, nombreDirectorio
  271.     int 21H
  272.     ret
  273. remove_dir endp
  274. ; Renombra un directorio
  275. ; ----------------------
  276. rename_dir proc
  277.     mov ah, 56H
  278.     lea dx, nombreDirectorio
  279.     lea di, nuevoDirectorio
  280.     int 21H
  281.     ret
  282. rename_dir endp
  283. ; ------------------------------------------------------
  284. ;     METODOS PARA EL TRABAJO CON PANTALLA             |
  285. ; ------------------------------------------------------
  286. ; Limpia la pantalla
  287. ; ------------------
  288. clear_screen proc
  289.     mov ax, 0600H
  290.     mov bh, 07H
  291.     mov cx, 0000
  292.     mov dx, 184fH
  293.     int 10h
  294.     ret
  295. clear_screen endp
  296. ; Establece la posicion del cursor
  297. ; --------------------------------
  298. set_cursor proc
  299.     mov ah, 02H
  300.     mov bh, 0
  301.     mov dh, row
  302.     mov dl, column
  303.     int 10H
  304.     ret
  305. set_cursor endp
  306. ; Pinta una region
  307. ; Requiere valores de color en BH
  308. ; -------------------------------
  309. paint_region proc
  310.     mov ax, 0600H
  311.     ; mov bh, 4aH
  312.     mov ch, x1
  313.     mov cl, y1
  314.     mov dh, x2
  315.     mov dl, y2
  316.     int 10h
  317.     ret
  318. paint_region endp
  319. ; Opcion 1
  320. ; --------
  321. option1 proc
  322.     ; Pinta su menu
  323.     mov row, 5
  324.     mov column, 5
  325.     call set_cursor
  326.     mov x1, 5
  327.     mov y1, 5
  328.     mov x2, 7
  329.     mov y2, 60
  330.     mov bh, 1aH
  331.     call paint_region
  332.     ret
  333. option1 endp
  334. end begin
Add Comment
Please, Sign In to add comment