diff lwasm/lwasm.c @ 249:1f1a28b797e1

Add trap for divide by zero in expression library Added a trap for division by zero in the expression library and adjusted lwasm to use it and report division by zero errors instead of crashing with a cryptic "arithmetic exception" or even more mysterious "floating point exception".
author William Astle <lost@l-w.ca>
date Fri, 25 Jan 2013 21:48:01 -0700
parents d0e9dbe9afbe
children bc25269d96bc
line wrap: on
line diff
--- a/lwasm/lwasm.c	Thu Jan 24 21:24:32 2013 -0700
+++ b/lwasm/lwasm.c	Fri Jan 25 21:48:01 2013 -0700
@@ -44,6 +44,12 @@
 	return 0;
 }
 
+void lwasm_dividezero(void *priv)
+{
+	asmstate_t *as = (asmstate_t *)priv;
+	lwasm_register_error(as, as -> cl, "Division by zero");
+}
+
 lw_expr_t lwasm_evaluate_var(char *var, void *priv)
 {
 	asmstate_t *as = (asmstate_t *)priv;