소스 검색

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…
취소
저장