mirror of https://github.com/yasm/yasm.git
Standard macro sets are looked up based on parser and preprocessor keyword from individual modules. The "standard" NASM parser macros now reside in the NASM parser, so when the GAS parser is used with the NASM preprocessor, the NASM-specific macros are no longer defined. Object-format specific macros are now individually defined by each object formatm module. This allows for the object formats to be independent of the NASM preprocessor module and yields a small optimization benefit as unused object format macros don't need to be skipped over. Also add GAS macro equivalents for the Win64 SEH more complex directives [1]. [1] Requested by Brian Gladman <brg@gladman.plus.com> svn path=/trunk/yasm/; revision=20820.7.2
parent
d8a6f8c376
commit
cbf0c7befd
34 changed files with 1026 additions and 551 deletions
@ -0,0 +1,73 @@ |
||||
%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 |
@ -0,0 +1,106 @@ |
||||
%imacro export 1+.nolist |
||||
[export %1] |
||||
%endmacro |
||||
|
||||
; Raw exception handling operations |
||||
%imacro proc_frame 1+.nolist |
||||
%1: |
||||
[proc_frame %1] |
||||
%endmacro |
||||
|
||||
; Disable these as they're too closely named to the macroized ones. |
||||
; MASM needs a preceding . to use these, so it seems reasonable for |
||||
; us to similarly require the []. |
||||
; |
||||
;%imacro pushreg 1.nolist |
||||
;[pushreg %1] |
||||
;%endmacro |
||||
; |
||||
;%imacro setframe 1-2.nolist |
||||
;[setframe %1 %2] |
||||
;%endmacro |
||||
; |
||||
;%imacro allocstack 1.nolist |
||||
;[allocstack %1] |
||||
;%endmacro |
||||
; |
||||
;%imacro savereg 2.nolist |
||||
;[savereg %1 %2] |
||||
;%endmacro |
||||
; |
||||
;%imacro savexmm128 2.nolist |
||||
;[savexmm128 %1 %2] |
||||
;%endmacro |
||||
; |
||||
;%imacro pushframe 0-1.nolist |
||||
;[pushframe %1] |
||||
;%endmacro |
||||
; |
||||
;%imacro endprolog 0.nolist |
||||
;[endprolog] |
||||
;%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 |
||||
push %1 |
||||
[pushreg %1] |
||||
%endmacro |
||||
|
||||
%imacro rex_push_reg 1 |
||||
db 0x48 |
||||
push %1 |
||||
[pushreg %1] |
||||
%endmacro |
||||
|
||||
%imacro push_eflags 0 |
||||
pushfq |
||||
[allocstack 8] |
||||
%endmacro |
||||
|
||||
%imacro rex_push_eflags 0 |
||||
db 0x48 |
||||
pushfq |
||||
[allocstack 8] |
||||
%endmacro |
||||
|
||||
%imacro alloc_stack 1 |
||||
sub rsp, %1 |
||||
[allocstack %1] |
||||
%endmacro |
||||
|
||||
%imacro save_reg 2 |
||||
mov [rsp+%2], %1 |
||||
[savereg %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro save_xmm128 2 |
||||
movdqa [rsp+%2], %1 |
||||
[savexmm128 %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro push_frame 0-1.nolist |
||||
[pushframe %1] |
||||
%endmacro |
||||
|
||||
%imacro set_frame 1-2 |
||||
%if %0==1 |
||||
mov %1, rsp |
||||
%else |
||||
lea %1, [rsp+%2] |
||||
%endif |
||||
[setframe %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro end_prolog 0.nolist |
||||
[endprolog] |
||||
%endmacro |
||||
|
||||
%imacro end_prologue 0.nolist |
||||
[endprolog] |
||||
%endmacro |
@ -0,0 +1,7 @@ |
||||
# $Id$ |
||||
|
||||
TESTS += modules/objfmts/win64/tests/gas/win64_gas_test.sh |
||||
|
||||
EXTRA_DIST += modules/objfmts/win64/tests/gas/win64_gas_test.sh |
||||
EXTRA_DIST += modules/objfmts/win64/tests/gas/win64-gas-sce.asm |
||||
EXTRA_DIST += modules/objfmts/win64/tests/gas/win64-gas-sce.hex |
@ -0,0 +1,11 @@ |
||||
PROC_FRAME sample |
||||
rex_push_reg %rbp |
||||
rex_push_eflags |
||||
alloc_stack 16 |
||||
save_reg %rsi, 0x18 |
||||
save_xmm128 %xmm7, 0x20 |
||||
push_frame 16 |
||||
set_frame %rdi |
||||
set_frame %rdi, 16 |
||||
END_PROLOGUE |
||||
ENDPROC_FRAME |
@ -0,0 +1,403 @@ |
||||
64 |
||||
86 |
||||
03 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
ed |
||||
00 |
||||
00 |
||||
00 |
||||
09 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
04 |
||||
00 |
||||
2e |
||||
74 |
||||
65 |
||||
78 |
||||
74 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
1f |
||||
00 |
||||
00 |
||||
00 |
||||
8c |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
20 |
||||
00 |
||||
50 |
||||
60 |
||||
2e |
||||
78 |
||||
64 |
||||
61 |
||||
74 |
||||
61 |
||||
00 |
||||
00 |
||||
1f |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
18 |
||||
00 |
||||
00 |
||||
00 |
||||
ab |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
40 |
||||
00 |
||||
40 |
||||
40 |
||||
2e |
||||
70 |
||||
64 |
||||
61 |
||||
74 |
||||
61 |
||||
00 |
||||
00 |
||||
37 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
0c |
||||
00 |
||||
00 |
||||
00 |
||||
c3 |
||||
00 |
||||
00 |
||||
00 |
||||
cf |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
00 |
||||
00 |
||||
40 |
||||
00 |
||||
30 |
||||
40 |
||||
48 |
||||
55 |
||||
48 |
||||
9c |
||||
48 |
||||
2b |
||||
24 |
||||
25 |
||||
10 |
||||
00 |
||||
00 |
||||
00 |
||||
48 |
||||
89 |
||||
74 |
||||
24 |
||||
18 |
||||
66 |
||||
0f |
||||
7f |
||||
7c |
||||
24 |
||||
20 |
||||
48 |
||||
89 |
||||
e7 |
||||
48 |
||||
8d |
||||
7c |
||||
24 |
||||
10 |
||||
01 |
||||
1f |
||||
0a |
||||
17 |
||||
1f |
||||
73 |
||||
1a |
||||
73 |
||||
17 |
||||
1a |
||||
17 |
||||
78 |
||||
02 |
||||
00 |
||||
11 |
||||
64 |
||||
03 |
||||
00 |
||||
0c |
||||
12 |
||||
04 |
||||
02 |
||||
02 |
||||
50 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
1f |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
04 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
04 |
||||
00 |
||||
00 |
||||
00 |
||||
04 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
08 |
||||
00 |
||||
00 |
||||
00 |
||||
05 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
2e |
||||
66 |
||||
69 |
||||
6c |
||||
65 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
fe |
||||
ff |
||||
00 |
||||
00 |
||||
67 |
||||
01 |
||||
2d |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
2e |
||||
74 |
||||
65 |
||||
78 |
||||
74 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
01 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
01 |
||||
1f |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
73 |
||||
61 |
||||
6d |
||||
70 |
||||
6c |
||||
65 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
01 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
2e |
||||
78 |
||||
64 |
||||
61 |
||||
74 |
||||
61 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
02 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
01 |
||||
18 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
2e |
||||
70 |
||||
64 |
||||
61 |
||||
74 |
||||
61 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
01 |
||||
0c |
||||
00 |
||||
00 |
||||
00 |
||||
03 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
00 |
||||
04 |
||||
00 |
||||
00 |
||||
00 |
@ -0,0 +1,4 @@ |
||||
#! /bin/sh |
||||
# $Id$ |
||||
${srcdir}/out_test.sh win64_gas_test modules/objfmts/win64/tests/gas "win64 objfmt" "-f win64 -p gas -r nasm" ".obj" |
||||
exit $? |
@ -0,0 +1,109 @@ |
||||
; Standard macro set for NASM -*- nasm -*- |
||||
|
||||
; 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. |
||||
|
||||
; These two need to be defined, though the actual definitions will |
||||
; be constantly updated during preprocessing. |
||||
%define __FILE__ |
||||
%define __LINE__ |
||||
|
||||
%define __SECT__ [section .text] ; 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 |
||||
%push struc |
||||
%define %$strucname %1 |
||||
[absolute 0] |
||||
%$strucname: ; allow definition of `.member' to work sanely |
||||
%endmacro |
||||
%imacro endstruc 0.nolist |
||||
%{$strucname}_size: |
||||
%pop |
||||
__SECT__ |
||||
%endmacro |
||||
|
||||
%imacro istruc 1.nolist |
||||
%push istruc |
||||
%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 |
||||
|
||||
%imacro align 1-2+.nolist nop |
||||
%ifidni %2,nop |
||||
[align %1] |
||||
%else |
||||
times ($$-$) & ((%1)-1) %2 |
||||
%endif |
||||
%endmacro |
||||
%imacro alignb 1-2+.nolist resb 1 |
||||
times ($$-$) & ((%1)-1) %2 |
||||
%endmacro |
||||
|
||||
%imacro extern 1-*.nolist |
||||
%rep %0 |
||||
[extern %1] |
||||
%rotate 1 |
||||
%endrep |
||||
%endmacro |
||||
|
||||
%imacro bits 1+.nolist |
||||
[bits %1] |
||||
%endmacro |
||||
|
||||
%imacro use16 0.nolist |
||||
[bits 16] |
||||
%endmacro |
||||
%imacro use32 0.nolist |
||||
[bits 32] |
||||
%endmacro |
||||
%imacro use64 0.nolist |
||||
[bits 64] |
||||
%endmacro |
||||
|
||||
%imacro global 1-*.nolist |
||||
%rep %0 |
||||
[global %1] |
||||
%rotate 1 |
||||
%endrep |
||||
%endmacro |
||||
|
||||
%imacro common 1-*.nolist |
||||
%rep %0 |
||||
[common %1] |
||||
%rotate 1 |
||||
%endrep |
||||
%endmacro |
||||
|
||||
%imacro cpu 1+.nolist |
||||
[cpu %1] |
||||
%endmacro |
||||
|
||||
%imacro default 1+.nolist |
||||
[default %1] |
||||
%endmacro |
||||
|
||||
; NASM compatibility shim |
||||
%define __OUTPUT_FORMAT__ __YASM_OBJFMT__ |
@ -1,145 +0,0 @@ |
||||
/* $Id$
|
||||
* |
||||
* C version of NASM's macros.pl |
||||
* |
||||
* Copyright (C) 2004-2007 Peter Johnson |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions |
||||
* are met: |
||||
* 1. Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
* POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
#define OUTPUT "nasm-macros.c" |
||||
#define MAXLINE 1024 |
||||
|
||||
int |
||||
main(int argc, char *argv[]) |
||||
{ |
||||
FILE *in, *out; |
||||
int i; |
||||
char *str; |
||||
char *strp; |
||||
char *charp; |
||||
int fline; |
||||
int line = 0; |
||||
int lindex = 0; |
||||
int tasm_count = -1; |
||||
size_t len; |
||||
|
||||
if (argc < 2) { |
||||
fprintf(stderr, "Usage: %s <file> [<file> ...]\n", argv[0]); |
||||
return EXIT_FAILURE; |
||||
} |
||||
|
||||
out = fopen(OUTPUT, "wt"); |
||||
|
||||
if (!out) { |
||||
fprintf(stderr, "Could not open `%s'.\n", OUTPUT); |
||||
return EXIT_FAILURE; |
||||
} |
||||
|
||||
str = malloc(MAXLINE); |
||||
|
||||
fprintf(out, "/* This file auto-generated from standard.mac by genmacro.c" |
||||
" - don't edit it */\n\n#include <stddef.h>\n\n" |
||||
"static const char *stdmac[] = {\n"); |
||||
|
||||
for (i=1; i<argc; i++) { |
||||
in = fopen(argv[i], "rt"); |
||||
if (!in) { |
||||
fprintf(stderr, "Could not open `%s'.\n", argv[i]); |
||||
fclose(out); |
||||
remove(OUTPUT); |
||||
return EXIT_FAILURE; |
||||
} |
||||
|
||||
fline = 0; |
||||
|
||||
while (fgets(str, MAXLINE, in)) { |
||||
line++; |
||||
fline++; |
||||
|
||||
strp = str; |
||||
|
||||
/* check for unterminated quotes and delete comments */ |
||||
charp = strp; |
||||
while ((charp = strpbrk(charp, "'\";"))) { |
||||
if (charp[0] == ';') { |
||||
*charp = '\0'; |
||||
break; |
||||
} |
||||
if ((charp = strchr(charp+1, charp[0])) == NULL) { |
||||
fprintf(stderr, "%s:%d: error: unterminated quote\n", |
||||
argv[i], fline); |
||||
fclose(out); |
||||
remove(OUTPUT); |
||||
return EXIT_FAILURE; |
||||
} |
||||
charp++; |
||||
} |
||||
|
||||
/* strip off leading and trailing whitespace */ |
||||
while (*strp == ' ' || *strp == '\t') |
||||
strp++; |
||||
len = strlen(strp); |
||||
while (len > 0 && (strp[len-1] == ' ' || strp[len-1] == '\t' || |
||||
strp[len-1] == '\n')) { |
||||
strp[len-1] = '\0'; |
||||
len--; |
||||
} |
||||
|
||||
/* skip blank lines */ |
||||
if (len == 0) |
||||
continue; |
||||
|
||||
/* check for special TASM ending token */ |
||||
if (strcmp(strp, "*END*TASM*MACROS*") == 0) { |
||||
tasm_count = lindex; |
||||
continue; |
||||
} |
||||
|
||||
/* output as string to output file */ |
||||
fprintf(out, " \""); |
||||
while (*strp != '\0') { |
||||
if (*strp == '\\' || *strp == '"') |
||||
fputc('\\', out); |
||||
fputc(*strp, out); |
||||
strp++; |
||||
} |
||||
fprintf(out, "\",\n"); |
||||
lindex++; |
||||
} |
||||
|
||||
fclose(in); |
||||
} |
||||
|
||||
fprintf(out, " NULL\n};\n"); |
||||
if (tasm_count == -1) |
||||
tasm_count = lindex; |
||||
fprintf(out, "#define TASM_MACRO_COUNT %d\n", tasm_count); |
||||
fclose(out); |
||||
|
||||
free(str); |
||||
|
||||
return EXIT_SUCCESS; |
||||
} |
@ -1,293 +0,0 @@ |
||||
; Standard macro set for NASM -*- nasm -*- |
||||
|
||||
; 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 |
||||
|
||||
; This is a magic token which indicates the end of the TASM macros |
||||
*END*TASM*MACROS* |
||||
|
||||
; 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. |
||||
|
||||
; These two need to be defined, though the actual definitions will |
||||
; be constantly updated during preprocessing. |
||||
%define __FILE__ |
||||
%define __LINE__ |
||||
|
||||
%define __SECT__ [section .text] ; 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 |
||||
%push struc |
||||
%define %$strucname %1 |
||||
[absolute 0] |
||||
%$strucname: ; allow definition of `.member' to work sanely |
||||
%endmacro |
||||
%imacro endstruc 0.nolist |
||||
%{$strucname}_size: |
||||
%pop |
||||
__SECT__ |
||||
%endmacro |
||||
|
||||
%imacro istruc 1.nolist |
||||
%push istruc |
||||
%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 |
||||
|
||||
%imacro align 1-2+.nolist nop |
||||
%ifidni %2,nop |
||||
[align %1] |
||||
%else |
||||
times ($$-$) & ((%1)-1) %2 |
||||
%endif |
||||
%endmacro |
||||
%imacro alignb 1-2+.nolist resb 1 |
||||
times ($$-$) & ((%1)-1) %2 |
||||
%endmacro |
||||
|
||||
%imacro extern 1-*.nolist |
||||
%rep %0 |
||||
[extern %1] |
||||
%rotate 1 |
||||
%endrep |
||||
%endmacro |
||||
|
||||
%imacro bits 1+.nolist |
||||
[bits %1] |
||||
%endmacro |
||||
|
||||
%imacro use16 0.nolist |
||||
[bits 16] |
||||
%endmacro |
||||
%imacro use32 0.nolist |
||||
[bits 32] |
||||
%endmacro |
||||
%imacro use64 0.nolist |
||||
[bits 64] |
||||
%endmacro |
||||
|
||||
%imacro global 1-*.nolist |
||||
%rep %0 |
||||
[global %1] |
||||
%rotate 1 |
||||
%endrep |
||||
%endmacro |
||||
|
||||
%imacro common 1-*.nolist |
||||
%rep %0 |
||||
[common %1] |
||||
%rotate 1 |
||||
%endrep |
||||
%endmacro |
||||
|
||||
%imacro cpu 1+.nolist |
||||
[cpu %1] |
||||
%endmacro |
||||
|
||||
%imacro default 1+.nolist |
||||
[default %1] |
||||
%endmacro |
||||
|
||||
; NASM compatibility shim |
||||
%define __OUTPUT_FORMAT__ __YASM_OBJFMT__ |
||||
|
||||
%ifidn __YASM_OBJFMT__,bin |
||||
%imacro org 1+.nolist |
||||
[org %1] |
||||
%endmacro |
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,win32 |
||||
%imacro export 1+.nolist |
||||
[export %1] |
||||
%endmacro |
||||
|
||||
%imacro safeseh 1+.nolist |
||||
[safeseh %1] |
||||
%endmacro |
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,win64 |
||||
%define __YASM_WIN64__ |
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,x64 |
||||
%define __YASM_WIN64__ |
||||
%endif |
||||
|
||||
%ifdef __YASM_WIN64__ |
||||
%undef __YASM_WIN64__ |
||||
|
||||
%imacro export 1+.nolist |
||||
[export %1] |
||||
%endmacro |
||||
|
||||
; Raw exception handling operations |
||||
%imacro proc_frame 1+.nolist |
||||
%1: |
||||
[proc_frame %1] |
||||
%endmacro |
||||
|
||||
%if 0 |
||||
; Disable these as they're too closely named to the macroized ones. |
||||
; MASM needs a preceding . to use these, so it seems reasonable for |
||||
; us to similarly require the []. |
||||
%imacro pushreg 1.nolist |
||||
[pushreg %1] |
||||
%endmacro |
||||
|
||||
%imacro setframe 1-2.nolist |
||||
[setframe %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro allocstack 1.nolist |
||||
[allocstack %1] |
||||
%endmacro |
||||
|
||||
%imacro savereg 2.nolist |
||||
[savereg %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro savexmm128 2.nolist |
||||
[savexmm128 %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro pushframe 0-1.nolist |
||||
[pushframe %1] |
||||
%endmacro |
||||
|
||||
%imacro endprolog 0.nolist |
||||
[endprolog] |
||||
%endmacro |
||||
%endif |
||||
|
||||
%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 |
||||
push %1 |
||||
[pushreg %1] |
||||
%endmacro |
||||
|
||||
%imacro rex_push_reg 1 |
||||
db 0x48 |
||||
push %1 |
||||
[pushreg %1] |
||||
%endmacro |
||||
|
||||
%imacro push_eflags 0 |
||||
pushfq |
||||
[allocstack 8] |
||||
%endmacro |
||||
|
||||
%imacro rex_push_eflags 0 |
||||
db 0x48 |
||||
pushfq |
||||
[allocstack 8] |
||||
%endmacro |
||||
|
||||
%imacro alloc_stack 1 |
||||
sub rsp, %1 |
||||
[allocstack %1] |
||||
%endmacro |
||||
|
||||
%imacro save_reg 2 |
||||
mov [rsp+%2], %1 |
||||
[savereg %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro save_xmm128 2 |
||||
movdqa [rsp+%2], %1 |
||||
[savexmm128 %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro push_frame 0-1.nolist |
||||
[pushframe %1] |
||||
%endmacro |
||||
|
||||
%imacro set_frame 1-2 |
||||
%if %0==1 |
||||
mov %1, rsp |
||||
%else |
||||
lea %1, [rsp+%2] |
||||
%endif |
||||
[setframe %1 %2] |
||||
%endmacro |
||||
|
||||
%imacro end_prolog 0.nolist |
||||
[endprolog] |
||||
%endmacro |
||||
|
||||
%imacro end_prologue 0.nolist |
||||
[endprolog] |
||||
%endmacro |
||||
|
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,elf |
||||
%define __YASM_ELF__ |
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,elf32 |
||||
%define __YASM_ELF__ |
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,elf64 |
||||
%define __YASM_ELF__ |
||||
%endif |
||||
|
||||
%ifdef __YASM_ELF__ |
||||
%undef __YASM_ELF__ |
||||
%imacro type 1+.nolist |
||||
[type %1] |
||||
%endmacro |
||||
%imacro size 1+.nolist |
||||
[size %1] |
||||
%endmacro |
||||
%imacro weak 1+.nolist |
||||
[weak %1] |
||||
%endmacro |
||||
%endif |
||||
|
||||
%ifidn __YASM_OBJFMT__,rdf |
||||
%imacro library 1+.nolist |
||||
[library %1] |
||||
%endmacro |
||||
%imacro module 1+.nolist |
||||
[module %1] |
||||
%endmacro |
||||
%endif |
||||
|
@ -1,3 +1,3 @@ |
||||
-:27: warning: (WORK_1:4) 4 |
||||
-:28: warning: (WORK_2:4) 4 |
||||
-:29: warning: (DONT_WORK_1:6) 4 4 |
||||
-:27: warning: (WORK_1:2) 4 |
||||
-:28: warning: (WORK_2:2) 4 |
||||
-:29: warning: (DONT_WORK_1:3) 4 4 |
||||
|
Loading…
Reference in new issue