summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-08-30 17:06:59 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2020-08-30 17:06:59 +0200
commit71e2a4f4926d36a9595aad58b6fa7ef19c2bbfb9 (patch)
tree51b50983eff05cfa2bf05aa9832cdb7ef761d69a
parent3112ed67f92d65863d736fafb7d62b0428acb11a (diff)
downloadcompilertests-71e2a4f4926d36a9595aad58b6fa7ef19c2bbfb9.tar.gz
compilertests-71e2a4f4926d36a9595aad58b6fa7ef19c2bbfb9.tar.bz2
asm-i386: fixed patchup of forward references (again)
-rw-r--r--ecomp-c/asm-i386.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/ecomp-c/asm-i386.c b/ecomp-c/asm-i386.c
index 584c631..6daae41 100644
--- a/ecomp-c/asm-i386.c
+++ b/ecomp-c/asm-i386.c
@@ -1686,12 +1686,29 @@ static int patchup_addresses( OpcodeInfo *opcode_info, int ORG )
int res = 0;
while( opcode != NULL ) {
+
+ /* 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 ) { */
+ if( operand->num == ADDRESS_UNDEFINED ) {
+ if( operand->node != NULL ) {
+ operand->num = evaluateExpression( operand->node, ORG, opcode->addr );
+ }
+ }
+/* } */
+ operand = operand->next;
+ }
/* set new increment of an instruction, if we have to
* enhance the space occupied by the opcode
*/
switch( opcode->opcode ) {
case OPCODE_JMP:
+ if( DEBUG_PARSER ) {
+ fprintf( stderr, "JMP at $%X to $%X\n", opcode->addr, opcode->operand->num );
+ }
if( opcode->addr != ADDRESS_UNDEFINED && opcode->operand->num != ADDRESS_UNDEFINED ) {
int rel = relative_distance( opcode, opcode->addr, opcode->operand->num );
if( DEBUG_PARSER ) {
@@ -1702,7 +1719,7 @@ static int patchup_addresses( OpcodeInfo *opcode_info, int ORG )
/* all fine, optimistic case already taken, short rel8 jump */
} else {
if( DEBUG_PARSER ) {
- fprintf( stderr, "Inreasing opcode of jump to 5 at $%X\n", opcode->addr );
+ fprintf( stderr, "Increasing opcode of jump to 5 at $%X\n", opcode->addr );
}
opcode->size = 5;
res = 1;
@@ -1739,19 +1756,6 @@ static int patchup_addresses( OpcodeInfo *opcode_info, int ORG )
break;
}
- /* 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 ) { */
- if( operand->num == ADDRESS_UNDEFINED ) {
- if( operand->node != NULL ) {
- operand->num = evaluateExpression( operand->node, ORG, opcode->addr );
- }
- }
-/* } */
- operand = operand->next;
- }
opcode = opcode->next;
}