The GetChar function

The GetChar function reads a single character entered by the user from the keyboard and returns it in the AL register. This makes it possible to obtain input from the user in text mode.

Parameters: The function takes no parameters.

Return value: AL: The code of the entered character.

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 GetChar function to read a character from the keyboard.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

code segment public             ; Start of the code segment
    assume  cs:code
    include Handyfar.inc        ; Include the file with functions

    main proc                   ; Start of the main procedure
        call    SetDataSegment  ; Call the SetDataSegment procedure

        call    GetChar         ; Call the GetChar procedure
        call    PrintNewLine    ; Call the PrintNewLine procedure
        call    PutChar         ; Call the PutChar procedure (al)

        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

A

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".