I wrote a code that receives characters from the console, and then outputs them, the length of the string that can be entered is 30 characters, and everything works correctly when I enter from 10 to 28 characters, but when I enter a string of 29 characters long, I get strange values at the output.
Could you tell me what the problem might be?
================================================================
Code:
.model small
.data
inputinvite db 'Input: $'
output db 'Output: $'
inputmsg db 30,(?),30 dup ('$') ;Выделяем 32 байта из которых 1 байт будет хранить 30(максимальное количество символов)
;2 байт будет хранить количество символов в строке, оставшиеся 30 хранят саму строку
.code
start:
;Устанавливаем ds адрес сегмента .data
mov ax,@data
mov ds,ax
;///////////////////////////
;Выводим приграшение на ввод
mov dx,offset inputinvite
mov ah,9
int 21h
;///////////////////////////
;Передаем исполнение прерыванию ввода
mov dx,offset inputmsg
mov ah,10
int 21h
;///////////////////////////
;Выводим введенные данные
mov dx,offset output
mov ah,9
int 21h
mov dx,offset inputmsg+2
mov ah,9
int 21h
;///////////////////////////
;Задержка чтобы програма не закрывалась сразу
mov dx,0
mov ah,10
int 21h
;///////////////////////////
;Завершение программы
mov ax,4c00h
int 21h
;///////////////////////////
.stack 10
end start
It was expected that when entering 29 characters (the maximum number), the output would be the same as when entering fewer characters