Monday, August 15

Replacing the Space By Underscore In A String Input Using Assembly Programming Language

.model small
.code
org 100h
jmp process
    parlist label byte
    maxlen db 30
    actlen db ?
    kbwill db 30 dup(' ')
   
    intro db 'Enter Word: ','$'
    storage db 30 dup(' ')

    out db 'Output: ','$'
input:
    mov ah,0ah
    lea dx,parlist
    int  21h
    ret
printing:
    mov ah,09h
    int 21h
    ret
clr_scr:
    mov ax,0600h
    mov bh,07h
    mov cx,0000h
    mov dx,184fh
    int 10h
    ret
set_cur:
    mov ah,02h
    mov bh,00h
    int 10h
    ret

process proc near
    call clr_scr
    mov dx,0000h
    call set_cur
    lea dx,intro
    call printing
    call input
    mov dx,0305h
    call set_cur
    mov si,00h
    mov di,00h
    mov ch,00h
    mov cl,actlen
    call processing
    mov dx,0505h
    call set_cur
    lea dx,out
    call printing
    mov storage[si],'$'
    lea dx,storage
    call printing
    int 20h
    process endp
    end process
processing:
    cmp si,cx
    je return
    mov dl,kbwill[si]
    cmp dl,' '
    je replace
    jne insert
return:
    ret
replace:
    mov storage[di],'_'
    inc di
    inc si
    jmp processing
insert:
    mov storage[di],dl
    inc di
    inc si
    jmp processing


/*Program Preview*/


No comments:

Post a Comment