The StringJoin function

The StringJoin function joins an array of strings using the specified delimiter and stores the result in a prepared buffer.

Parameters: DS:AX - pointer to the array of strings; ES:BX - pointer to the buffer; CX - number of strings; DL - delimiter character.

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 StringJoin function to join an array of strings with a delimiter.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

data segment public
    string db "My\0", "name\0", "is\0", "Evgeny\0"
    buffer db 100 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

        mov     dl, ' '            ; Copy the space character value into the dl register
        mov     cx, 4              ; Set the number of words equal to 4
        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    StringJoin         ; Call the StringJoin procedure (ds:ax, es:bx, cx:4, dl:' ')

        lea     ax, ds:[buffer]    ; Load the address of the variable buffer into the ds:ax register
        call    PrintFormatString  ; Call the PrintFormatString 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

My name is Evgeny

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