Make yield a regular syscall taking an argument.

Allows "wait for interrupt"/"wait for event" type operation where VM code blocks until the host has something for it.
This commit is contained in:
Toby Jaffey 2025-12-10 10:35:18 +00:00
parent d52baca7b2
commit e07eeab043
14 changed files with 88 additions and 24 deletions

View file

@ -13,13 +13,6 @@ void movecursor(int x, int y) {
print("f");
}
void sleep(uint32_t ms) {
uint32_t start = millis();
while (millis() < start + ms) {
yield();
}
}
// Absolute value function for doubles
double abs_c(double x) {
if (x < 0) {
@ -116,7 +109,7 @@ void main(void) {
// wait for next frame
while (millis() < framestart + (1000 / 30)) {
yield();
yield(0);
}
beta += 0.05;
freq1 += 0.01;

View file

@ -45,6 +45,8 @@ void main(void) {
break;
case UVM32_EVT_SYSCALL: // vm has paused to handle UVM32_SYSCALL
switch(evt.data.syscall.code) {
case UVM32_SYSCALL_YIELD:
break;
case UVM32_SYSCALL_PUTC:
putc(uvm32_getval(&vmst, &evt, ARG0));
break;

View file

@ -25,7 +25,7 @@ void setup(void) {
void main(void) {
setup();
while(loop()) {
yield();
yield(0);
}
}