aboutsummaryrefslogtreecommitdiff
path: root/vm/runtime.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-31 22:29:07 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-31 22:30:53 +0000
commit5045452d7a78d888329eec886011a176afd7adb0 (patch)
tree1ad92f45e02f61706c0a00d8b0b7fe4f7551e0cb /vm/runtime.c
parent0f0a1c7699fe48c726081230df605674a8a89c57 (diff)
downloadovm-5045452d7a78d888329eec886011a176afd7adb0.tar.gz
ovm-5045452d7a78d888329eec886011a176afd7adb0.tar.bz2
ovm-5045452d7a78d888329eec886011a176afd7adb0.zip
Added flag which forces the printing of hexes
Anything other than char (which can just use print.byte to print the hex) and byte (which prints hexes anyway), all other types may be forced to print a hex rather than a number if PRINT_HEX is 1.
Diffstat (limited to 'vm/runtime.c')
-rw-r--r--vm/runtime.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/vm/runtime.c b/vm/runtime.c
index 5558280..402b541 100644
--- a/vm/runtime.c
+++ b/vm/runtime.c
@@ -195,18 +195,42 @@ err_t vm_execute(vm_t *vm)
printf("0x%x", datum.as_byte);
break;
case TYPE_INT: {
- printf("%" PRId32, datum.as_int);
+ printf(
+#if PRINT_HEX == 1
+ "0x%X",
+#else
+ "%" PRId32,
+#endif
+ datum.as_int);
break;
}
case TYPE_HWORD:
- printf("%" PRIu32, datum.as_hword);
+ printf(
+#if PRINT_HEX == 1
+ "0x%X",
+#else
+ "%" PRIu32,
+#endif
+ datum.as_hword);
break;
case TYPE_LONG: {
- printf("%" PRId64, datum.as_long);
+ printf(
+#if PRINT_HEX == 1
+ "0x%dX",
+#else
+ "%" PRId64,
+#endif
+ datum.as_long);
break;
}
case TYPE_WORD:
- printf("%" PRIu64, datum.as_word);
+ printf(
+#if PRINT_HEX == 1
+ "0x%lX",
+#else
+ "%" PRIu64,
+#endif
+ datum.as_word);
break;
}