WinInc CUI Sample 2

1. About

Another "hello world" sample for WinInc, this one uses printf() from MSVCRT to display its text.

2. Source Code

WINCUI2.ASM
;+---------------------------+
;|  use CRT (MSVCRT) in ASM  |
;+---------------------------+

        .386
        .MODEL FLAT, stdcall
        option casemap:none

ifndef __POASM__
        .nolist
        .nocref
endif        
WIN32_LEAN_AND_MEAN equ 1
        include windows.inc
        include stdio.inc
ifndef __POASM__        
        .cref
        .list
endif        

;--- CStr(): macro function to simplify defining a string

CStr macro pszText:REQ
local szText
    .const
szText  db pszText,0
    .code
    exitm 
endm

        .CODE

main    proc c

        invoke printf, CStr(<"Hello, world!",10>)
        ret

main    endp

mainCRTStartup proc c
        call main
        invoke ExitProcess, 0
mainCRTStartup endp

        end mainCRTStartup
 

3. Explanations

WIN32_LEAN_AND_MEAN equ 1
        include windows.inc
        include stdio.inc
 
WinInc does not contain a library of helper functions (like M32LIB in MASM32). Instead it is recommended to use CRT libraries, if any. Directly supported by WinInc are the CRT dlls MSVCRT and CRTDLL. The first is a redistributable binary included in MS VC (and most likely present on a Windows machine), the latter is supplied with all versions of Windows.