summaryrefslogtreecommitdiff
path: root/parser.c
AgeCommit message (Collapse)AuthorFilesLines
2013-12-04bnd: Add a new nobnd prefixJin Kyu Song1-0/+1
bnd and nobnd prifixes can be used for each instruction line to direct whether bnd registers should be preserved or not. And those are also added as options for DEFAULT directive. Once bnd is set with default, DEFAULT BND, all bnd-prefix available instructions are prefixed with bnd. To override it, nobnd prefix can be used. In the other way, DEFAULT NOBND can disable DEFAULT BND and have nasm encode in the normal way. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-28Add {vex3} and {vex2} prefixes by analogy with {evex}H. Peter Anvin1-1/+3
Allow specifying {vex3} or {vex2} (the latter is currently always redundant, unless we end up with instructions at some point can be specified with legacy prefixes or VEX) to select a specific encoding of VEX-encoded instructions. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-11-27stdscan: Rework curly brace parsing routinesJin Kyu Song1-1/+1
As recommended by the community, a comma-separated decorators ({k1,z}) and nested braces ({{k1},{z}}) are dropped out. So only standard syntax is supported from now. This rework made source code neat and easy to maintain. Most of the codes for handling corner cases are removed. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20match: Check the number of elements in broadcasting operandsJin Kyu Song1-1/+2
The broadcasting decorator {1to##} must describe exactly how many times the memory element is repeated in order to clearly match the correct instruction format. For example, vaddpd zmm30,zmm29,QWORD [rdx+0x3f8]{1to8} ; good vaddpd zmm30,zmm29,QWORD [rdx+0x3f8]{1to16} ; fail qword * 16 = 1024b vaddps zmm30,zmm29,DWORD [rcx]{1to16} ; good vaddps zmm30,zmm29,DWORD [rcx]{1to8} ; fail dword * 8 = 256b Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20Build: Suppress warning messagesJin Kyu Song1-1/+1
Giving a correct printf format specifier supresses the warning message. And a local pointer variable is initialized with NULL. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20AVX-512: Add {evex} instruction prefixJin Kyu Song1-0/+2
For instructions that can be encoded either in VEX or EVEX, {evex} forces nasm to encode in EVEX. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20MPX: Add BND prefix for branch instructionsJin Kyu Song1-0/+1
BND prefix is used for adding bounds checking protection across flow control changes such as call, ret, jmp and jcc calls. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20MPX: Add MPX instructionsJin Kyu Song1-0/+7
Added MPX instructions and corresponding parser and encoder. ICC style mib - base + disp and index are separate - is supported. E.g. bndstx [ebx+3], bnd2, edx -> ebx+3 : base+disp, edx : index As a supplement to NASM style mib - split EA - parser, omitted base+disp is now treated as 0 displacement. E.g. bndstx [,edx], bnd2 -> bndstx [0,edx], bnd2 Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20parser: support split base,index effective addressH. Peter Anvin1-18/+79
Mostly intended for the "mib" expressions in BNDLDX/BNDSTX. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20parse: factor out mref parsingH. Peter Anvin1-125/+132
Factor out the parsing of an mref from parse_line(). In order to support the [base,index] syntax we need to be able to parse an mref in two steps. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20parser: simplify code by keeping a pointer to the current operandH. Peter Anvin1-152/+132
There is an awful lot of syntax-heavy "result->oprs[operand]" going on; simplify by making a pointer to the current operand. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-10-02Add support for DZ and RESZ, document the ZWORD keywordH. Peter Anvin1-4/+9
Add the DZ and RESZ pseudoinstructions and add ZWORD to the documentation. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-08-29AVX-512: Remember the position of operand with broadcast or embedded roundingJin Kyu Song1-0/+6
It was not so straight forward to find the postion of operand that has a broadcasting, embedded rounding mode or SAE (Suppress All Exceptions) decorator out from operands types or bytecode. Remebering the postion of the operand of interest in the parser reduces the burden that assembler looks through the operands. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-22AVX-512: Fix parser to handle opmask decorator correctlyJin Kyu Song1-5/+8
When a memory reference operand is a destination, this could have an opmask decorator as well. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-22AVX-512: Add ZWORD keywordJin Kyu Song1-0/+5
ZWORD (512 bits) keyword is added Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-22AVX-512: Reword comment about opmask decoratorsJin Kyu Song1-1/+1
Previous comment was not so clear. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-16AVX-512: Add EVEX encoding and new instructionsJin Kyu Song1-0/+6
EVEX encoding support includes 32 vector regs (XMM/YMM/ZMM), opmask, broadcasting, embedded rounding mode, suppress all exceptions, compressed displacement. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-06AVX-512: Add support for parsing bracesJin Kyu Song1-2/+92
AVX-512 introduced new syntax using braces for decorators. Opmask, broadcat, rounding control use this new syntax. http://software.intel.com/sites/default/files/319433-015.pdf Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-07-19BR 3392260: Handle instructions only separated by vector SIB sizeH. Peter Anvin1-6/+21
There are two instructions (VGATHERQPS, VPGATHERQD) where the only separation between two forms is the vector length given to the vector SIB. This means the *matcher* has to be able to distinguish instructions by vector SIB length and the matcher only operates on the operands and the instruction flags, not on the bytecode. Export the vector index-ness into the operand flags and add to the matcher. This resolves BR 3392260. Reported-by: Agner <agner@anger.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-07-16parse_line: Shrink code with memset helperCyrill Gorcunov1-3/+2
We know that P_none = 0 thus instead of using for() statement assign them all in one memset call. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-03-01Remove +sBen Rudiak-Gould1-17/+11
It doesn't seem worth >200 lines of C and Perl to save ~50 lines in insns.dat. In order to make this work I had to rename sbyte16/sbyte32 so that they can take an ordinary size suffix (their size suffix was formerly treated specially). This fixes one disassembly bug: 48C7C000000080 disassembles to mov rax,0x80000000, which reassembles to B800000080, which loads a different value. Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com> Acked-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-09-10opflags: Extend opflags_t to 64 bitsCyrill Gorcunov1-1/+1
Soon we will need to encode 512 bits values thus there is no space left in our opflags_t which is 32 bitfield. Extend it to 64 bits width. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-02-24HLE: Implement the basic mechanism for XACQUIRE/XRELEASEH. Peter Anvin1-0/+2
This implements the mechanism for XACQUIRE/XRELEASE. It does not include the necessary annotations in insns.dat. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-24HLE: Split the LOCK and REP prefix slotsH. Peter Anvin1-1/+2
With HLE, the sequence REP LOCK actually makes sense, so support it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2011-11-12BR3392198: Fix compilation warning on prefixesCyrill Gorcunov1-1/+1
insn->prefixes might contain not only values from 'enum prefixes' but from 'enum reg_enum' as well so make it generic 'int' instead. This calms down the compiler about enum's mess and eliminates a wrong assumption that we always have values by particular type in this field. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-28parser: No need to split line if it a bit longer than 80 charsCyrill Gorcunov1-2/+1
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-28Add IS_SREG and IS_FSGS helpersCyrill Gorcunov1-9/+11
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-28A few style fixups in parser.cCyrill Gorcunov1-59/+66
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-07BR3104852: only warn once for repeated prefixesVictor van den Elzen1-1/+1
2010-08-27parser.c: Drop space line and use hex notationCyrill Gorcunov1-3/+2
For big numbers it's easier to estimate bytes count if they are written in hex notation. Let it be so. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-08-24Optimize mov r64,immH. Peter Anvin1-1/+8
Handle immediate-size optimization for "mov r64,imm" -- reduce it to "mov r32,imm32" or "mov r64,imm32" as appropriate. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-07-25Revert "Improve process_ea and introduce -OL"H. Peter Anvin1-1/+0
This reverts commit ac732cb6a599836bf4c988e59ac6de4498758c72. Resolved Conflicts: doc/nasmdoc.src Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2010-07-24Improve process_ea and introduce -OLVictor van den Elzen1-0/+1
Two fixes: 1. Optimization of [bx+0xFFFF] etc 0xFFFF is an sbyte under 16-bit semantics, so make sure to check it right. 2. Don't optimize displacements in -O0 Displacements that fit into an sbyte or can be removed should *not* be optimized in -O0. Implicit zero displacements are still optimized, e.g.: [eax] -> 0 bit displacement, [ebp] -> 8 bit displacement. However explicit displacements are not optimized: [eax+0] -> 32 bit displacement, [ebp+0] -> 32 bit displacement. Because #2 breaks compatibility with 0.98, I introduced a new optimization level: -OL, legacy.
2009-11-01Revert "BR 2887108: Use overflow_ helper to catch inappropriate imm ↵Cyrill Gorcunov1-9/+8
optimization" This reverts commit 41208028ff52d190044ee7532bf14c5aca0f899a. | | From: "H. Peter Anvin" <hpa@zytor.com> | | The tests for overflow_signed() are wrong too. Those are relevant for if a | warning should be issued, but not for how the value should be encoded in | the byte stream. | Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2009-10-31Various tab/space/comment cleanupCyrill Gorcunov1-209/+213
No change on binary level Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31stdscan: switch to stdscan_get/set routinesCyrill Gorcunov1-5/+5
Instead of manipulating stdscan buffer pointer directly we switch to a routine interface. This allow us to unify stdscan access: ie caller should "talk" to stdscan via stdscan_get/set routines. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31nasmlib: Introduce idata_bytes helperCyrill Gorcunov1-37/+18
This allow us to eliminate code duplication Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31BR 2887108: Use overflow_ helper to catch inappropriate imm optimizationCyrill Gorcunov1-8/+9
We should use overflow_ helpers before check if an immediate operand fit a type range, otherwise we may loose high bits. For example when we assemble the following instruction imul eax,eax,0x10000 with -Ox passed we optimze it up to imm8 though it must be imm32. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-14parser.c: pasrse_line -- fix alignmentCyrill Gorcunov1-3/+3
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-23Use I_none opcode instead of hardcoded numberCyrill Gorcunov1-18/+18
Consolidate I_none opcode to be used everywhere instead of mix (-1,I_none). Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-11Fix some format strings for nasm_errorVictor van den Elzen1-3/+3
Added a format attribute to nasm_error (only for GCC) and used the resulting warnings to fix some format strings.
2009-07-18Drop efunc and evaluate argument to parse_line()H. Peter Anvin1-49/+47
We never invoked the parser with anything but the default definitions for evaluate and efunc. Unlike the backend, though, we sometimes invoke parse_line() with redefine_label() instead of define_label(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18Drop the ofmt and errfunc arguments to label definition functionsH. Peter Anvin1-4/+2
We never set ofmt and errfunc to anything but the global values. Dropping them from the label definition function command line simplifies the code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06NASM: relicense under the 2-clause BSD licenseH. Peter Anvin1-12/+0
*To the best of my knowledge*, we now have authorization from everyone who has significantly contributed to NASM in the past. As such, change the license to the 2-clause BSD license. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28Add copyright headers to the *.c/*.h files in the main directoryH. Peter Anvin1-6/+45
Add copyright headers to the *.c/*.h files in the main directory. For files where I'm sure enough that we have all the approvals, I have given them the 2-BSD license, the others have been given the "LGPL for now" license header. Most of them can probably be changed after auditing. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27parser.c: fix stylistic nitpickH. Peter Anvin1-1/+0
Fix stray blank line in parser.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-23parser: don't use midcode declarationsH. Peter Anvin1-1/+2
OpenWatcom can't handle midcode variable declarations. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-23BR 2782055: reject invalid tokens after ]Victor van den Elzen1-8/+16
A bracketed memory reference should be followed by a comma or the end of the line. Enforce this.
2009-02-25Do not confuse segmentless adresses and unknown forward referencesVictor van den Elzen1-0/+8
Also be optimistic with immediate forward references.
2009-02-21BR 2592476: Treat WAIT as a prefix even though it's really an instructionH. Peter Anvin1-0/+2
WAIT is technically an instruction, but from an assembler standpoint it behaves as if it had been a prefix. In particular, it has to be ordered *before* any real hardware prefixes.