SAMPLE: Writing a Windows Application Using MASM 6.0

Last reviewed: February 15, 1996
Article ID: Q77256
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

Using the high-level language features of the Microsoft Macro Assembler (MASM) version 6.0, it is now much simpler to write a complete Windows program in MASM than with previous versions of the program.

A program called MASMWIN in the Microsoft Software Library demonstrates what is required to write a complete Windows program using MASM 6.0.

Download MASMWIN.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download MASMWIN.EXE (size: 44105 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get MASMWIN.EXE (size: 44105 bytes) 
    

MASMWIN demonstrates a number of features of MASM 6.0. It demonstrates the use of alternate PROLOGUE and EPILOGUE code generation. It also demonstrates function prototyping and the use of the INVOKE feature.

While MASM provides a complete programming environment with high-level language features, applications written in MASM will be much more difficult to transfer to future versions of Windows that run on non- Intel platforms.

MORE INFORMATION

Using the OPTION:PROLOGUE and OPTION:EPILOGUE directives in MASM 6.0, an application can cause MASM 6.0 to generate any type of prologue or epilogue code desired. For this program, it creates the appropriate Windows code. The macros to perform this task are contained in the file WINPRO.INC. The two declarations, ?WINDOWS=1 and ?PMODE=1, affect the generation of the prologue and epilogue code.

The ?WINDOWS=1 declaration will cause Windows prologue and epilogue code to be generated for all FAR functions. All other functions are declared with the normal function stack frame.

The ?PMODE=1 declaration causes the Windows prologue and epilogue code to be generated only for FAR functions declared as EXPORT. This code takes advantage of the fact that in protected mode, Windows does not walk the stack.

The program includes a WINDOWS.INC file that is different from the one included in Windows Software Development Kit (SDK) version 3.0. This WINDOWS.INC file was created by running WINDOWS.H through the H2INC utility provided with MASM 6.0. This provides prototypes for all of the Windows functions and also translates C structures to corresponding MASM structures. This file allows the INVOKE feature of MASM 6.0 to be used to call Windows functions. The INVOKE function handles all the parameter passing and stack clean up. To use this file, it is necessary to include the following line in the source code before the line that includes the new WINDOWS.INC:

   OPTION CASEMAP:NONE

This causes the assembler to maintain case sensitivity when dealing with symbols.


Additional reference words: 3.00 3.10 softlib MASMWIN.EXE
KBCategory: kbtool kbfile
KBSubcategory: TlsMisc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.