Reputation: 109
I am trying to get the input string from keyboard and redisplay it abut I dont know why I am getting a message twice. For example: Enter your string:1234567 The output will be
Your input:1234567 Your input:
And I wonder why I am getting it twice. Here is my code:
data segment
prompt db 0dh,0ah,"Enter your string(7 Chars Max): $"
nam db 8 dup(?) ; 7 plus term char $
msg1 db 0dh,0ah,"Your input: $"
sev db 7 dup(?)
data ends
code segment
assume cs:code,ds:data
START:
mov ax,data
mov ds,ax
mov dx,offset prompt
mov ah,09h
int 21h
lea si,nam
mov cx,7
et:mov ah,01
int 21h
mov [si],al
inc si
loop et
mov si+sev,'$'
mov dx,offset msg1
mov ah,09h
int 21h
lea dx,nam
mov ah,09h
int 21h
mov ah,4ch
int 21h
Code ends
end Start
Upvotes: 1
Views: 2772
Reputation: 31143
I assume with the line mov si+sev, '$'
you are trying to add the end marker to the string. This is not correct since sev
is another memory block of seven bytes so adding its offset to si
will point to somewhere completely different and may even cause problems.
Since you're reading values and incrementing si
each time you can just use mov [si], '$'
to write the end marker after the last character read.
Upvotes: 2