; ===========================================================================
; FILE    : hello.asm
; SUBJECT : Program to demonstrate assembly language on the Win32 platform.
; AUTHOR  : Peter C. Chapin <PChapin@vtc.vsc.edu>
;
; This is the classic "Hello, World" program. It is a bit complicated in assembly language
; because of the need to interact with the Windows API to get the output printed. assemble this
; program using the Open Watcom assembler use the following commands:
;
;   > wasm hello.asm
;   > wlink sys nt debug watcom file hello.obj
;
;===========================================================================

                .586
                .MODEL FLAT
        
                ; Windows API functions.
                EXTERN   _GetStdHandle@4:PROC
                EXTERN   _WriteConsoleA@20:PROC

                GLOBAL   _WinMain@16:PROC
        
                ; Symbolic names. These special values are meaningful to GetStdHandle.
GET_STDINPUT    EQU    -10
GET_STDOUTPUT   EQU    -11
GET_STDERROR    EQU    -12
CR              EQU     13
LF              EQU     10

                .DATA
stdout          DD      0
Message         DB      "Hello, World!", CR, LF
Written         DD      15

        
                .CODE
        
_WinMain@16     PROC
                ; Get the handle to the screen buffer.
                push    GET_STDOUTPUT
                call    _GetStdHandle@4
                mov     stdout, eax

                ; Display a friendly message.
                push    0
                push    OFFSET Written
                push    Written
                push    OFFSET Message
                push    stdout
                call    _WriteConsoleA@20
                ret
_WinMain@16     ENDP

                END _WinMain@16
