diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2019-01-08 04:28:05 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2019-01-08 04:28:05 +0000 |
commit | cb2780e435aede4e13653af62a1758e33bd4527c (patch) | |
tree | 39f3c64aa8a3a5f82ae7d9d063f23c83f87e559e | |
parent | af797b7574b6332e1722ef136e78aa734cba91b0 (diff) | |
download | mdk-cb2780e435aede4e13653af62a1758e33bd4527c.tar.gz mdk-cb2780e435aede4e13653af62a1758e33bd4527c.tar.bz2 |
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.
-rw-r--r-- | mixlib/mix_parser.c | 34 |
1 files 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 @@ -224,15 +224,26 @@ update_future_refs_value_ (mix_parser_t *parser, const gchar *name, 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); } - |