2002-05-04 11:57:52 +08:00
|
|
|
; Standard macro set for NASM -*- nasm -*-
|
2002-05-01 05:01:08 +08:00
|
|
|
|
|
|
|
; Macros to make NASM ignore some TASM directives before the first include
|
|
|
|
; directive.
|
|
|
|
|
|
|
|
%idefine IDEAL
|
|
|
|
%idefine JUMPS
|
|
|
|
%idefine P386
|
|
|
|
%idefine P486
|
|
|
|
%idefine P586
|
|
|
|
%idefine END
|
|
|
|
|
2002-05-04 11:57:52 +08:00
|
|
|
; This is a magic token which indicates the end of the TASM macros
|
|
|
|
*END*TASM*MACROS*
|
|
|
|
|
2002-05-01 04:52:49 +08:00
|
|
|
; Note that although some user-level forms of directives are defined
|
|
|
|
; here, not all of them are: the user-level form of a format-specific
|
|
|
|
; directive should be defined in the module for that directive.
|
2002-05-01 04:52:26 +08:00
|
|
|
|
2007-04-12 10:40:54 +08:00
|
|
|
; These three need to be defined, though the actual definitions will
|
2002-05-01 04:52:49 +08:00
|
|
|
; be constantly updated during preprocessing.
|
|
|
|
%define __FILE__
|
|
|
|
%define __LINE__
|
2007-04-12 10:40:54 +08:00
|
|
|
%define __BITS__
|
2002-05-01 04:52:26 +08:00
|
|
|
|
|
|
|
%define __SECT__ ; it ought to be defined, even if as nothing
|
|
|
|
|
|
|
|
%imacro section 1+.nolist
|
|
|
|
%define __SECT__ [section %1]
|
|
|
|
__SECT__
|
|
|
|
%endmacro
|
|
|
|
%imacro segment 1+.nolist
|
|
|
|
%define __SECT__ [segment %1]
|
|
|
|
__SECT__
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
%imacro absolute 1+.nolist
|
|
|
|
%define __SECT__ [absolute %1]
|
|
|
|
__SECT__
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
%imacro struc 1.nolist
|
2008-07-03 09:11:49 +08:00
|
|
|
%push
|
2002-05-01 04:52:26 +08:00
|
|
|
%define %$strucname %1
|
|
|
|
[absolute 0]
|
2002-05-01 04:52:49 +08:00
|
|
|
%$strucname: ; allow definition of `.member' to work sanely
|
2002-05-01 05:01:08 +08:00
|
|
|
%endmacro
|
2002-05-01 04:52:26 +08:00
|
|
|
%imacro endstruc 0.nolist
|
|
|
|
%{$strucname}_size:
|
|
|
|
%pop
|
|
|
|
__SECT__
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
%imacro istruc 1.nolist
|
2008-07-03 09:11:49 +08:00
|
|
|
%push
|
2002-05-01 04:52:26 +08:00
|
|
|
%define %$strucname %1
|
|
|
|
%$strucstart:
|
|
|
|
%endmacro
|
|
|
|
%imacro at 1-2+.nolist
|
|
|
|
times %1-($-%$strucstart) db 0
|
|
|
|
%2
|
|
|
|
%endmacro
|
|
|
|
%imacro iend 0.nolist
|
|
|
|
times %{$strucname}_size-($-%$strucstart) db 0
|
|
|
|
%pop
|
|
|
|
%endmacro
|
|
|
|
|
2002-05-01 04:52:49 +08:00
|
|
|
%imacro align 1-2+.nolist nop
|
2008-07-17 05:38:58 +08:00
|
|
|
times ($$-$) % (%1) %2
|
2002-05-01 04:52:49 +08:00
|
|
|
%endmacro
|
2008-07-21 00:40:14 +08:00
|
|
|
%imacro alignb 1-2+.nolist
|
2008-07-21 00:32:31 +08:00
|
|
|
%ifempty %2
|
|
|
|
resb ($$-$) % (%1)
|
|
|
|
%else
|
|
|
|
times ($$-$) % (%1) %2
|
|
|
|
%endif
|
|
|
|
%endmacro
|
2002-05-01 04:52:49 +08:00
|
|
|
|
|
|
|
%imacro extern 1-*.nolist
|
|
|
|
%rep %0
|
2002-05-01 04:52:26 +08:00
|
|
|
[extern %1]
|
2002-05-01 04:52:49 +08:00
|
|
|
%rotate 1
|
|
|
|
%endrep
|
2002-05-01 04:52:26 +08:00
|
|
|
%endmacro
|
|
|
|
|
|
|
|
%imacro bits 1+.nolist
|
|
|
|
[bits %1]
|
|
|
|
%endmacro
|
|
|
|
|
2002-05-01 04:59:21 +08:00
|
|
|
%imacro use16 0.nolist
|
|
|
|
[bits 16]
|
|
|
|
%endmacro
|
|
|
|
%imacro use32 0.nolist
|
|
|
|
[bits 32]
|
|
|
|
%endmacro
|
2007-04-12 10:40:54 +08:00
|
|
|
%imacro use64 0.nolist
|
|
|
|
[bits 64]
|
|
|
|
%endmacro
|
2002-05-01 04:59:21 +08:00
|
|
|
|
2002-05-01 04:52:49 +08:00
|
|
|
%imacro global 1-*.nolist
|
|
|
|
%rep %0
|
2002-05-01 04:52:26 +08:00
|
|
|
[global %1]
|
2002-05-01 04:52:49 +08:00
|
|
|
%rotate 1
|
|
|
|
%endrep
|
2002-05-01 04:52:26 +08:00
|
|
|
%endmacro
|
|
|
|
|
2002-05-01 04:52:49 +08:00
|
|
|
%imacro common 1-*.nolist
|
|
|
|
%rep %0
|
2002-05-01 04:52:26 +08:00
|
|
|
[common %1]
|
2002-05-01 04:52:49 +08:00
|
|
|
%rotate 1
|
|
|
|
%endrep
|
2002-05-01 04:52:26 +08:00
|
|
|
%endmacro
|
2002-05-01 04:59:21 +08:00
|
|
|
|
|
|
|
%imacro cpu 1+.nolist
|
|
|
|
[cpu %1]
|
|
|
|
%endmacro
|
|
|
|
|
2007-10-17 05:40:27 +08:00
|
|
|
%define __FLOAT_DAZ__ nodaz
|
|
|
|
%define __FLOAT_ROUND__ near
|
|
|
|
; __FLOAT__ contains the whole floating-point configuration so it can
|
|
|
|
; be saved and restored
|
2007-10-17 05:42:32 +08:00
|
|
|
%define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__
|
2007-10-17 05:40:27 +08:00
|
|
|
%imacro float 1-*.nolist
|
|
|
|
%rep %0
|
|
|
|
[float %1]
|
|
|
|
%ifidni %1,daz
|
|
|
|
%define __FLOAT_DAZ__ daz
|
|
|
|
%elifidni %1,nodaz
|
|
|
|
%define __FLOAT_DAZ__ nodaz
|
|
|
|
%elifidni %1,near
|
|
|
|
%define __FLOAT_ROUND__ near
|
|
|
|
%elifidni %1,up
|
|
|
|
%define __FLOAT_ROUND__ up
|
|
|
|
%elifidni %1,down
|
|
|
|
%define __FLOAT_ROUND__ down
|
|
|
|
%elifidni %1,zero
|
|
|
|
%define __FLOAT_ROUND__ zero
|
|
|
|
%elifidni %1,default
|
|
|
|
%define __FLOAT_DAZ__ nodaz
|
|
|
|
%define __FLOAT_ROUND__ near
|
|
|
|
%endif
|
2008-05-31 02:06:28 +08:00
|
|
|
%rotate 1
|
2007-10-17 05:40:27 +08:00
|
|
|
%endrep
|
|
|
|
%endmacro
|
|
|
|
|
2007-08-30 00:40:26 +08:00
|
|
|
%imacro default 1+.nolist
|
|
|
|
[default %1]
|
|
|
|
%endmacro
|
2008-05-31 01:42:30 +08:00
|
|
|
|
|
|
|
%imacro incbin 1-2+.nolist 0
|
2008-07-03 09:11:49 +08:00
|
|
|
%push
|
2008-05-31 01:42:30 +08:00
|
|
|
%pathsearch %$dep %1
|
|
|
|
%depend %$dep
|
2008-05-31 02:04:07 +08:00
|
|
|
%? %$dep,%2
|
2008-05-31 01:42:30 +08:00
|
|
|
%pop
|
|
|
|
%endmacro
|