The PrintFormatTime function

The PrintFormatTime function outputs a string containing formatted time. The string may contain specifiers for outputting hours, minutes and seconds: %h, %m, %s.

Parameters: AX: pointer to a null-terminated string.

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 PrintFormatTime function for formatted time output.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

data segment public
    fmtstr db "Current time: [%h:%m:%s]\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     ax, ds:[fmtstr]  ; Load the address of the variable fmtstr into the ds:ax register
        call    PrintFormatTime  ; Call the PrintFormatTime procedure (ax:fmtstr)

        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

Current time: [13:41:17]

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