mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-13 17:57:12 +08:00
Add support for DZ and RESZ, document the ZWORD keyword
Add the DZ and RESZ pseudoinstructions and add ZWORD to the documentation. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
a9ecfa5ae8
commit
9d5461069d
@ -1,6 +1,6 @@
|
||||
\# --------------------------------------------------------------------------
|
||||
\#
|
||||
\# Copyright 1996-2012 The NASM Authors - All Rights Reserved
|
||||
\# Copyright 1996-2013 The NASM Authors - All Rights Reserved
|
||||
\# See the file AUTHORS included with the NASM distribution for
|
||||
\# the specific copyright holders.
|
||||
\#
|
||||
@ -1264,18 +1264,18 @@ indicate what size of \i{memory operand} it refers to.
|
||||
Pseudo-instructions are things which, though not real x86 machine
|
||||
instructions, are used in the instruction field anyway because that's
|
||||
the most convenient place to put them. The current pseudo-instructions
|
||||
are \i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO} and
|
||||
\i\c{DY}; their \i{uninitialized} counterparts \i\c{RESB}, \i\c{RESW},
|
||||
\i\c{RESD}, \i\c{RESQ}, \i\c{REST}, \i\c{RESO} and \i\c{RESY}; the
|
||||
\i\c{INCBIN} command, the \i\c{EQU} command, and the \i\c{TIMES}
|
||||
prefix.
|
||||
are \i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO},
|
||||
\i\c{DY} and \i\c\{DZ}; their \i{uninitialized} counterparts
|
||||
\i\c{RESB}, \i\c{RESW}, \i\c{RESD}, \i\c{RESQ}, \i\c{REST},
|
||||
\i\c{RESO}, \i\c{RESY} and \i\c\{RESZ}; the \i\c{INCBIN} command, the
|
||||
\i\c{EQU} command, and the \i\c{TIMES} prefix.
|
||||
|
||||
|
||||
\S{db} \c{DB} and Friends: Declaring Initialized Data
|
||||
|
||||
\i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO} and
|
||||
\i\c{DY} are used, much as in MASM, to declare initialized data in the
|
||||
output file. They can be invoked in a wide range of ways:
|
||||
\i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO}, \i\c{DY}
|
||||
and \i\c{DZ} are used, much as in MASM, to declare initialized data in
|
||||
the output file. They can be invoked in a wide range of ways:
|
||||
\I{floating-point}\I{character constant}\I{string constant}
|
||||
|
||||
\c db 0x55 ; just the byte 0x55
|
||||
@ -1292,20 +1292,21 @@ output file. They can be invoked in a wide range of ways:
|
||||
\c dq 1.234567e20 ; double-precision float
|
||||
\c dt 1.234567e20 ; extended-precision float
|
||||
|
||||
\c{DT}, \c{DO} and \c{DY} do not accept \i{numeric constants} as operands.
|
||||
\c{DT}, \c{DO}, \c{DY} and \c{DZ} do not accept \i{numeric constants}
|
||||
as operands.
|
||||
|
||||
|
||||
\S{resb} \c{RESB} and Friends: Declaring \i{Uninitialized} Data
|
||||
|
||||
\i\c{RESB}, \i\c{RESW}, \i\c{RESD}, \i\c{RESQ}, \i\c{REST}, \i\c{RESO}
|
||||
and \i\c{RESY} are designed to be used in the BSS section of a module:
|
||||
they declare \e{uninitialized} storage space. Each takes a single
|
||||
operand, which is the number of bytes, words, doublewords or whatever
|
||||
to reserve. As stated in \k{qsother}, NASM does not support the
|
||||
MASM/TASM syntax of reserving uninitialized space by writing
|
||||
\I\c{?}\c{DW ?} or similar things: this is what it does instead. The
|
||||
operand to a \c{RESB}-type pseudo-instruction is a \i\e{critical
|
||||
expression}: see \k{crit}.
|
||||
\i\c{RESB}, \i\c{RESW}, \i\c{RESD}, \i\c{RESQ}, \i\c{REST},
|
||||
\i\c{RESO}, \i\c{RESY} and \i\c\{RESZ} are designed to be used in the
|
||||
BSS section of a module: they declare \e{uninitialized} storage
|
||||
space. Each takes a single operand, which is the number of bytes,
|
||||
words, doublewords or whatever to reserve. As stated in \k{qsother},
|
||||
NASM does not support the MASM/TASM syntax of reserving uninitialized
|
||||
space by writing \I\c{?}\c{DW ?} or similar things: this is what it
|
||||
does instead. The operand to a \c{RESB}-type pseudo-instruction is a
|
||||
\i\e{critical expression}: see \k{crit}.
|
||||
|
||||
For example:
|
||||
|
||||
@ -1313,6 +1314,7 @@ For example:
|
||||
\c wordvar: resw 1 ; reserve a word
|
||||
\c realarray resq 10 ; array of ten reals
|
||||
\c ymmval: resy 1 ; one YMM register
|
||||
\c zmmvals: resz 32 ; 32 ZMM registers
|
||||
|
||||
\S{incbin} \i\c{INCBIN}: Including External \i{Binary Files}
|
||||
|
||||
@ -1866,11 +1868,11 @@ invent one using the macro processor.
|
||||
|
||||
When assembling with the optimizer set to level 2 or higher (see
|
||||
\k{opt-O}), NASM will use size specifiers (\c{BYTE}, \c{WORD},
|
||||
\c{DWORD}, \c{QWORD}, \c{TWORD}, \c{OWORD} or \c{YWORD}), but will
|
||||
give them the smallest possible size. The keyword \c{STRICT} can be
|
||||
used to inhibit optimization and force a particular operand to be
|
||||
emitted in the specified size. For example, with the optimizer on, and
|
||||
in \c{BITS 16} mode,
|
||||
\c{DWORD}, \c{QWORD}, \c{TWORD}, \c{OWORD}, \c{YWORD} or \c{ZWORD}),
|
||||
but will give them the smallest possible size. The keyword \c{STRICT}
|
||||
can be used to inhibit optimization and force a particular operand to
|
||||
be emitted in the specified size. For example, with the optimizer on,
|
||||
and in \c{BITS 16} mode,
|
||||
|
||||
\c push dword 33
|
||||
|
||||
|
@ -55,6 +55,7 @@ DQ ignore ignore ignore
|
||||
DT ignore ignore ignore
|
||||
DO ignore ignore ignore
|
||||
DY ignore ignore ignore
|
||||
DZ ignore ignore ignore
|
||||
RESB imm [ resb] 8086
|
||||
RESW ignore ignore ignore
|
||||
RESD ignore ignore ignore
|
||||
@ -62,6 +63,7 @@ RESQ ignore ignore ignore
|
||||
REST ignore ignore ignore
|
||||
RESO ignore ignore ignore
|
||||
RESY ignore ignore ignore
|
||||
RESZ ignore ignore ignore
|
||||
|
||||
;# Conventional instructions
|
||||
AAA void [ 37] 8086,NOLONG
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 1996-2012 The NASM Authors - All Rights Reserved
|
||||
* Copyright 1996-2013 The NASM Authors - All Rights Reserved
|
||||
* See the file AUTHORS included with the NASM distribution for
|
||||
* the specific copyright holders.
|
||||
*
|
||||
@ -790,6 +790,8 @@ int idata_bytes(int opcode)
|
||||
return 16;
|
||||
case I_DY:
|
||||
return 32;
|
||||
case I_DZ:
|
||||
return 64;
|
||||
case I_none:
|
||||
return -1;
|
||||
default:
|
||||
|
13
parser.c
13
parser.c
@ -406,7 +406,8 @@ restart_parse:
|
||||
if (result->opcode == I_DB || result->opcode == I_DW ||
|
||||
result->opcode == I_DD || result->opcode == I_DQ ||
|
||||
result->opcode == I_DT || result->opcode == I_DO ||
|
||||
result->opcode == I_DY || result->opcode == I_INCBIN) {
|
||||
result->opcode == I_DY || result->opcode == I_DZ ||
|
||||
result->opcode == I_INCBIN) {
|
||||
extop *eop, **tail = &result->eops, **fixptr;
|
||||
int oper_num = 0;
|
||||
int32_t sign;
|
||||
@ -414,7 +415,7 @@ restart_parse:
|
||||
result->eops_float = false;
|
||||
|
||||
/*
|
||||
* Begin to read the DB/DW/DD/DQ/DT/DO/INCBIN operands.
|
||||
* Begin to read the DB/DW/DD/DQ/DT/DO/DY/DZ/INCBIN operands.
|
||||
*/
|
||||
while (1) {
|
||||
i = stdscan(NULL, &tokval);
|
||||
@ -495,7 +496,7 @@ is_float:
|
||||
eop->stringlen = idata_bytes(result->opcode);
|
||||
if (eop->stringlen > 16) {
|
||||
nasm_error(ERR_NONFATAL, "floating-point constant"
|
||||
" encountered in DY instruction");
|
||||
" encountered in DY or DZ instruction");
|
||||
eop->stringlen = 0;
|
||||
} else if (eop->stringlen < 1) {
|
||||
nasm_error(ERR_NONFATAL, "floating-point constant"
|
||||
@ -1049,7 +1050,7 @@ is_expression:
|
||||
result->oprs[operand++].type = 0;
|
||||
|
||||
/*
|
||||
* Transform RESW, RESD, RESQ, REST, RESO, RESY into RESB.
|
||||
* Transform RESW, RESD, RESQ, REST, RESO, RESY, RESZ into RESB.
|
||||
*/
|
||||
switch (result->opcode) {
|
||||
case I_RESW:
|
||||
@ -1076,6 +1077,10 @@ is_expression:
|
||||
result->opcode = I_RESB;
|
||||
result->oprs[0].offset *= 32;
|
||||
break;
|
||||
case I_RESZ:
|
||||
result->opcode = I_RESB;
|
||||
result->oprs[0].offset *= 64;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user