Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .model small
  2. .stack 256
  3.  
  4. EscribirMensaje MACRO message
  5.   push ax
  6.   push dx
  7.   mov ah, 09
  8.   mov dx, offset message
  9.   int 21h
  10.   pop dx
  11.   pop ax
  12. ENDM
  13.  
  14. .data
  15.  
  16. msg1        db 10, 13, 'Tarea 2 - Juan D. Lopez - 2015-0793 $'
  17. msg2        db 10, 13, 'Escriba una frase o palabra: $'
  18. msg3        db "Se ingres",162,": $"
  19. msg4        db 10, 13, "Ingrese la letra a buscar: $"
  20. msg5        db "Cantidad de letras: $"
  21. msg6        db 10, 13, "No encontrado $"
  22. msg7        db 10, 13, "Se deseas salir, pulse la tecla (ESCAPE), si no presiona cualquier letra"
  23. symbol      db 10, 13, "$"
  24. COUNT       db 0
  25. string      db 100 dup ('$')
  26. _ascii      db 0FFH DUP ('$')
  27. char        db ?
  28. l1          db ?
  29. string_len  dw ?
  30.  
  31. .CODE
  32. MAIN PROC
  33.     mov     ax, @DATA
  34.     mov     ds, ax
  35.  
  36. DisplayPrompt:
  37.   mov count, 0            ; declara el contador a 0
  38.   EscribirMensaje msg1    ; Escribe el mensaje con su funcion
  39.   EscribirMensaje msg2    ; Escribe el mensaje con su funcion
  40.  
  41.   lea dx, string
  42.   mov ah, 0ah
  43.   int 21h
  44.  
  45.  
  46.   ;lea SI, string          ; Load effective address
  47.   ;call ReadString
  48.   ;mov string_len, ax
  49.  
  50.   EscribirMensaje msg3    ; Escribe el mensaje con su funcion
  51.   EscribirMensaje string   ; Escribe el mensaje con su funcion
  52.   EscribirMensaje msg4    ; Escribe el mensaje con su funcion
  53.  
  54.   mov ah, 01h
  55.   int 21h
  56.   mov char, al
  57.  
  58.   lea si, _ascii
  59.  
  60.   mov cl, l1
  61.   mov ch, 0
  62.  
  63. CHECK:
  64.   mov al, [si]
  65.   cmp char, al
  66.   jne SKIP
  67.   inc count
  68.  
  69. SKIP:
  70.   inc si
  71.   loop CHECK
  72.  
  73.   cmp count, 0
  74.   je NotFound
  75.  
  76.   EscribirMensaje symbol
  77.  
  78.   EscribirMensaje msg5
  79.   mov dl, count
  80.   add dl, 30H
  81.   mov ah, 02H
  82.   int 21h
  83.  
  84.   EscribirMensaje msg7
  85.  
  86.   start:
  87.     mov ah, 01h
  88.     int 21h
  89.     cmp al, 27
  90.     je Exit
  91.  
  92.   jmp DisplayPrompt
  93.  
  94. NotFound:
  95.   EscribirMensaje msg6
  96.   jmp Exit
  97.  
  98.  
  99. Exit:
  100.   mov ah,4ch
  101.   mov al,00
  102.   int 21h
  103.  
  104. MAIN ENDP
  105.  
  106. ReadString PROC NEAR
  107.     mov cx, si
  108.   Leer:
  109.     mov ah, 01h
  110.     int 21h
  111.     cmp al, 13
  112.     je Done
  113.     mov [si], al
  114.     inc si
  115.     jmp Leer
  116.   Done:
  117.     mov [si], "$"
  118.     mov ax, si
  119.     sub ax, cx
  120.   ret
  121. ReadString ENDP
  122.  
  123.  
  124. end MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement