32-Bit Flat Memory Model MASM Code for Windows NTLast reviewed: January 23, 1995Article ID: Q94314 |
The information in this article applies to:
SUMMARYThe Microsoft Macro Assembler (MASM) versions 6.0a and later support generating 32-bit flat memory model code through the .MODEL flat directive. When combined with the CVTOMF and LINK32 utilities and the KERNEL32.LIB library distributed with the Windows NT software development kit (SDK) or the LINK utility and the KERNEL32.LIB library distributed with Microsoft Visual C++ for Windows NT, MASM can generate a 32-bit flat memory model application for the Windows NT environment. Because MASM version 6.0 does not properly support the _stdcall convention, it cannot be used to generate applications for the Windows NT environment.
MORE INFORMATIONGiven some MASM code in a file named FLAT32.ASM where its entry point is _start, to assemble this code into a 32-bit flat memory model application for the Windows NT environment, perform the following four steps:
Windows NT does not support the MLX driver provided with MASM versions 6.0a and 6.0b. Also, Windows NT does not support the MS-DOS-extender used by MASM versions 6.1 and 6.1a. Therefore, it may be necessary to perform the assembly step on a machine running MS-DOS while the other steps run on a machine running Windows NT. Another option is to upgrade to MASM version 6.11. The code below is a "Hello, world" application developed in assembler to use the 32-bit flat memory model of Windows NT.
Sample Code; Assemble options needed: /c .386 .MODEL flat, stdcall STD_OUTPUT_HANDLE EQU -11 GetStdHandle PROTO NEAR32 stdcall, nStdHandle:DWORDWriteFile PROTO NEAR32 stdcall, hFile:DWORD, lpBuffer:NEAR32, nNumberOfBytesToWrite:DWORD, lpNumberOfBytesWritten:NEAR32, lpOverlapped:NEAR32ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD.STACK 4096 .DATA msg DB "Hello, world.", 13, 10 written DW 0 hStdOut DD 0 .CODE _start: INVOKE GetStdHandle, STD_OUTPUT_HANDLE ; Standard output handle mov hStdOut, eax INVOKE WriteFile, hStdOut, ; File handle for screen NEAR32 PTR msg, ; Address of string LENGTHOF msg, ; Length of string NEAR32 PTR written, ; Bytes written 0 ; Overlapped mode INVOKE ExitProcess, 0 ; Result code for parent processPUBLIC _start END
|
Additional reference words: kbinf 6.00a 6.00b 6.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |