StringJoinEx function

The StringJoinEx function joins an array of strings into one using the specified separator. The parameters are passed through the stack. The function automatically aligns the stack to 8 bytes.

Parameters (stack): 1. Pointer to the array of strings. 2. Pointer to the buffer. 3. Number of strings. 4. Separator character.

Return value: The function does not return a value.

Flag state: The function does not modify the flags.

Program source code

Intel 8086 assembly program example demonstrating the use of the StringJoinEx function to join an array of strings with a separator.

title Author: Evgeny Sergeevich Dovgopolov

.286C
.model small
.stack 100h

data segment public
    string db "My\0", "name\0", "is\0", "Evgeny Dovgopolov\0"
    buffer db 100 dup(0)
data ends

code segment public
    assume  ds:data, cs:code
    include Handyfar.inc        ; Include the file with functions
    include Handymac.inc        ; Include the file with macros

    main proc
        call    SetDataSegment  ; Call the SetDataSegment procedure

        push    ' '             ; 4th: Push the value of the ' ' character onto the stack
        push    4               ; 3rd: Push the number 4 onto the stack
        pushs   es:[buffer]     ; 2nd: Push the address of variable buffer onto the stack
        pushs   ds:[string]     ; 1st: Push the address of variable string onto the stack
        call    StringJoinEx    ; Call procedure StringJoinEx(string, buffer, 4, ' ')

        pushs   ds:[buffer]     ; Push the address of variable buffer onto the stack
        call    WriteStringEx   ; Call procedure WriteStringEx(buffer)

        push    0               ; Push the byte return code onto the top of the stack
        call    ExitProcessEx   ; Call the ExitProcessEx(0) procedure
    main endp

code ends
end main

My name is Evgeny Dovgopolov

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