I have written a code for 8086 microprocessor for taking string from keyboard and displaying it as follow
I don't understand why we have to give effective address of the string as str+2 to print the inputted string back ? If simply lea dx, str2 is used no string is displayed.
Thanks in advance.
Rich (BB code):
Title Get the string from keyboard and display it
.model small
.stack 100h
.data
str1 db 'Enter String ','$'
str2 db 50 dup('$')
str3 db 0dh, 0ah, '$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h ; for displaying Enter String
lea dx,str1
int 21h
mov ah,0ah ; for taking i/p from keyboard
lea dx,str2
int 21h
mov ah,09h ; for displaying in new line
lea dx,str3
int 21h
mov ah,09h ; for displaying what you have entered
lea dx,str2+2
int 21h
int 21h
mov ah,4ch
int 21h
main endp
end main
I don't understand why we have to give effective address of the string as str+2 to print the inputted string back ? If simply lea dx, str2 is used no string is displayed.
Thanks in advance.
Last edited: