summaryrefslogtreecommitdiffhomepage
path: root/mixutils/mixvm_command.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixutils/mixvm_command.c')
-rw-r--r--mixutils/mixvm_command.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/mixutils/mixvm_command.c b/mixutils/mixvm_command.c
index 19eddf0..4014ede 100644
--- a/mixutils/mixvm_command.c
+++ b/mixutils/mixvm_command.c
@@ -53,6 +53,7 @@ DEC_FUN (sreg_);
DEC_FUN (scmp_);
DEC_FUN (sover_);
DEC_FUN (smem_);
+DEC_FUN (ssym_);
DEC_FUN (sbp_);
DEC_FUN (sbpa_);
DEC_FUN (cbp_);
@@ -96,6 +97,8 @@ COMMAND commands[] = {
{ "sover", cmd_sover_, N_("Set overflow flag value"), "sover T | F" },
{ "smem", cmd_smem_, N_("Set memory contents in given address"),
"smem ADDRESS VALUE" },
+ { "ssym", cmd_ssym_, N_("Set the value of an existing of newly defined symbol"),
+ "ssym SYMBOL WEXPR" },
{ "sbp", cmd_sbp_, N_("Set break point at given line"), "sbp LINENO" },
{ "cbp", cmd_cbp_, N_("Clear break point at given line"), "cbp LINENO" },
{ "sbpa", cmd_sbpa_, N_("Set break point at given address"),
@@ -236,8 +239,13 @@ cmd_load_ (char *arg)
{
errno = 0;
if (arg == NULL || *arg == '\0')
- fputs (_("Missing file name\n"), stderr);
- else if (!mix_vm_load_file (vm_, arg) )
+ {
+ fputs (_("Missing file name\n"), stderr);
+ return TRUE;
+ }
+ mix_eval_remove_symbols_from_table (eval_,
+ mix_vm_get_symbol_table (vm_));
+ if (!mix_vm_load_file (vm_, arg) )
{
fprintf (stderr, _("Cannot load %s: "), arg);
if ( errno == 0 )
@@ -246,9 +254,8 @@ cmd_load_ (char *arg)
perror (NULL);
return TRUE + 1;
}
- mix_eval_use_symbol_table (eval_,
- (mix_symbol_table_t *)
- mix_vm_get_symbol_table (vm_));
+ mix_eval_set_symbols_from_table (eval_,
+ mix_vm_get_symbol_table (vm_));
fprintf (stderr, _("Program loaded. Start address: %d\n"),
mix_vm_get_prog_count (vm_));
@@ -344,7 +351,7 @@ cmd_pc_ (char *arg)
static int
cmd_psym_ (char *arg)
{
- const mix_symbol_table_t *table = mix_vm_get_symbol_table (vm_);
+ const mix_symbol_table_t *table = mix_eval_symbol_table (eval_);
if ( table == NULL )
fputs (_("Symbol table not available\n"), stderr);
else if (arg != NULL && *arg != '\0')
@@ -627,6 +634,35 @@ cmd_smem_ (char *arg)
}
static int
+cmd_ssym_ (char *arg)
+{
+ if (arg == NULL || strlen(arg) == 0)
+ {
+ fprintf (stderr, _("Missing arguments\n"));
+ return cmd_help_ ("ssym");
+ }
+ else
+ {
+ gchar *a = g_strdup (arg);
+ gchar *s = strtok (a, " \t");
+ gchar *w = strtok (NULL, " \t");
+ if (w != NULL && strtok (NULL, " \t") == NULL)
+ {
+ cmd_weval_ (w);
+ if (mix_eval_last_error (eval_) == MIX_EVAL_OK)
+ mix_eval_set_symbol (eval_, s, mix_eval_value (eval_));
+ }
+ else
+ {
+ fprintf (stderr, _("Wrong argument number\n"));
+ cmd_help_ ("ssym");
+ }
+ g_free (a);
+ return TRUE;
+ }
+}
+
+static int
cmd_sbp_ (char *arg)
{
glong lineno;