Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 256
- EscribirMensaje MACRO message
- push ax
- push dx
- mov ah, 09
- mov dx, offset message
- int 21h
- pop dx
- pop ax
- ENDM
- .data
- msg1 db 10, 13, 'Tarea 2 - Juan D. Lopez - 2015-0793 $'
- msg2 db 10, 13, 'Escriba una frase o palabra: $'
- msg3 db "Se ingres",162,": $"
- msg4 db 10, 13, "Ingrese la letra a buscar: $"
- msg5 db "Cantidad de letras: $"
- msg6 db 10, 13, "No encontrado $"
- msg7 db 10, 13, "Se deseas salir, pulse la tecla (ESCAPE), si no presiona cualquier letra"
- symbol db 10, 13, "$"
- COUNT db 0
- string db 100 dup ('$')
- _ascii db 0FFH DUP ('$')
- char db ?
- l1 db ?
- string_len dw ?
- .CODE
- MAIN PROC
- mov ax, @DATA
- mov ds, ax
- DisplayPrompt:
- mov count, 0 ; declara el contador a 0
- EscribirMensaje msg1 ; Escribe el mensaje con su funcion
- EscribirMensaje msg2 ; Escribe el mensaje con su funcion
- lea dx, string
- mov ah, 0ah
- int 21h
- ;lea SI, string ; Load effective address
- ;call ReadString
- ;mov string_len, ax
- EscribirMensaje msg3 ; Escribe el mensaje con su funcion
- EscribirMensaje string ; Escribe el mensaje con su funcion
- EscribirMensaje msg4 ; Escribe el mensaje con su funcion
- mov ah, 01h
- int 21h
- mov char, al
- lea si, _ascii
- mov cl, l1
- mov ch, 0
- CHECK:
- mov al, [si]
- cmp char, al
- jne SKIP
- inc count
- SKIP:
- inc si
- loop CHECK
- cmp count, 0
- je NotFound
- EscribirMensaje symbol
- EscribirMensaje msg5
- mov dl, count
- add dl, 30H
- mov ah, 02H
- int 21h
- EscribirMensaje msg7
- start:
- mov ah, 01h
- int 21h
- cmp al, 27
- je Exit
- jmp DisplayPrompt
- NotFound:
- EscribirMensaje msg6
- jmp Exit
- Exit:
- mov ah,4ch
- mov al,00
- int 21h
- MAIN ENDP
- ReadString PROC NEAR
- mov cx, si
- Leer:
- mov ah, 01h
- int 21h
- cmp al, 13
- je Done
- mov [si], al
- inc si
- jmp Leer
- Done:
- mov [si], "$"
- mov ax, si
- sub ax, cx
- ret
- ReadString ENDP
- end MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement