Количество введнных символов!!!

Низкоуровневое программирование портов, микроконтроллеров и т.д.

Модератор: Andy

Ответить
Xabar
Сообщения: 1
Зарегистрирован: 08 окт 2006, 14:29

Здравствуйте!
После ввода символов и считывания их, в blength окзывается количество введенных символов, каким образом это происходит?

Вот часть кода программы на ассемблере:
mov dx,offset message1
mov ah,9
int 21h ; вывести приглашение ко вводу message1
mov dx,offset buffer
mov ah,0Ah
int 21h ; считать строку символов в буфер
mov dx,offset crlf
mov ah,9
int 21h ; перевод строки

messagel db "Десятичное число: $"
err_msg db "Ошибка ввода"
crlf db 0Dh,0Ah,'$'
buffer db 6 ; максимальный размер буфера ввода
blength db ? ; размер буфера после считывания
bcontents: ; содержимое буфера располагается за
; концом СОМ-файла
end start
Аватара пользователя
somewhere
Сообщения: 1858
Зарегистрирован: 31 авг 2006, 17:14
Откуда: 71 RUS
Контактная информация:

7.1.11. Int 21H Function 0AH
Description:
Buffered Keyboard Input
Reads a string of bytes from the standard input device, up
to and including an ASCII carriage return (0DH), and places
them in a user-designated buffer. The characters are echoed to
the standard output device. Input may be redirected (if input
has been redirected, there is no way to detect EOF).
Input Output
------------------------------ ------
AH=0AH Nothing
DS :D X=segment :o ffset of buffer
- The buffer used by this function has the following format:
Byte
Contents
0
maximum number of characters to read, set by
program
1
number of characters actually read (excluding
carriage return), set by MS-DOS
2+
string read from keyboard or standard input,
terminated by a carriage return (0DH)
- If the buffer fills to one fewer than the maximum number
of characters it can hold, subsequent input is ignored and
the bell is sounded until a carriage return is detected.
- This input function is buffered with type-ahead
capability, and all of the standard keyboard editing
commands are active.
Interrupt 21H, Character-Oriented Functions


- If the standard input is not redirected, and a CTRL+C is
detected at the console, an Int 23H is executed. If the
standard input is redirected, a CTRL+C is detected at the
console, and BREAK is ON, an Int 23H is executed.
- See Int 21H Functions 01H, 06H, 07H, and 08H for
single-character input from the keyboard or standard input
device.
- You can also read strings from the keyboard by performing
a read (Int 21H Function 3FH) using the predefined handle
for the standard input (0000H), if it has not been
redirected, or using a handle obtained by opening the
logical device CON.
It's a long way to the top if you wanna rock'n'roll
Аватара пользователя
somewhere
Сообщения: 1858
Зарегистрирован: 31 авг 2006, 17:14
Откуда: 71 RUS
Контактная информация:

Байт 0 - максимальная длина буффера
Байт 1 - реальное количество введенных символов (заполняется после вызова)
Байт 2 и т.д. - собственно, сам буффер
It's a long way to the top if you wanna rock'n'roll
Ответить