summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjaortega <jaortega>2000-12-23 02:23:27 +0000
committerjaortega <jaortega>2000-12-23 02:23:27 +0000
commitf9c1896e70bb78487f5e21136d8a6584e2653b47 (patch)
tree735c1e2f9c25ac24ae6e4a459855e9d8eebab8f5
parentcaa95f92c73f1fd81db0862d2bf6989c81cd4607 (diff)
downloadmdk-f9c1896e70bb78487f5e21136d8a6584e2653b47.tar.gz
mdk-f9c1896e70bb78487f5e21136d8a6584e2653b47.tar.bz2
(mix_vm_get_uptime) new method
(mix_vm_run, mix_vm_exec_next) update the vm clock after execution of instructions
-rw-r--r--mixlib/mix_vm.c16
-rw-r--r--mixlib/mix_vm.h5
2 files changed, 20 insertions, 1 deletions
diff --git a/mixlib/mix_vm.c b/mixlib/mix_vm.c
index 38ce5a9..c778615 100644
--- a/mixlib/mix_vm.c
+++ b/mixlib/mix_vm.c
@@ -74,7 +74,9 @@ mix_vm_new (void)
for (i = 0; i < BD_NO_; ++i)
vm->devices[i] = NULL;
-
+
+ vm->clock = mix_vm_clock_new ();
+
vm_reset_ (vm);
return vm;
}
@@ -339,6 +341,8 @@ mix_vm_run (mix_vm_t *vm)
mix_word_to_ins_uncheck (get_cell_ (vm, get_loc_ (vm)), ins);
if ( !(*ins_handlers_[ins.opcode]) (vm,&ins) )
return MIX_VM_ERROR;
+ else
+ update_time_ (vm, &ins);
if (bp_is_set_ (vm, get_loc_ (vm)))
return MIX_VM_BREAK;
if (get_loc_ (vm) >= MIX_VM_CELL_NO) halt_ (vm, TRUE);
@@ -357,6 +361,8 @@ mix_vm_exec_next (mix_vm_t *vm)
mix_word_to_ins_uncheck (get_cell_ (vm, get_loc_ (vm)), ins);
if (!(*ins_handlers_[ins.opcode]) (vm, &ins))
return MIX_VM_ERROR;
+ else
+ update_time_ (vm, &ins);
return bp_is_set_ (vm, get_loc_ (vm)) ? MIX_VM_BREAK : MIX_VM_OK;
}
@@ -471,3 +477,11 @@ mix_vm_clear_all_breakpoints (mix_vm_t *vm)
bp_clear_all_ (vm);
}
+/* Get the vm uptime, defined as the time spent executing instructions */
+mix_time_t
+mix_vm_get_uptime (const mix_vm_t *vm)
+{
+ g_return_val_if_fail (vm != NULL, 0);
+ return mix_vm_clock_get_time (get_clock_ (vm));
+}
+
diff --git a/mixlib/mix_vm.h b/mixlib/mix_vm.h
index 62ba34d..91d1d28 100644
--- a/mixlib/mix_vm.h
+++ b/mixlib/mix_vm.h
@@ -28,6 +28,7 @@
#include "mix_code_file.h"
#include "mix_src_file.h"
#include "mix_symbol_table.h"
+#include "mix_vm_clock.h"
/* Comparison flag */
typedef enum { mix_LESS, mix_EQ, mix_GREAT } mix_cmpflag_t;
@@ -178,6 +179,10 @@ mix_vm_clear_breakpoint_address (mix_vm_t *vm, guint address) ;
extern void
mix_vm_clear_all_breakpoints (mix_vm_t *vm);
+/* Get the vm uptime, defined as the time spent executing instructions */
+extern mix_time_t
+mix_vm_get_uptime (const mix_vm_t *vm);
+
#endif /* MIX_VM_H */