You are on page 1of 2

.

model small
.stack 100h
.data
str byte "JahanGul",0Ah,0Dh,'$'
s byte "zeb"
temp byte 20 dup(?)
i word 5h
.code
main proc
mov ax,@data
mov ds,ax
mov si,offset str
mov di,offset s
mov bx,offset temp

mov cx,lengthof str


jmp insrt

cont:
jmp exit
;------------------
insrt:
mov ax,i
add ax,si
mov si,ax
mov ax,i
sub cx,ax
;------------------
start:
mov al,[si]
mov [bx],al
;
inc bx
inc si
loop Start
;------------------
mov cx,lengthof s ; cx = 3
mov si,offset str
mov ax,i
add si,ax

strt2:
mov ah,[di]
mov [si],ah
; overwriting
inc si
inc di

loop strt2
;--------------------
mov cx,lengthof temp
mov bx,offset temp
strt3:
mov ah,[bx]
mov [si],ah
; Recover the overwriting string from temp
inc bx
inc si
loop strt3
;---------------------
jmp cont

exit:

mov ax,0900h
mov dx,offset str
int 21h
mov ax,4c00h
int 21h
main endp
end main

You might also like