瀏覽代碼

print garbage instructions nicer

master
Martin Dørum 3 年之前
父節點
當前提交
d48ca19bca
共有 1 個檔案被更改,包括 13 行新增0 行删除
  1. 13
    0
      lib/vm/print.c

+ 13
- 0
lib/vm/print.c 查看文件

@@ -1,6 +1,7 @@
#include "vm/print.h"

#include <stdio.h>
#include <string.h>

void l2_vm_print_val(struct l2_vm_value *val) {
switch (val->flags & 0x0f) {
@@ -203,6 +204,18 @@ void l2_vm_print_op(l2_word *ops, size_t opcount, size_t *ptr) {
case L2_OP_HALT:
printf("HALT\n");
break;

default:
{
l2_word word = (l2_word)opcode;
char bytes[sizeof(word)];
memcpy(&bytes, &word, sizeof(word));
printf("?");
for (size_t i = 0; i < sizeof(bytes); ++i) {
printf(" %02x", bytes[i]);
}
printf("\n");
}
}
}


Loading…
取消
儲存