I have this assembly code that reads a string of 120 bytes. If I try to fill the buffer by pressing a key until it stops writing, the enter key doesn't work. I counted the characters and I found that I have written 121 characters.
Is this normal? Is there a way to avoid it? Another interruption perhaps?
The code:
.model small
.stack 100h
.386
.data
MSG DB "Please give me the string (max 120 chars): ", 10, 13, "$"
Sentence1 DB 121,?,121 dup(0)
.code
start:
mov ax, @data
mov ds, ax
mov ah,09h
lea dx,A
int 21h
xor ax,ax
mov dx, offset Sentence1
mov ah, 0Ah
int 21h
xor bx,bx
mov bl, Sentence1[1]
mov Sentence1[bx+2], '$'
mov ah, 4ch
int 21h
end start
An example (imagine that is a 11 bytes buffer and not 121 bytes, for brevity):
Please give me the string (max 10 chars):
AAAAAAAAAAA
\_________/
|
11 As
If I press Enter at this point it doesn't work, but if I delete an A and press Enter, then it works.
I use Tasm and Tlink for compiling.
Regards.
[Edit] A typo.