(uxn.c) Catch div-by-zero errors

This commit is contained in:
Devine Lu Linvega 2023-04-15 09:52:08 -07:00
parent 14b704fd01
commit 32fa0f95c3
2 changed files with 4 additions and 4 deletions

View File

@ -4,10 +4,10 @@
;on-halt .System/vector DEO2
( divzero ) #02 #00 DIV
( underflow ) POP
( overflow ) #00 &l #ffff ROT INC DUP ?&l POP
( divzero ) #02 #00 DIV
#80 .System/halt DEO
BRK

View File

@ -111,8 +111,8 @@ uxn_eval(Uxn *u, Uint16 pc)
case 0x39: t=T2;n=N2; SET(4,-2) PUT2(0, n - t) break;
case 0x1a: /* MUL */ t=T;n=N; SET(2,-1) PUT(0, n * t) break;
case 0x3a: t=T2;n=N2; SET(4,-2) PUT2(0, n * t) break;
case 0x1b: /* DIV */ t=T;n=N; SET(2,-1) PUT(0, n / t) break;
case 0x3b: t=T2;n=N2; SET(4,-2) PUT2(0, n / t) break;
case 0x1b: /* DIV */ t=T;n=N; SET(2,-1) if(!t) HALT(3) PUT(0, n / t) break;
case 0x3b: t=T2;n=N2; SET(4,-2) if(!t) HALT(3) PUT2(0, n / t) break;
case 0x1c: /* AND */ t=T;n=N; SET(2,-1) PUT(0, n & t) break;
case 0x3c: t=T2;n=N2; SET(4,-2) PUT2(0, n & t) break;
case 0x1d: /* ORA */ t=T;n=N; SET(2,-1) PUT(0, n | t) break;