8086 ALP String Display

Discussion in 'Programmer's Corner' started by karki, Jul 19, 2014.

  1. karki

    Thread Starter New Member

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

    Code ( (Unknown Language)):
    1.  
    2. Title Get the string from keyboard and display it
    3.  
    4. .model small
    5. .stack 100h
    6. .data
    7.     str1 db 'Enter String ','$'
    8.     str2 db 50 dup('$')
    9.     str3 db 0dh, 0ah, '$'
    10. .code
    11.  
    12. main proc
    13.     mov ax,@data
    14.     mov ds,ax
    15.    
    16.     mov ah,09h     ; for displaying Enter String
    17.     lea dx,str1
    18.     int 21h
    19.    
    20.  
    21.     mov ah,0ah      ; for taking i/p from keyboard
    22.     lea dx,str2
    23.     int 21h
    24.    
    25.    
    26.     mov ah,09h  ; for displaying in new line
    27.     lea dx,str3
    28.     int 21h
    29.    
    30.     mov ah,09h          ; for displaying what you have entered
    31.     lea dx,str2+2
    32.     int 21h
    33.    
    34.     int 21h
    35.     mov ah,4ch
    36.     int 21h
    37.     main endp
    38.  
    39. end main
    40.  

    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: Jul 19, 2014
  2. karki

    Thread Starter New Member

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

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,729
    Look at what the DOS Buffer looks like for buffered input, and then tell us.
     
  4. karki

    Thread Starter New Member

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

    AAC Fanatic!

    Jun 6, 2011
    2,677
    2,729
    Look at how you initialized STR2.
     
Loading...