summaryrefslogtreecommitdiff
path: root/ecomp-c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-07-24 21:08:19 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2020-07-24 21:08:19 +0200
commit8f3209b03e3bfdc2f6cb483db104c5ae9aaeb76c (patch)
tree70a7c8a7fbf56698eb9746f97f4499cfe75977c7 /ecomp-c
parente50caad4825f5b8f8083bda160ef94dc42b9947b (diff)
downloadcompilertests-8f3209b03e3bfdc2f6cb483db104c5ae9aaeb76c.tar.gz
compilertests-8f3209b03e3bfdc2f6cb483db104c5ae9aaeb76c.tar.bz2
asm-i386: fixes initializations and some hexnum debug output
Diffstat (limited to 'ecomp-c')
-rw-r--r--ecomp-c/asm-i386.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ecomp-c/asm-i386.c b/ecomp-c/asm-i386.c
index 5ece809..d4e1aab 100644
--- a/ecomp-c/asm-i386.c
+++ b/ecomp-c/asm-i386.c
@@ -1362,6 +1362,8 @@ static OpcodeInfo *parseOrg( void )
operand_info->next = NULL;
operand_info->type = OPERAND_ABSOLUTE;
operand_info->num = num;
+ operand_info->str = NULL;
+ operand_info->node = NULL;
append_operand( opcode_info, operand_info );
@@ -1557,10 +1559,11 @@ static int patchup_addresses( OpcodeInfo *opcode_info )
static char *get_expression_comment( ExpressionNode *node, char *buf, int bufsize )
{
char s[MAX_STRING_LEN+1];
-
+
+ s[0] = '\0';
switch( node->type ) {
case EXPRESSION_NODE_TYPE_CONST:
- snprintf( s, MAX_STRING_LEN, "%d", node->integer_value );
+ snprintf( s, MAX_STRING_LEN, "$%X", node->integer_value );
strlcat( buf, s, bufsize );
break;
@@ -1598,6 +1601,7 @@ static void print_opcodes( OpcodeInfo *opcode_info )
strlcpy( indent, " ", 2 );
fprintf( stderr, "%X: %s", opcode->addr, opcodename[opcode->opcode] );
operand = opcode->operand;
+ buf[0] = '\0';
while( operand != NULL ) {
switch( operand->type ) {
case OPERAND_ABSOLUTE:
@@ -1617,12 +1621,12 @@ static void print_opcodes( OpcodeInfo *opcode_info )
fprintf( stderr, "%s%s", indent, registername[operand->reg] );
break;
case OPERAND_MEMORY_DIRECT:
- fprintf( stderr, "%s%s=%X", indent,
+ fprintf( stderr, "%s%s=$%X", indent,
get_expression_comment( operand->node, buf, MAX_STRING_LEN ),
operand->addr );
break;
case OPERAND_MEMORY_INDIRECT:
- fprintf( stderr, "%s[%s=%X]", indent,
+ fprintf( stderr, "%s[%s=$%X]", indent,
get_expression_comment( operand->node, buf, MAX_STRING_LEN ),
operand->addr );
break;
@@ -1647,7 +1651,7 @@ void print_labels( Symbol *symbol )
if( DEBUG_PARSER ) {
while( sym != NULL ) {
- fprintf( stderr, "%s=%X\n",
+ fprintf( stderr, "%s=$%X\n",
sym->name, sym->addr );
sym = sym->next;
}