summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-07-27 20:54:27 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2020-07-27 20:54:27 +0200
commitd628150b7ceb31ff2aad170365bda652733e10ad (patch)
tree9291e88dbd5ea1db6e677f31db39a392c6a0aa24
parent53ebb640a4f7cb638a2a40eeda0a0465a42b39d1 (diff)
downloadcompilertests-d628150b7ceb31ff2aad170365bda652733e10ad.tar.gz
compilertests-d628150b7ceb31ff2aad170365bda652733e10ad.tar.bz2
asm-i386: tried to fix assignment
-rw-r--r--ecomp-c/asm-i386.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/ecomp-c/asm-i386.c b/ecomp-c/asm-i386.c
index ef3dba1..a79d03e 100644
--- a/ecomp-c/asm-i386.c
+++ b/ecomp-c/asm-i386.c
@@ -1462,6 +1462,7 @@ static OpcodeInfo *parseAssignment( void )
OpcodeInfo *opcode_info;
OperandInfo *operand_info;
Symbol *symbol;
+ ExpressionNode *node;
opcode_info = Allocate( sizeof( OpcodeInfo ) );
opcode_info->addr = 0;
@@ -1479,6 +1480,11 @@ static OpcodeInfo *parseAssignment( void )
}
}
symbol->defined = 1;
+
+ node = create_expression_node( );
+ node->type = EXPRESSION_NODE_TYPE_VAR;
+ node->symbol = symbol;
+
sym = getSym( );
Expect( S_equals );
@@ -1491,14 +1497,6 @@ static OpcodeInfo *parseAssignment( void )
append_operand( opcode_info, operand_info );
- /* TODO: symbols are only label, adresses for now, so we
- * abuse it to store constants, we could also do lazy
- * evaluation */
- /* TODO: make an assignment node, cannot evaluate here without
- * current ORG and LC!
- * symbol->addr = evaluateExpression( node );
- */
-
return opcode_info;
}
@@ -1822,6 +1820,10 @@ static int compute_addresses( OpcodeInfo *opcode_info )
fprintf( stderr, "ORG/LC set to $%X\n", LC );
}
break;
+
+ case OPCODE_PSEUDO_ASSIGN:
+ opcode->operand->node->left->symbol->addr = evaluateExpression( opcode->operand->node->right, ORG, LC );
+ break;
case OPCODE_PSEUDO_DD:
case OPCODE_PSEUDO_DW:
@@ -1915,12 +1917,12 @@ static void generate_code( OpcodeInfo *opcode_info )
fputs( "labels:\n", stderr );
print_labels( symbol );
}
- check_for_undefined_labels( symbol );
has_to_relocate = patchup_addresses( opcode_info, ORG );
} while( has_to_relocate );
compute_addresses( opcode_info );
pass++;
+ check_for_undefined_labels( symbol );
if( DEBUG_PARSER ) {
fprintf( stderr, "-- pass %d\n", pass );
fputs( "code:\n", stderr );
@@ -2137,6 +2139,8 @@ static void emit_opcode( OpcodeInfo *opcode_info )
case OPCODE_RET:
Emit( "%c", 0xC3 );
break;
+ case OPCODE_PSEUDO_ASSIGN:
+ break;
default:
Abort( "Opcode '%s' has not been implemented when generating binary",
opcodename[opcode_info->opcode] );