(uxn.c) Catch JCI underflow

This commit is contained in:
neauoire 2023-08-30 09:14:20 -07:00
parent abfeead04c
commit c97d19da99
2 changed files with 3 additions and 4 deletions

View File

@ -15,11 +15,10 @@ rom:
@ ./bin/uxnasm etc/polycat.tal bin/polycat.rom
run: bin/uxnasm bin/uxncli bin/uxn11 rom
@ ./bin/uxn11 bin/polycat.rom
cli: bin/uxnasm bin/uxncli
@ ./bin/uxnasm etc/opctest.tal bin/opctest.rom
@ ./bin/uxncli bin/opctest.rom
test: bin/uxnasm bin/uxncli bin/uxn11
@ ./bin/uxnasm && ./bin/uxncli && ./bin/uxn11 && ./bin/uxnasm -v && ./bin/uxncli -v && ./bin/uxn11 -v
@ ./bin/uxnasm etc/opctest.tal bin/opctest.rom
@ ./bin/uxncli bin/opctest.rom
install: bin/uxnasm bin/uxncli bin/uxn11
@ cp bin/uxn11 bin/uxnasm bin/uxncli ~/bin/
uninstall:

View File

@ -48,7 +48,7 @@ uxn_eval(Uxn *u, Uint16 pc)
switch(ins & 0x1f ? ins & 0x3f : ins << 4) {
/* IMM */
case 0x000: /* BRK */ return 1;
case 0x200: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */
case 0x200: /* JCI */ t=T; SET(0,-1) if(!t) { pc += 2; break; } /* else fallthrough */
case 0x400: /* JMI */ pc += PEEK2(ram + pc) + 2; break;
case 0x600: /* JSI */ SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
case 0x800: /* LIT */ case 0xc00: SET(0, 1) PUT1(ram[pc++]) break;