Monday, August 15

Printing The Characters Of Two String Inputs In Alernating Manner Using Assembly Programming Language


.model small
.code
org 100h
jmp process
                parlist label byte
                maxlen db 30
                actlen db ?
                kbwill1 db 30 dup(' ')
               
                paralist label byte
                maxnlen db 30
                actnlen db ?
                kbwill2 db 30 dup(' ')
               
                intro1 db 'Enter Word1: ','$'
                intro2 db 'Enter Word2: ','$'
                storage db 60 dup(' ')
                mana db 'Press Any Key To Continue','$'
                rr db ?
                r1 db ?
               
input1:
                mov ah,0ah
                lea dx,parlist
                int  21h
                ret
input2:
                mov ah,0ah
                lea dx,paralist
                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,intro1
                call printing
                call input1
                mov dx,0100h
                call set_cur
                lea dx,intro2
                call printing
                call input2
                mov si,00h
                mov di,00h
                mov ch,00h
                mov cl,actlen
                mov al,actnlen
                mov ah,00h
                mov bx,0000h
                call processing
                mov dx,0505h
                call set_cur
                mov storage[bx],'$'
                lea dx,storage
                call printing
                mov dx,0905h
                call set_cur
                lea dx,mana
                call printing
                mov ax,071ch
                int 21h
                int 20h
                process endp
                end process
processing:
                 jmp word1
               
word1:
                cmp si,cx
                je compare2
                mov dl,kbwill1[si]
                mov storage[bx],dl
                inc si
                add bx,01h
                jmp word2
word2:
                cmp di,ax
                je compare1
                mov dl,kbwill2[di]
                mov storage[bx],dl
                inc di
                add bx,01h
                jmp processing
compare1:
                cmp si,cx
                je return
                jne word1
compare2:
                cmp di,ax
                je return
                jne word2
return:
                ret


/*Program Preview*/

No comments:

Post a Comment