Looks like these 2 words are missing in ficl. Maybe there are other useful
words to convert integers to floats and vice-versa?
I need the conversion, so I've implemented a first hack:
static void ficlPrimitiveD2F(ficlVm *vm)
{
ficlInteger doubleLow;
ficlStackPopInteger(vm->dataStack); // ignore double high
doubleLow = ficlStackPopInteger(vm->dataStack);
ficlStackPushFloat(vm->floatStack, (float) doubleLow);
}
static void ficlPrimitiveF2D(ficlVm *vm)
{
float f = ficlStackPopFloat(vm->floatStack);
ficlInteger doubleLow = (ficlInteger) f;
ficlInteger doubleHigh = doubleLow < 0 ? -1 : 0;
ficlStackPu****nteger(vm->dataStack, doubleLow);
ficlStackPu****nteger(vm->dataStack, doubleHigh);
}
and the registering part:
ficlDictionarySetPrimitive(dictionary, "d>f", ficlPrimitiveD2F,
FICL_WORD_DEFAULT);
ficlDictionarySetPrimitive(dictionary, "f>d", ficlPrimitiveF2D,
FICL_WORD_DEFAULT);
But this doesn't work. Looks like ficl saves a double in low/high format.
This is the output of Win32Forth:
12. . .
0 12
and this on ficl (compiled on an ARM platform) :
12. . .
12 0
Which one is the right one? I don't understand what the word "above" means
in "3.1.4.1 Double-cell integers".
For me it looks better to push the high value as the last item on stack,
because then I can just drop it, if not needed, instead of "swap drop", so
I've changed the ficl parsing function, now my d>f and f>d words are
working as expected, e.g. like this:
12. d>f -6. d>f f/ f>d drop .
-2
But the other double words are not working any more. Is there a better
Forth system for ARM9 plaforms, maybe compiled instead of interpreted?
Currently it runs in a WindowsCE environment and I need to interface to
lots of C functions for driver accessing. Later it is possible that it
should work with "Net+OS" ( http://www.digi.com/pdf/fs_netos7.pdf
), too,
which has lots of C functions, too.
--
Frank Buss, fb@[EMAIL PROTECTED]
http://www.it4-systems.de


|