; print the string in reverse manner
;----------------------------------------------------------------------------
.model small
.data
message_display macro msg
mov dx,offset msg
mov ah,09h
int 21h
endm
msg1 db 10,13, "Enter the string $"
msg2 db 10,13, "Reversed string is $"
msg3 db 10,13, "$"
string db 10h dup(0)
len db 00h
.code
mov ax,@data
mov ds,ax
message_display msg1
lea si,string
next_char: mov ah,01h
int 21h
mov [si],al
inc si
inc len
cmp al,0dh
jnz next_char
mov al,24h
mov [si],al
inc len
message_display msg2
message_display msg3
mov bh,len
loop1: mov dl,[si]
mov ah,02h
int 21h
dec si
dec bh
jnz loop1
mov ah,4ch
int 21h
end
;------------------------------------------------------------------------------------
; done by prof. Dhumane A.V. VIIT, Pune
No comments:
Post a Comment