8086 ALP String Display

Thread Starter

karki

Joined Jul 19, 2014
3
I have written a code for 8086 microprocessor for taking string from keyboard and displaying it as follow

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:

Thread Starter

karki

Joined Jul 19, 2014
3
As I new to this forum, I don't know the much details about different features available here. Anyway thanks for your edit.
 

Thread Starter

karki

Joined Jul 19, 2014
3
If offset 00 and 01 stores something then why it is not displaying anything when using str2 or str2+0 instead of str2+2.
 
Top