Welcome    |  Sign In     | 
Click to Rate and Give Feedback
     
 OPTION (MASM)
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
  • Microsoft Visual Studio 2003/.NET Framework 1.1
  • Microsoft Visual Studio 2008/.NET Framework 3.5
  • Microsoft Macro Assembler Reference 
    OPTION (MASM) 

    Enables and disables features of the assembler.

    OPTION optionlist
    See AlsoSee Also
    Tags What's this?: Add a tag
    Community Content
     
     
    Add new Community Content
    PROLOGUE/EPILOGUE Syntax      Zooba__ ... Zooba   |   Edit   |  

    Prologue

    The syntax for PROLOGUE is OPTION PROLOGUE:x where x is the name of a user defined macro function, PrologueDef (to use the default) or NONE.

    The prologue macro is of the form:

    MyPrologue MACRO procname, flags, argbytes, localbytes, reglist, userparms:VARARG

    Where:

    procname contains the name of the procedure

    flags contains a word-size bit mask of settings:
    Bits 0-2: Language type (000 - unspecified, 001 C, 010 SYSCALL, 011 STDCALL, 100 PASCAL, 101 FORTRAN, 110 BASIC, (111 is reserved))
    Bit 3: (reserved)
    Bit 4: 1 if the caller will restore the stack, 0 if the callee must
    Bit 5: FAR procedure
    Bit 6: PRIVATE procedure
    Bit 7: EXPORT procedure

    argbytes contains the number of bytes used by arguments

    localbytes contains the number of bytes defined using the LOCAL directive for this procedure

    reglist contains a comma-delimited list of USES parameters (registers which are to be preserved)

    userparms contains a list of other parameters specified

    At the end of the macro, the number of bytes used for local storage (ie. the magnitude difference between ESP and EBP at the end of the macro) must be returned using EXITM.

    Here is a sample prologue macro which provides basic frame functionality:

    MyPrologue MACRO procname, flags, argbytes, localbytes, reglist, userparms:VARARG
    IF localbytes GT 0
    push ebp
    mov ebp, esp
    sub esp, localbytes
    ELSEIF argbytes GT 0
    push ebp
    mov ebp, esp
    ELSEIFNB <userparms>
    IF @InStr(1, <userparms>, <FORCEFRAME>)
    push ebp
    mov ebp, esp
    ENDIF
    ENDIF

    ;; USES clause
    IFNB <reglist>
    FOR reg,reglist
    push reg
    ENDM
    ENDIF

    EXITM <localbytes>
    ENDM

    Epilogue

    The syntax for EPILOGUE is OPTION EPILOGUE:x where x is the name of a user defined macro, EpilogueDef (to use the default) or NONE.

    The epilogue macro is of the form:

    MyEpilogue MACRO procname, flags, argbytes, localbytes, reglist, userparms:VARARG

    where all parameters are the same as for the prologue macro, with the following additions:

    flags bit 8 will be set (1) if the epilogue was called using IRET, clear (0) if RET was used.

    reglist is in reverse order from the prologue to make it easier to code.

    The epilogue macro does not return any values.

    Here is a sample epilogue macro which will match the prologue example shown above:

    MyEpilogue MACRO procname, flags, argbytes, localbytes, reglist, userparms:VARARG
    ;; USES clause
    IFNB <reglist>
    FOR reg,reglist
    pop reg
    ENDM
    ENDIF

    IF (argbytes GT 0) OR (localbytes GT 0)
    leave
    ELSEIFNB <userparms>
    IF @InStr(1,<userparms>,<FORCEFRAME>)
    leave
    ENDIF
    ENDIF
      
        IF flags AND 10h
            ;; caller will restore stack
    retn 0
    ELSE
            ;; callee must restore stack
    retn argbytes
    ENDIF
    ENDM
    Tags What's this?: Add a tag

     
    Page view tracker