From: Robert Pengelly Date: Mon, 9 Jun 2025 21:35:17 +0000 (+0100) Subject: Allow Intel 386 registers for both bits == 32 and target CPU is 386 or newer and... X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=828a2c5028db33423798bdd743297735c0601ca1;p=sasm.git Allow Intel 386 registers for both bits == 32 and target CPU is 386 or newer and also allow 16-bit registers with or without them conditions --- diff --git a/coff.c b/coff.c index a75afbf..7c9d679 100644 --- a/coff.c +++ b/coff.c @@ -40,7 +40,6 @@ static int output_relocation (FILE *outfile, struct fixup *fixup) { switch (fixup->reloc_type) { case RELOC_TYPE_DEFAULT: - case RELOC_TYPE_FAR_CALL: switch (fixup->size) { @@ -82,12 +81,11 @@ static int output_relocation (FILE *outfile, struct fixup *fixup) { } - } else { + } else if (state->format == AS_OUTPUT_WIN32) { switch (fixup->reloc_type) { case RELOC_TYPE_DEFAULT: - case RELOC_TYPE_FAR_CALL: switch (fixup->size) { @@ -112,6 +110,13 @@ static int output_relocation (FILE *outfile, struct fixup *fixup) { case RELOC_TYPE_RVA: + if (fixup->size != 4) { + + report_at (__FILE__, __LINE__, REPORT_INTERNAL_ERROR, "unsupported COFF relocation size %i for reloc_type RELOC_TYPE_RVA", fixup->size); + exit (EXIT_FAILURE); + + } + type = IMAGE_REL_I386_DIR32NB; break; diff --git a/intel.c b/intel.c index e77595f..27c7c6c 100644 --- a/intel.c +++ b/intel.c @@ -3008,22 +3008,28 @@ static int base_index_check (char *operand_string) { || (instruction.index_reg && (!instruction.index_reg->type.base_index || !instruction.index_reg->type.qword))) { goto bad; } + + return 0; + + } - } else if (bits == 32) { + if (bits == 32 || cpu_arch_flags.cpu_386) { if ((instruction.base_reg && !instruction.base_reg->type.dword) || (instruction.index_reg && (!instruction.index_reg->type.base_index || !instruction.index_reg->type.dword))) { - goto bad; + goto _check16; } + + return 0; - } else { + } - if ((instruction.base_reg && (!instruction.base_reg->type.base_index || !instruction.base_reg->type.word)) - || (instruction.index_reg && (!instruction.index_reg->type.base_index || !instruction.index_reg->type.word - || !(instruction.base_reg && instruction.base_reg->number < 6 && instruction.index_reg->number >= 6 - && instruction.log2_scale_factor == 0)))) { - goto bad; - } +_check16: + if ((instruction.base_reg && (!instruction.base_reg->type.base_index || !instruction.base_reg->type.word)) + || (instruction.index_reg && (!instruction.index_reg->type.base_index || !instruction.index_reg->type.word + || !(instruction.base_reg && instruction.base_reg->number < 6 && instruction.index_reg->number >= 6 + && instruction.log2_scale_factor == 0)))) { + goto bad; } return 0;