diff lwasm/main.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 164487152dd9
children 49010c6653e7
line wrap: on
line diff
--- a/lwasm/main.c	Thu Jan 24 21:24:32 2013 -0700
+++ b/lwasm/main.c	Fri Jan 25 21:48:01 2013 -0700
@@ -222,6 +222,7 @@
 extern lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv);
 extern lw_expr_t lwasm_evaluate_var(char *var, void *priv);
 extern lw_expr_t lwasm_parse_term(char **p, void *priv);
+extern void lwasm_dividezero(void *priv);
 
 struct passlist_s
 {
@@ -251,6 +252,7 @@
 	lw_expr_set_special_handler(lwasm_evaluate_special);
 	lw_expr_set_var_handler(lwasm_evaluate_var);
 	lw_expr_set_term_parser(lwasm_parse_term);
+	lw_expr_setdivzero(lwasm_dividezero);
 
 	/* initialize assembler state */
 	asmstate.include_list = lw_stringlist_create();