Microsoft KB Archive/72698

= Using Full Segment Directives with MASM 6.0 HELLO.ASM =

Article ID: 72698

Article Last Modified on 10/17/2003

-

APPLIES TO


 * Microsoft Macro Assembler 6.0 Standard Edition
 * Microsoft Macro Assembler 6.0a
 * Microsoft Macro Assembler 6.0b

-



This article was previously published under Q72698



SUMMARY
The &quot;Microsoft Macro Assembler Programmer's Guide&quot; for MASM version 6.0 has a HELLO.ASM example for OS/2 on page 458, section 17.3, and has the same example using INVOKE on page 459. Both examples use simplified dot directives. The code sample below shows how the examples may be assembled using full segment directives.



MORE INFORMATION
The code that the assembler generates with the INVOKE directive is placed in comment lines below each INVOKE.

With INVOKE, the assembler generates code depending on the prototypes for the DosWrite and DosExit functions declared in the include file BSEDOS.INC. Both the prototypes indicate the PASCAL calling convention. In BSEDOS.INC, DosWrite is prototyped as: DosWrite PROTO FAR PASCAL \ hf:Hfile, bBuf:PVOID, cbBuf:WORD, pcbBytesWritten:PWORD DosExit is prototyped in BSEDOS.INC as: DosExit PROTO FAR PASCAL fTerminate:BOOL, usExitCode:WORD In OS2DEF.INC, PVOID is typedefined as: PVOID TYPEDEF FAR PTR PWORD is typedefined as: PWORD TYPEDEF FAR PTR WORD BOOL is typedefined as: BOOL TYPEDEF WORD The code generated for INVOKE accomplishes the following:


 * 1) Pushes the arguments for the function DosWrite on the stack (from right to left).
 * 2) Pushes the arguments for the DosExit function on the stack (from right to left).
 * 3) Exits.

Sample Code
; Assemble options needed: none

.286

INCLUDELIB os2.lib INCLUDE os2.inc

DGROUP GROUP _DATA

STACK SEGMENT PARA STACK 'STACK'     ;stack segment declared WORD  256 dup(?) STACK ENDS

_DATA     SEGMENT WORD PUBLIC 'DATA'     ;data segment declared message   BYTE  &quot;Hello World&quot;, 13,10 bytecount DWORD ? _DATA     ENDS

_TEXT SEGMENT WORD PUBLIC 'CODE'     ;code segment declared ASSUME  CS:_TEXT, DS:_DATA, SS:STACK

@Startup:

INVOKE DosWrite, 1, ADDR message, LENGTHOF message ADDR bytecount

;Code generated by INVOKE ;      ;   push   1                   ;output to Stdout ;  push   ds                  ;pass address of msg ;  push   OFFSET message ;  push   LENGTHOF message    ;pass length of msg ;  push   ds       ;   push   OFFSET bytecount    ;pass address of count ;  call   DosWrite

INVOKE  DosExit,+1h, +0h

;Code generated by INVOKE ;      ;   push   +1h                 ;Ends all threads ;  push   +0h                 ;Pass 0 return code ;  call   DosExit

_TEXT ENDS END @Startup

Additional query words: kbinf 6.00 6.00a 6.00b

Keywords: KB72698

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.