Using Full Segment Directives with MASM 6.0 HELLO.ASMLast reviewed: January 23, 1995Article ID: Q72698 |
The information in this article applies to:
SUMMARYThe "Microsoft Macro Assembler Programmer's Guide" 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 INFORMATIONThe 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:PWORDDosExit is prototyped in BSEDOS.INC as:
DosExit PROTO FAR PASCAL fTerminate:BOOL, usExitCode:WORDIn OS2DEF.INC, PVOID is typedefined as:
PVOID TYPEDEF FAR PTRPWORD is typedefined as:
PWORD TYPEDEF FAR PTR WORDBOOL is typedefined as:
BOOL TYPEDEF WORDThe code generated for INVOKE accomplishes the following:
Sample Code; Assemble options needed: none
.286 INCLUDELIB os2.lib INCLUDE os2.incDGROUP 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 "Hello World", 13,10bytecount 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 reference words: kbinf 6.00 6.00a 6.00b
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |