Monday, March 26, 2012

accept and display string in assembly X86

; accept and display string
;---------------------------------------------------------------------------
.model small

.data

display_message macro msg
mov dx,offset msg
mov ah,09h
int 21h
endm

msg1 db 10,13,"Enter the String $"
msg2 db 10,13,"String is $"
msg3 db 10,13,"$"
array db 10h dup(0)

.code
mov ax,@data ; intialization of data segment rgistr
mov ds,ax

display_message msg1

lea si,array


accept_next_char:
mov ah,01h
int 21h
mov [si],al
inc si
cmp al,0dh ; 0dh is enter character
jnz accept_next_char

mov al,24h ; 24h is '$' character
mov [si],al

display_message msg2
display_message msg3
display_message array

mov ah,4ch ; proram termination
int 21h
end

;-----------------------------------------------------------------------------------------
; done by prof. Dhumane A.V. VIIT, Pune

No comments:

Post a Comment