Printing a one-dimensional array

A program that prints the elements of a one-dimensional array.

Program source code

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

data segment public
    strout db  "Array elements: \0"
    array  dw  54, 26, 8831, 23, -16, 76, 84, 13, 456, -3
    arrlen equ ($-array) / 2 ; Compute the array length
    fmtout db  "%d \0"
data ends

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

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

        lea     ax, ds:[strout]    ; Load the address of the strout variable into the ax register
        call    WriteString        ; Call the WriteString procedure

        lea     bx, ds:[array]     ; Load the address of the array variable into the bx register
        mov     cx, arrlen         ; Set the counter to the length of the array

    PrintArrayLoop:
        push    word ptr[bx+si]    ; 2nd: save the value at bx with index si on the stack
        lea     ax, ds:[fmtout]    ; 1st: load the address of the fmtout format string into ax
        call    PrintFormatString  ; Call the PrintFormatString procedure
        add     sp, 2              ; Align the stack
        incw    si                 ; Call the incw macro. Increment the si index by 2
        loop    PrintArrayLoop     ; Loop while CX≠0

        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

Array elements: 54 26 8831 23 -16 76 84 13 456 -3

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