;PROGRAM TO INSERT '#' BEFORE EVERY 'p' IN THE GIVEN STRING
data segment
list db 'aopresgdjpssp','$'
i db '#'
bfr db 'p'
count equ $-list
list1 db count+1 dup(0)
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov cl,count
mov si,offset list
mov di,offset list1
mov ah,i
inc di
lp:
mov al,[si]
cmp al,bfr
je is
mov [di],al
inc si
inc di
jmp cnt
is:
mov [di],ah
inc di
mov [di],al
inc di
inc si
cnt:
dec cl
jnz lp
mov ah,09h
mov dx,offset list
int 21h
mov dx,offset list1
int 21h
int 3
code ends
end start
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment