New project

Create a new folder named 'mosaic' in your asm projects folder (it is adviceable to create this folder on the same drive as the MASM package so you can use the relative lib/include paths in the examples.

Download this ZIP file and extract it's contents in your 'mosaic' folder: mosaic_lesson_files.zip

1.1 - Basic files

The ZIP contains the basic (almost empty) files for your project. Here's a short description of the files:

Mosaic.asm

;=================================================================
; Mosaic.asm
;=================================================================
.486
.model flat, stdcall
option casemap: none

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\comdlg32.lib
include \masm32\include\kernel32.inc
include \masm32\include\comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\windows.inc
include mosaic.inc

.code
start:

end start

This file contains the framework for a win32 asm source file.

.486: indicates to use the 486+ assembly instructions
.model flat, stdcall: defines the memory model (flat) and the calling convention (stdcall)
includelib / include: These include the libraries and include files for the windows functions needed. The windows.inc includes basic windows constants. The mosaic.inc contains your own constants.
.code: select code segment
start: just a label, could be anything
end start: indicates that the entry point of your program is at a label called start.

Mosaic.inc

;---- msgbox macro: usage MSGBOX "string to display" -------
MSGBOX MACRO msg:REQ
LOCAL @msg
.data
@msg db msg, 0
.code
invoke MessageBox, NULL, ADDR @msg, ADDR AppName, MB_OK
ENDM

In mosaic.inc there is a little macro to simplify the use of MessageBoxes. A macro is a piece of code that can contain variables (here msg for example), which you can then use in your code and will be replaced by the macro code when assembling. I don't go into details about macro's right now, just remember you can show a msgbox in your program by using:

msgbox "Your string to display"

make.bat

@echo off
ml /c /coff mosaic.asm
rc -r mosaic.rc
link /subsystem:windows mosaic.obj mosaic.res
pause>nul

Use this batch file to assemble and link your program. The rc command will compile your resources.

resources\

This folder contains some bitmaps and icons we will use in our program:

Big program icon Small program icon Toolbar image Demo image
Big icon
(big.ico)
Small icon
(small.ico)
Toolbar buttons
(Toolbar.bmp)
Demo game picture
(demo.bmp)