Joined: Fri Aug 30, 2002 1:09 am Posts: 8520 Location: Southern California
|
Yes; the 71 puts floating-point numbers on a separate HP-41-style floating-point stack. The Forth word ITOF ( n -- ) (integer to floating-point) converts n into a floating-point number and puts it in the X register, lifting the floating-point stack. FTOI ( -- n ) (floating-point to integer) converts the contents of the X register to an integer and puts it on the regular Forth data stack. If |x|>$FFFFF, an overflow error condition occurs. FTOI takes the absolute value of X, rounds it to the nearest integer, and converts it to a five-nybble value. If X was positive, FTOI returns this result. If X was negative, FTOI returns the twos complement of this result.
The 71's Forth's floating-point included function set includes: 1/X 10^X ACOS ASIN ATAN CHS COS E^X F* F+ F- F/ FABS FP (ie, fractional part) IP (ie, integer part) ITOF LGT (log, base ten) LN (log, natural) SIN SQRT TAN X^2 and Y^X.
In the input stream, FP numbers are identified by the presence of a decimal point. If you want a double-precision integer instead, use , or : or / . If NUMBER sees the decimal point, it passes the sequence to the routine used by BASIC's keyword VAL (value) for evaluation. FP numbers are stored the same way the 71's BASIC does it, adhering to the IEEE floating-point standard, with a 12-digit mantissa and 3-digit exponent, also able to indicate "infinite" (which may be positive or negative) or NaN ("not a number"). Since the BASIC OS already has the routines to handle the floating-point operations, the Forth module uses those rather than repeating them.
I should mention that there were two different Forth modules I'm aware of. I have not studied the differences. I have the HP82441A Forth/Assembler module.
Since this is a 6502 forum and topics should have at least some application to the 65xx's, I'll comment that a separate floating-point stack can of course be implemented on these. I think it makes more sense than trying to put FP numbers on the standard data stack. Since the (ZP,X) addressing mode is not needed in a floating-point stack, this third stack could be in non-ZP memory. There would only be a small penalty in efficiency, not function. The 71 uses 16 nibbles (8 bytes) for each number. Having X, Y, Z, T, and L then means 40 bytes. If you don't need to stick to the IEEE floating-point standard, you could go with less.
The HP-41's Forth, although now rather well documented thanks to Ángel Martin's very clear MCode guide done in Apr 2014, is not something I have looked into much. The 41's architecture, memory size (for holding source-code files), and the slowness and limitations of its text editor (which is only available on the 41cx which I have, and not on the 41c or 41cv), make it, IMO, not a serious platform for Forth. I still use my 41cx nearly every day (and you can see the wide array of modules and accessories I have for it), but I'm not very interested in pursuing Forth on it. Having a 65xx workbench computer in smallish, hand-held, portable package however is a different matter, and you can see how the 41 and 71 inspired my early efforts of such a workbench computer at http://wilsonminesco.com/BenchCPU/ .
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
|
|