%imacro export 1+.nolist
.export %1
%endmacro

; Raw exception handling operations
%imacro proc_frame 1+.nolist
%1:
.proc_frame %1
%endmacro

%imacro endproc_frame 0.nolist
.endproc_frame
%endmacro

; Complex (macro) exception handling operations
; Mimics many macros provided by MASM's macamd64.inc
%imacro push_reg 1
pushq %1
.pushreg %1
%endmacro

%imacro rex_push_reg 1
.byte 0x48
pushq %1
.pushreg %1
%endmacro

%imacro push_eflags 0
pushfq
.allocstack 8
%endmacro

%imacro rex_push_eflags 0
.byte 0x48
pushfq
.allocstack 8
%endmacro

%imacro alloc_stack 1
subq $%1, %rsp
.allocstack %1
%endmacro

%imacro save_reg 2
movq %1, %2(%rsp)
.savereg %1 %2
%endmacro

%imacro save_xmm128 2
movdqa %1, %2(%rsp)
.savexmm128 %1, %2
%endmacro

%imacro push_frame 0-1.nolist
.pushframe %1
%endmacro

%imacro set_frame 1-2
%if %0==1
movq %rsp, %1
%else
leaq %2(%rsp), %1
%endif
.setframe %1, %2
%endmacro

%imacro end_prolog 0.nolist
.endprolog
%endmacro

%imacro end_prologue 0.nolist
.endprolog
%endmacro
