The StringCopyIfNot function

The StringCopyIfNot function copies the elements of a null-terminated string into a prepared buffer if they do NOT satisfy the condition specified by the function passed through the pointer.

Parameters: DS:AX - source string; ES:BX - destination buffer; CX - pointer to the condition function.

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 StringCopyIfNot function to copy characters that do NOT satisfy the condition.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

data segment public
    string db "Hel1lo Wo2rld!\0"
    buffer db 20 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     cx, IsDigit      ; Load the address of the IsDigit procedure into the cx register
        lea     bx, es:[buffer]  ; Load the address of the variable buffer into the es:bx register
        lea     ax, ds:[string]  ; Load the address of the variable string into the ds:ax register
        call    StringCopyIfNot  ; Call the StringCopyIfNot procedure (ds:ax, es:bx, cx)

        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

Hello World!

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