NASM-X
Next Chapter |
Previous Chapter |
Contents |
Index
Description
     This macro causes program execution within a looping construct to terminate.
Syntax
     BREAK
Examples
Section E.4
See also:
Section 2.3: DO
Section 2.11: IF
Section 2.29: REPEAT
Section 2.32: WHILE
Description
     This macro causes program execution within a looping construct to jump back to the start of the inner-most loop that it is currently contained in.
Syntax
     CONTINUE
Examples
Section E.3
See also:
Section 2.3: DO
Section 2.32: WHILE
Description
     This macro creates a procedure specific label to implement a looping block.
Syntax
     DO
Examples
Section E.3
See also:
Section 2.1: BREAK
Section 2.32: WHILE
Description
     This macro causes program execution to branch to this block of code if the condition of the prior IF statement is false.
Syntax
     ELSE
Examples
Section E.3
See also:
Section 2.7 : ENDIF
Section 2.11 : IF
Description
     This macro causes program execution to branch to this block of code if the condition of the prior IF statement is false.
Syntax
     ELSIF reg,cc,val
    
     where:
         reg is the register used for comparison
         cc is the condition to check
         val is the value to compare the register against
Examples
Section E.3
See also:
Section 2.7 : ENDIF
Section 2.11 : IF
Description
     Specifying the program entry point.
Syntax
     ENTRY proc_name
Examples
Section E.1
Section E.2
See also:
Section 2.13: INVOKE
Section 2.27: PROC
Description
     Terminates an IF block.
Syntax
     ENDIF
Examples
Section E.1
Section E.2
See also:
Section 2.4: ELSE
Section 2.11: IF
Description
     Terminates a PROC block.
Syntax
     ENDPROC
Examples
Section E.1
Section E.2
See also:
Section 2.27: PROC
Description
     Terminates a LOCALS block.
Syntax
     ENDLOCALS
Examples
Section E.1
Section E.2
See also:
Section 2.15: LOCALS
Description
     Terminates a WHILE block.
Syntax
     ENDWHILE
Examples
Section E.1
Section E.2
See also:
Section 2.32: WHILE
Description
     This macro causes conditional branching of the program execution.
Syntax
     IF reg,cc,val
    
     where:
         reg is the register used for comparison
         cc is the condition to check
         val is the value to compare the register against
Example
Section E.2
See also:
Section 2.4: ELSE
Section 2.5: ELSIF
Section 2.7: ENDIF
Description
     This macro causes the external procedure name provided to be made available to your program to call.
Syntax
     IMPORT [callconv,] proc_name [,param[,param,...]]
    
     where:
          callconv is the calling convention used if not the default.
               supported conventions: CDECL, FASTCALL, NAKED, PASCAL, STDCALL
          proc_name is the name of the procedure to import.
          param is the type and parameter name(s) of the procedure.
Example
Section E.1
See also:
Section 2.6: ENTRY
Section 2.13: INVOKE
Section 2.27: PROC
Description
     This macro causes procedure name to be called.
Syntax
     INVOKE [callconv,] proc_name [,param[,param,...]]
    
     where:
          callconv is the calling convention used if not the default.
               supported conventions: CDECL, FASTCALL, NAKED, PASCAL, STDCALL
          proc_name is the name of the procedure to call.
          param is the parameter type and value of the called procedure.
Notes
Fox Windows x64 programming:
INVOKE will not normally spill register arguments to the stack prior to the call. If this behavior is desired due
to calling a non-conformant function then you may use NASMX_PRAGMA INVOKE_FASTCALL_STACK_PRELOAD, ENABLE
prior to INVOKE to enable this behavior and then disable the pragma after INVOKE.
Example
Section E.1
See also:
Section 2.6: ENTRY
Section 2.12: IMPORT
2.21: NASMX_PRAGMA
Section 2.27: PROC
Description
     This macro creates variable space for the procedure on the stack.
Syntax
     LOCAL varname, type, qty
    
     where:
          varname is the name of the local variable.
          type is the type of the local variable being created.
          qty is the number of types needed ( default: 1 ).
Example
Section E.5
See also:
Section 2.9: ENDLOCALS
Section 2.15: LOCALS
Section 2.27: PROC
Description
     This macro marks the beginning of procedure local variables. It must be the next immediate macro after PROC.
Syntax
     LOCALS [NONE]
    
     where:
          NONE is an optional value indicating the procedure does not use local stack variables.
          Note that the macro ENDLOCALS is not required when LOCALS NONE is specified.
Example
Section E.1
See also:
Section 2.9: ENDLOCALS
Section 2.14: LOCAL
Section 2.27: PROC
Description
     This macro allocates structure member space.
Syntax
     NASMX_AT name, value
    
     where:
          name provides the name of the structure member offset.
          value specifies the data value to be initially assigned.
Example
Section E.5
See also:
Section 2.19: NASMX_IENDSTRUC
Section 2.20: NASMX_ISTRUC
Description
     This macro is used to indicate that the structure currently being defined is now completed.
Syntax
     NASMX_ENDSTRUC
Example
Section E.5
See also:
Section 2.22: NASMX_RESERVE
Section 2.23: NASMX_STRUC
Description
     This macro is used to indicate that the union currently being defined is now completed.
Syntax
     NASMX_ENDUNION
Example
Section E.5
See also:
Section 2.22: NASMX_RESERVE
Section 2.26: NASMX_UNION
Description
     This macro is used to indicate that the structure currently being allocated is now completed.
Syntax
     NASMX_IENDSTRUC
Example
Section E.5
See also:
Section 2.16: NASMX_AT
Section 2.20: NASMX_ISTRUC
Description
     This macro is used to create a structure instance.
Syntax
     NASMX_ISTRUC name, type
    
     where:
          name is the name of this structure instance.
          type is the name of the predefined structure type.
Example
Section E.5
See also:
Section 2.16: NASMX_AT
Section 2.19: NASMX_IENDSTRUC
Description
     This macro allows the developer to specify certain options that affect how NASMX generates code.
Syntax
     NASMX_PRAGMA directive,option [,options]
    
     where:
          directive
provides instruction to NASMX
          options
are optional values specified for the directive.
     directives:
          CALLSTACK, size
; Win64 minimum callstack size is 32
          PACK, PUSH, align_val
; default is natural structure member alignment
          PACK, POP
          PROC_FASTCALL_STACK_PRELOAD, [ ENABLE | DISABLE ]
; default is enable
          INVOKE_FASTCALL_STACK_PRELOAD, [ ENABLE | DISABLE ]
; default is disable
Note: The pragma INVOKE_FASTCALL_STACK_PRELOAD is applicable only for Windows 64-bit.
Example
Please see demos
See also:
Section 2.15: LOCALS
Section 2.27: PROC
Description
    This macro allows the developer to specify the structure member variable names and types.
Syntax
     NASMX_RESERVE name, type, qty
    
     where:
          name provides the name of the structure member.
          type specifies the data type of the member.
          qty specifies how many types to reserve ( Default: 1 ).
Example
Section E.5
See also:
Section 2.23: NASMX_STRUC
Section 2.26: NASMX_UNION
Description
    This macro allows the developer to begin structure definition and provide a name.
Syntax
     NASMX_STRUC name
    
     where:
          name provides the name of the structure.
Example
Section E.5
See also:
Section 2.22: NASMX_RESERVE
Section 2.17: NASMX_ENDSTRUC
Description
    This macro is used to indicate that the character type for the defined label will change based on the UNICODE define.
Syntax
     NASMX_TCHAR
Example
Section E.1
See also:
Section 2.15: NASMX_TEXT
Description
    This macro is used to indicate that the character type for the defined label will change based on the UNICODE define.
Syntax
     NASMX_TEXT
Example
Section E.1
See also:
Section 2.24: NASMX_TCHAR
Description
    This macro allows the developer to begin a union definition and provide a name.
Syntax
     NASMX_UNION name
    
     where:
          name provides the name of the union.
Example
Section E.5
See also:
Section 2.22: NASMX_RESERVE
Section 2.18: NASMX_ENDUNION
Description
     This macro causes the named procedure to be defined.
Syntax
     PROC [callconv,] proc_name [,param[,param,...]]
    
     where:
          callconv is the calling convention used if not the default.
               supported conventions: CDECL, FASTCALL, NAKED, PASCAL, STDCALL
          proc_name is the name of the procedure.
          param is the type and parameter name(s) of the procedure.
Notes
The stack frame is automatically created whenever you have defined either procedure parameters or local stack variables.
Arguments are always located on the stack above the return address for both 32-bit and 64-bit.
The 32-bit register EBP ( RBP in 64-bit ) is used as the frame pointer. Procedures that define parameter arguments will have the parameter
names equated to offsets from the frame. Use the macro argv()
to access the procedure arguments.
For the 64-bit fastcall calling convention:
By default, during the procedure prologue, NASM-X will automatically save the registers used for
the procedure parameters you define to the stack. To prevent NASM-X from saving register parameters to the stack you can place a
NASMX_PRAGMA PROC_FASTCALL_STACK_PRELOAD, DISABLE
at the beginning of your source file after including nasmx.inc
You may enable or disable stack pre-loading at any time by using multiple NASMX_PRAGMA directives in your source file.
For Linux 64-bit mode:
NASM-X will create a register argument spill area below the return address in a manner similar to local variables.
Automatic register argument saving is enabled or disabled as indicated previously. The macro argv()
will
correctly provide the parameter offsets in this area.
Finally, if your procedure does not require automatic register saves or you will not access the register spill area then you may simply
define a PROC without parameters. Doing so may eliminate the need to use register EBP/RBP to create the stack frame depending on whether
local variable stack space is required or not thus freeing up that register for use. The exceptions are 1.) the program main entry point which,
if defined, must establish the initial frame; and 2.) procedures that expect floating point arguments must be prototyped in order for INVOKE to
assign the appropriate floating point registers.
Known Issues
- There is currently no support for passing parameter values larger than 64-bits.
- For Linux 64-bit mode NASM-X currently does not support defining a PROC with more parameters than the maximum registers defined for the x64 fastcall calling convention.
The INVOKE macro, however, fully supports the calling convention.
Example
Section E.3
See also:
     Section 2.6: ENTRY
     Section 2.12: IMPORT
     2.21: NASMX_PRAGMA
     Section 2.28: PROTO
    This macro generates a global procedure name that can be imported by additional source modules.
Syntax
     PROTO [callconv,] proc_name [,param[,param,...]]
    
     where:
          callconv is the calling convention used if not the default.
               supported conventions: CDECL, FASTCALL, NAKED, PASCAL, STDCALL
          proc_name is the name of the procedure.
          param is the type and parameter name(s) of the procedure.
See also:
     Section 2.6: ENTRY
     Section 2.12: IMPORT
     Section 2.27: PROC
Description
     This macro creates a procedure specific label to implement a looping block.
Syntax
     REPEAT
Examples
Section E.3
See also:
Section 2.1: BREAK
Section 2.31: UNTIL
Description
     This macro causes a jump to the procedure epilogue.
Syntax
     RETURN [ val ]
    
     where val is the optional procedure return value
Examples
See demos/win32/demo2 for example usage.
Notes
At the end of your procedure you may simply mov eax, val
as the last statement to be executed in order to optimize out the jump to the procedure epilogue.
See also:
Section 2.8: ENDPROC
Section 2.27: PROC
Description
     Specifying a REPEAT block terminating condition.
Syntax
     UNTIL reg,cc,val
    
     where:
         reg is the register used for comparison
         cc is the condition to check
         val is the value to compare the register against
Examples
Section E.1
Section E.2
See also:
Section 2.1: BREAK
Section 2.29: REPEAT
Description
     This macro enables the developer to specific registers that must be saved during the procedure prologue. Saved registers are restored automatically by NASMX during ENDPROC.
     This macro, if used, must appear immediately following a PROC statement and immediate before the LOCALS statement
Syntax
     USES reg [,reg [,reg...]]
Examples
Section E.3
See also:
Section 2.8: ENDPROC
Section 2.27: PROC
Description
     This macro creates a procedure specific label to implement a looping block.
Syntax
     WHILE reg,cc,val
    
     where:
         reg is the register used for comparison
         cc is the condition to check
         val is the value to compare the register against
Examples
Section E.3
See also:
Section 2.1: BREAK
Section 2.3: DO
Section 2.10: ENDWHILE
Next Chapter |
Previous Chapter |
Contents |
Index