diff -up gforth-0.7.0/engine/support.c.orig gforth-0.7.0/engine/support.c
--- gforth-0.7.0/engine/support.c.orig 2008-11-01 23:06:35.000000000 +0100
+++ gforth-0.7.0/engine/support.c 2011-03-21 14:53:52.000000000 +0100
@@ -724,16 +724,21 @@ DCell smdiv (DCell num, Cell denom)
DCell res;
#if defined(sdiv_qrnnd)
/* #warning "using sdiv_qrnnd" */
- Cell u1,q,r
+ Cell u1,q,r;
UCell u0;
UCell MAYBE_UNUSED lz;
- vm_d2twoCell(u,u0,u1);
- if (v==0)
+ vm_d2twoCell(num,u0,u1);
+ if (denom==0)
throw(BALL_DIVZERO);
- if (u1>=v)
- throw(BALL_RESULTRANGE);
- sdiv_qrnnd(q,r,u1,u0,v);
+ sdiv_qrnnd(q,r,u1,u0,denom);
+ if ((u1^denom)<0) {
+ if (q>0)
+ throw(BALL_RESULTRANGE);
+ } else {
+ if (q<0)
+ throw(BALL_RESULTRANGE);
+ }
vm_twoCell2d(q,r,res);
#else
UDCell ures;