mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-01-30 16:41:05 +08:00
Factor out size tokens and annotate with the corresponding size
There is space in the token table to explicitly encode the size corresponding to a size token. We might as well do so... Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
e7c75e5521
commit
11599f49da
@ -767,7 +767,8 @@ is_expression:
|
||||
}
|
||||
first = false;
|
||||
op->type = 0; /* so far, no override */
|
||||
while (i == TOKEN_SPECIAL) { /* size specifiers */
|
||||
/* size specifiers */
|
||||
while (i == TOKEN_SPECIAL || i == TOKEN_SIZE) {
|
||||
switch (tokval.t_integer) {
|
||||
case S_BYTE:
|
||||
if (!setsize) /* we want to use only the first */
|
||||
@ -835,7 +836,8 @@ is_expression:
|
||||
mref = true;
|
||||
bracket = (i == '[');
|
||||
i = stdscan(NULL, &tokval); /* then skip the colon */
|
||||
while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
|
||||
while (i == TOKEN_SPECIAL || i == TOKEN_SIZE ||
|
||||
i == TOKEN_PREFIX) {
|
||||
process_size_override(result, op);
|
||||
i = stdscan(NULL, &tokval);
|
||||
}
|
||||
@ -880,7 +882,8 @@ is_expression:
|
||||
}
|
||||
|
||||
i = stdscan(NULL, &tokval); /* then skip the colon */
|
||||
while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
|
||||
while (i == TOKEN_SPECIAL || i == TOKEN_SIZE ||
|
||||
i == TOKEN_PREFIX) {
|
||||
process_size_override(result, op);
|
||||
i = stdscan(NULL, &tokval);
|
||||
}
|
||||
|
@ -60,24 +60,26 @@ xrelease
|
||||
bnd
|
||||
nobnd
|
||||
|
||||
% TOKEN_SIZE, 0, SIZE_*, S_*
|
||||
byte
|
||||
word
|
||||
dword
|
||||
qword
|
||||
tword
|
||||
oword
|
||||
yword
|
||||
zword
|
||||
|
||||
% TOKEN_SPECIAL, 0, 0, S_*
|
||||
abs
|
||||
byte
|
||||
dword
|
||||
far
|
||||
long
|
||||
near
|
||||
nosplit
|
||||
oword
|
||||
qword
|
||||
rel
|
||||
short
|
||||
strict
|
||||
to
|
||||
tword
|
||||
word
|
||||
yword
|
||||
zword
|
||||
|
||||
% TOKEN_ID, 0, TFLAG_WARN, 0
|
||||
ptr
|
||||
|
@ -167,7 +167,8 @@ enum token_type { /* token types, other than chars */
|
||||
TOKEN_INSN, /* instruction name */
|
||||
TOKEN_HERE, /* $ */
|
||||
TOKEN_BASE, /* $$ */
|
||||
TOKEN_SPECIAL, /* BYTE, WORD, DWORD, QWORD, FAR, NEAR, etc */
|
||||
TOKEN_SIZE, /* BYTE, WORD, DWORD, QWORD, etc */
|
||||
TOKEN_SPECIAL, /* REL, FAR, NEAR, STRICT, NOSPLIT, etc */
|
||||
TOKEN_PREFIX, /* A32, O16, LOCK, REPNZ, TIMES, etc */
|
||||
TOKEN_SHL, /* << or <<< */
|
||||
TOKEN_SHR, /* >> */
|
||||
@ -1081,25 +1082,40 @@ extern const struct dfmt *dfmt;
|
||||
|
||||
#define TYS_ELEMENTS(x) ((x) << 8)
|
||||
|
||||
/* Sizes corresponding to various tokens */
|
||||
enum byte_sizes {
|
||||
SIZE_BYTE = 1,
|
||||
SIZE_WORD = 2,
|
||||
SIZE_DWORD = 4,
|
||||
SIZE_QWORD = 8,
|
||||
SIZE_TWORD = 10,
|
||||
SIZE_OWORD = 16,
|
||||
SIZE_YWORD = 32,
|
||||
SIZE_ZWORD = 64
|
||||
};
|
||||
|
||||
enum special_tokens {
|
||||
SPECIAL_ENUM_START = PREFIX_ENUM_LIMIT,
|
||||
S_ABS = SPECIAL_ENUM_START,
|
||||
S_BYTE,
|
||||
SIZE_ENUM_START = PREFIX_ENUM_LIMIT,
|
||||
S_BYTE = SIZE_ENUM_START,
|
||||
S_WORD,
|
||||
S_DWORD,
|
||||
S_QWORD,
|
||||
S_TWORD,
|
||||
S_OWORD,
|
||||
S_YWORD,
|
||||
S_ZWORD,
|
||||
SIZE_ENUM_LIMIT,
|
||||
|
||||
SPECIAL_ENUM_START = SIZE_ENUM_LIMIT,
|
||||
S_ABS = SPECIAL_ENUM_START,
|
||||
S_FAR,
|
||||
S_LONG,
|
||||
S_NEAR,
|
||||
S_NOSPLIT,
|
||||
S_OWORD,
|
||||
S_QWORD,
|
||||
S_REL,
|
||||
S_SHORT,
|
||||
S_STRICT,
|
||||
S_TO,
|
||||
S_TWORD,
|
||||
S_WORD,
|
||||
S_YWORD,
|
||||
S_ZWORD,
|
||||
SPECIAL_ENUM_LIMIT
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user