Program "Input string and Display each word in next line" for 8086 microprocessor

title ALP for 8086 microprocessor to read a string from keyboard
title display each word at separate line.
title The length of input string can be up to 60 characters.
.model small
.stack 100h
.data
msg db 60 dup(?)
.code
start:
    mov ax,@data
    mov ds,ax
    mov si,offset msg
take: mov ah,1
    int 21h
    mov [si],al
    cmp al,13
    je display
    inc si
    jmp take
 
display: mov [si],'$'
    mov dl,10
    mov ah,2
    int 21h
 
    lea di,msg
 
palo: mov dl,[di]
    cmp dl,'$'
    je stop
    cmp dl,' '
    je next
    mov ah,2
    int 21h
    inc di
    jmp palo
 
next: mov dl,10
    mov ah,2
    int 21h
    inc di
    jmp palo
 
stop: mov ah,4ch
    int 21h
end start
end

No comments:

Post a Comment