From cb2780e435aede4e13653af62a1758e33bd4527c Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Tue, 8 Jan 2019 04:28:05 +0000 Subject: Fix for bug #47208: correctly store immediate constants We were taking only the first 3 bits of the index byte in a the word representing immediate constants, so that, for instance, =262143=, representing 00 00 63 63 63, was stored as 00 00 07 63 63. --- mixlib/mix_parser.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/mixlib/mix_parser.c b/mixlib/mix_parser.c index 796f3ad..f1ec253 100644 --- a/mixlib/mix_parser.c +++ b/mixlib/mix_parser.c @@ -223,16 +223,27 @@ update_future_refs_value_ (mix_parser_t *parser, const gchar *name, #define update_future_refs_(parser,name,rem) \ update_future_refs_value_(parser, name, (parser)->loc_count, rem) +static void +add_raw_ (mix_parser_t *parser, mix_word_t word, guint lineno) +{ + if ( parser->status == MIX_PERR_NOCOMP || parser->status == MIX_PERR_OK ) + { + ins_node_ *node = g_new (ins_node_, 1); + node->ins = word; + node->lineno = lineno; + g_tree_insert (parser->ins_table, + GUINT_TO_POINTER ((guint)parser->loc_count), + (gpointer)node); + } +} + static void update_ls_ (gpointer symbol, gpointer value, gpointer parser) { /* add an instruction on current location and update refs to it */ - mix_ins_t ins; mix_word_t w = (mix_word_t) GPOINTER_TO_UINT (value); mix_parser_t *par = (mix_parser_t *) parser; - - mix_word_to_ins_uncheck (w, ins); update_future_refs_ (par, (const gchar *)symbol, TRUE); - mix_parser_add_ins (par, &ins, 0); + add_raw_ (par, w, 0); par->loc_count++; } @@ -542,20 +553,6 @@ mix_parser_define_ls (mix_parser_t *parser, mix_word_t value) } /* Compilation */ -static void -add_raw_ (mix_parser_t *parser, mix_word_t word, guint lineno) -{ - if ( parser->status == MIX_PERR_NOCOMP || parser->status == MIX_PERR_OK ) - { - ins_node_ *node = g_new (ins_node_, 1); - node->ins = word; - node->lineno = lineno; - g_tree_insert (parser->ins_table, - GUINT_TO_POINTER ((guint)parser->loc_count), - (gpointer)node); - } -} - void mix_parser_add_ins (mix_parser_t *parser, const mix_ins_t *new_ins, guint lineno) @@ -606,4 +603,3 @@ mix_parser_log_error (mix_parser_t *parser, mix_parser_err_t error, else fputs ("\n", stderr); } - -- cgit v1.2.3