The IsCntrl function

The IsCntrl function checks whether the given character is a control character (00h-1Fh) or a delete character (7Fh).

Parameters: AL: The character to check.

Return value: ZF = 1: if the character is a control character; ZF = 0: if it is not.

Flag state: The function affects all processor flags.

Program source code

An example program for the Intel 8086 assembler demonstrating the use of the IsCntrl function to check whether a character is a control character.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

data segment public
    true  db "TRUE\0"
    false db "FALSE\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

        mov     al, 9h          ; Copy the tab character into the al register
        call    IsCntrl         ; Call the IsCntrl procedure (al:\t)

        jne     @False          ; If ZF=0, jump to the label @False

    @True:
        lea     ax, ds:[true]   ; Load the address of the variable true into the ds:ax register
        jmp     @Done           ; Perform an unconditional jump to the label @Done

    @False:
        lea     ax, ds:[false]  ; Load the address of the variable false into the ds:ax register

    @Done:
        call    WriteString     ; Call the WriteString procedure

        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

TRUE

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