From ac554865a6be2da4db5baf383d44763200d85543 Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Tue, 9 Dec 2025 22:08:53 +0000 Subject: [PATCH] Make ROM const --- host-arduino/config.h | 2 +- host-arduino/host-arduino.ino | 8 ++++++-- host-arduino/uvm32.cpp | 2 +- host-arduino/uvm32.h | 2 +- uvm32/uvm32.c | 2 +- uvm32/uvm32.h | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/host-arduino/config.h b/host-arduino/config.h index bb9df17..6f236bd 100644 --- a/host-arduino/config.h +++ b/host-arduino/config.h @@ -1,2 +1,2 @@ // Arduino cannot do -DUVM32_MEMORY_SIZE, so set this explicitly -#define UVM32_MEMORY_SIZE 600 +#define UVM32_MEMORY_SIZE 16*1024 diff --git a/host-arduino/host-arduino.ino b/host-arduino/host-arduino.ino index 1dc7cf4..1399ec8 100644 --- a/host-arduino/host-arduino.ino +++ b/host-arduino/host-arduino.ino @@ -2,7 +2,8 @@ #include "uvm32.h" #include "common/uvm32_common_custom.h" -uint8_t rom[] = { +#if 0 +uint8_t rom[] = { // mandel.bin 0x23, 0x26, 0x11, 0x00, 0xef, 0x00, 0xc0, 0x00, 0xb7, 0x08, 0x00, 0x01, 0x73, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0xff, 0x23, 0x26, 0x81, 0x00, 0x37, 0xf5, 0xff, 0xff, 0xb7, 0x15, 0x00, 0x00, 0x37, 0xe6, 0xff, 0xff, @@ -27,6 +28,9 @@ uint8_t rom[] = { 0x67, 0x80, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x00 }; +#else +#include "zigtris.h" +#endif uvm32_state_t vmst; uvm32_evt_t evt; @@ -49,7 +53,7 @@ void loop(void) { } if (isrunning) { - uvm32_run(&vmst, &evt, 100); // num instructions before vm considered hung + uvm32_run(&vmst, &evt, 10000000); // num instructions before vm considered hung switch(evt.typ) { case UVM32_EVT_END: diff --git a/host-arduino/uvm32.cpp b/host-arduino/uvm32.cpp index 59846fb..dd9097c 100644 --- a/host-arduino/uvm32.cpp +++ b/host-arduino/uvm32.cpp @@ -78,7 +78,7 @@ void uvm32_init(uvm32_state_t *vmst) { vmst->core.extraflags |= 3; // Machine-mode. } -bool uvm32_load(uvm32_state_t *vmst, uint8_t *rom, int len) { +bool uvm32_load(uvm32_state_t *vmst, const uint8_t *rom, int len) { if (len > UVM32_MEMORY_SIZE) { // too big return false; diff --git a/host-arduino/uvm32.h b/host-arduino/uvm32.h index f12afb8..f940949 100644 --- a/host-arduino/uvm32.h +++ b/host-arduino/uvm32.h @@ -72,7 +72,7 @@ typedef struct { } uvm32_state_t; void uvm32_init(uvm32_state_t *vmst); -bool uvm32_load(uvm32_state_t *vmst, uint8_t *rom, int len); +bool uvm32_load(uvm32_state_t *vmst, const uint8_t *rom, int len); bool uvm32_hasEnded(const uvm32_state_t *vmst); uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter); diff --git a/uvm32/uvm32.c b/uvm32/uvm32.c index 6c0f8ab..eee6fc8 100644 --- a/uvm32/uvm32.c +++ b/uvm32/uvm32.c @@ -77,7 +77,7 @@ void uvm32_init(uvm32_state_t *vmst) { vmst->core.extraflags |= 3; // Machine-mode. } -bool uvm32_load(uvm32_state_t *vmst, uint8_t *rom, int len) { +bool uvm32_load(uvm32_state_t *vmst, const uint8_t *rom, int len) { if (len > UVM32_MEMORY_SIZE) { // too big return false; diff --git a/uvm32/uvm32.h b/uvm32/uvm32.h index 3e76d68..a3eec88 100644 --- a/uvm32/uvm32.h +++ b/uvm32/uvm32.h @@ -72,7 +72,7 @@ typedef struct { } uvm32_state_t; void uvm32_init(uvm32_state_t *vmst); -bool uvm32_load(uvm32_state_t *vmst, uint8_t *rom, int len); +bool uvm32_load(uvm32_state_t *vmst, const uint8_t *rom, int len); bool uvm32_hasEnded(const uvm32_state_t *vmst); uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter);