The ReadString function
The ReadString function reads user input from the keyboard and stores it in a prepared null-terminated buffer. Input ends when the Enter key is pressed.
Parameters: AX: pointer to the buffer.
Return value: The function does not return a value.
Flag state: The function does not modify the flags.
Program source code
An example program for the Intel 8086 assembler demonstrating the use of the ReadString function to input a string from the keyboard.
title .model small .stack 100h data segment public askUser db "Enter your full name: \0" output db "\nYour full name is \0" buffer db 255 dup(0) data ends code segment public ; Start of the code segment assume ds:data, cs:code include Handyfar.inc ; Include the file with functions main proc ; Start of the main procedure call SetDataSegment ; Call the SetDataSegment procedure lea ax, ds:[askUser] ; Load the address of the variable askUser into the ds:ax register call WriteString ; Call the WriteString procedure (ax:askUser) lea ax, ds:[buffer] ; Load the address of the variable buffer into the ds:ax register call ReadString ; Call the ReadString procedure (ax:buffer) lea ax, ds:[output] ; Load the address of the variable output into the ds:ax register call WriteString ; Call the WriteString procedure (ax:output) lea ax, ds:[buffer] ; Load the address of the variable buffer into the ds:ax register call WriteString ; Call the WriteString procedure (ax:buffer) xor al, al ; Clear the al register call ExitProcess ; Call the ExitProcess procedure main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Enter your full name: Dovgopolov Evgeny Sergeevich
Your full name is Dovgopolov Evgeny Sergeevich
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".