summaryrefslogtreecommitdiff
path: root/ecomp-c/asm-i386.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-04-11 20:39:28 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2020-04-11 20:39:28 +0200
commit6fda06667e3991c39b721c13b040d7fb35e2b8b1 (patch)
tree27f26aa82ca5a4b111a27dd22adc9d8e04860f67 /ecomp-c/asm-i386.c
parentec256aa65d1c0ce880472e09730367d015862225 (diff)
downloadcompilertests-6fda06667e3991c39b721c13b040d7fb35e2b8b1.tar.gz
compilertests-6fda06667e3991c39b721c13b040d7fb35e2b8b1.tar.bz2
added some comments on address rewriting
Diffstat (limited to 'ecomp-c/asm-i386.c')
-rw-r--r--ecomp-c/asm-i386.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ecomp-c/asm-i386.c b/ecomp-c/asm-i386.c
index b2255a0..d905e55 100644
--- a/ecomp-c/asm-i386.c
+++ b/ecomp-c/asm-i386.c
@@ -1114,6 +1114,9 @@ static int patchup_addresses( OpcodeInfo *opcode_info )
while( opcode != NULL ) {
+ /* set new increment of an instruction, if we have to
+ * enhance the space occupied by the opcode
+ */
switch( opcode->opcode ) {
case OPCODE_JMP:
case OPCODE_JE:
@@ -1137,6 +1140,14 @@ static int patchup_addresses( OpcodeInfo *opcode_info )
break;
}
+ /* if an opcode has an increment, we must adapt
+ * - all addresses and labels coming after this instruction,
+ * - invalidate all addresses in opcodes below our current
+ * instruction, so they get recalculated
+ */
+
+ /* replace illegal address (forward references) with the
+ * correct address */
operand = opcode->operand;
while( operand != NULL ) {
if( operand->type == OPERAND_MEMORY_DIRECT || operand->type == OPERAND_MEMORY_INDIRECT ) {