Program in Assembly to REVERSE content of string -MASM 8086)

Program in Assembly to REVERSE content of string -MASM 8086)

org 100h
.stack 100h
.data
str db "RANA AHSAN ALI$"
strlen db 0
.code
mov bl,0
mov si,offset str
;===========Finding length of string=================
L:
cmp [si],'$'
je lout
inc bl
inc si
LOOP L
lout:
mov strlen,bl
;=================PUSH in stack======================
mov cl,bl
mov si,offset str
ex:
push [si]
inc si
LOOP ex
;=============POPING from stack====================
mov si,offset str
mov cl,strlen
p:
pop [si]
inc si
LOOP p
mov [si],'$'
;===============PRINTING of reversed string========
lea dx,str
mov ah,09h
int 21h
mov ah,4ch
int 21h
ret

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s