diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2019-08-09 14:21:42 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2019-08-09 14:21:42 -0700 |
commit | fb118890402f44a816c7e345b80e2b2dd54c73b7 (patch) | |
tree | b9c49417a62bfbe13f5297859408a9940d2dd659 | |
parent | 63cacad27123662290958bab5d2e4ea02db95048 (diff) | |
download | nasm-fb118890402f44a816c7e345b80e2b2dd54c73b7.tar.gz nasm-fb118890402f44a816c7e345b80e2b2dd54c73b7.tar.xz nasm-fb118890402f44a816c7e345b80e2b2dd54c73b7.zip |
BR 3392590: add warning for valid but obsolete instructions
Just becase one is compiling for an old CPU doesn't mean one wants to
use obsolete instructions that would not be forward compatible. Rename
the "obsolete" warning to "obsolete-removed" and create a new
"obsolete-valid" warning to go with it (-w[+-]obsolete controls both
options, as usual.)
Suggested-by: C. Masloch <pushbx@38.de>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r-- | asm/assemble.c | 22 | ||||
-rw-r--r-- | test/obsolete.asm | 9 |
2 files changed, 25 insertions, 6 deletions
diff --git a/asm/assemble.c b/asm/assemble.c index 82d6c6cf..ad6d5ea6 100644 --- a/asm/assemble.c +++ b/asm/assemble.c @@ -782,21 +782,31 @@ int64_t assemble(int32_t segment, int64_t start, int bits, insn *instruction) /* Matches! */ if (unlikely(itemp_has(temp, IF_OBSOLETE))) { /* - * If IF_OBSOLETE is set, warn unless we have *exactly* - * the correct CPU level set. + * If IF_OBSOLETE is set, warn the user. Different + * warning classes for "obsolete but valid for this + * specific CPU" and "obsolete and gone." * - *!obsolete [on] instruction obsolete for the target CPU - *! warns if an instruction which has been removed + *!obsolete-removed [on] instruction obsolete and removed on the target CPU + *! warns for an instruction which has been removed *! from the architecture, and is no longer included *! in the CPU definition given in the \c{[CPU]} *! directive, for example \c{POP CS}, the opcode for *! which, \c{0Fh}, instead is an opcode prefix on *! CPUs newer than the first generation 8086. + * + *!obsolete-valid [on] instruction obsolete but valid on the target CPU + *! warns for an instruction which has been removed + *! from the architecture, but is still valid on the + *! specific CPU given in the \c{CPU} directive. Code + *! using these instructions is not forward compatible. */ if (iflag_cmp_cpu_level(&insns_flags[temp->iflag_idx], &cpu)) { - nasm_warn(WARN_OBSOLETE, - "obsolete instruction invalid on the target CPU"); + nasm_warn(WARN_OBSOLETE_REMOVED, + "instruction obsolete and removed on the target CPU"); + } else { + nasm_warn(WARN_OBSOLETE_VALID, + "instruction obsolete but valid on the target CPU"); } } diff --git a/test/obsolete.asm b/test/obsolete.asm new file mode 100644 index 00000000..49dd772f --- /dev/null +++ b/test/obsolete.asm @@ -0,0 +1,9 @@ + bits 16 + + cpu 8086 + pop cs + mov cs,ax + + cpu 386 + pop cs + mov cs,ax |