diff --git a/assemble.c b/assemble.c index 7ed08921..a798d176 100644 --- a/assemble.c +++ b/assemble.c @@ -1218,11 +1218,6 @@ static void gencode(int32_t segment, int64_t offset, int bits, insn * ins, const struct itemplate *temp, int64_t insn_end) { - static const char condval[] = { /* conditional opcodes */ - 0x7, 0x3, 0x2, 0x6, 0x2, 0x4, 0xF, 0xD, 0xC, 0xE, 0x6, 0x2, - 0x3, 0x7, 0x3, 0x5, 0xE, 0xC, 0xD, 0xF, 0x1, 0xB, 0x9, 0x5, - 0x0, 0xA, 0xA, 0xB, 0x8, 0x4 - }; uint8_t c; uint8_t bytes[4]; int64_t size; @@ -1561,7 +1556,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, break; case 0330: - *bytes = *codes++ ^ condval[ins->condition]; + *bytes = *codes++ ^ get_cond_opcode(ins->condition); out(offset, segment, bytes, OUT_RAWDATA, 1, NO_SEG, NO_SEG); offset += 1; break; diff --git a/nasm.h b/nasm.h index a9bff49a..97cef3c1 100644 --- a/nasm.h +++ b/nasm.h @@ -466,6 +466,17 @@ enum ccode { /* condition code names */ C_none = -1 }; +static inline uint8_t get_cond_opcode(enum ccode c) +{ + static const uint8_t ccode_opcodes[] = { + 0x7, 0x3, 0x2, 0x6, 0x2, 0x4, 0xf, 0xd, 0xc, 0xe, 0x6, 0x2, + 0x3, 0x7, 0x3, 0x5, 0xe, 0xc, 0xd, 0xf, 0x1, 0xb, 0x9, 0x5, + 0x0, 0xa, 0xa, 0xb, 0x8, 0x4 + }; + + return ccode_opcodes[(int)c]; +} + /* * REX flags */