Re: Why is PAD 68 bytes above the DP?
Posted: Mon Jan 24, 2022 2:59 pm
[ Oops, another post while I've been busy typing. Might as well share this anyway... ]
Yes, that's correct. In FIG Forth (a 16-bit Forth), a literal that's a double number (32 bits) it is compiled as two separate 16-bit literals.
Referring to SCR # 52 of the FIG source code (found in the widely available Installation Manual), we see INTERPRET is the loop to "interpret or compile source text input words." If the word/string can't be recognized by -FIND then it's assumed to be some sort of number, and is evaluated by NUMBER which always returns a double precision result (two 16-bit halves, one stack cell each).
As Garth said, the presence or absence of a decimal point makes a difference to what gets compiled. With no decimal point, the most significant cell returned by NUMBER is DROPped, and what's complied to the dictionary is LITERAL followed by the least-significant half of the number.
But if a decimal point was present, INTERPRET compiles...
IamRob wrote:
My biggest confusion, and I think everyone elses as well, is that a double number is not compiled all at once. It is compiled as two separate 16-bit numbers.
Referring to SCR # 52 of the FIG source code (found in the widely available Installation Manual), we see INTERPRET is the loop to "interpret or compile source text input words." If the word/string can't be recognized by -FIND then it's assumed to be some sort of number, and is evaluated by NUMBER which always returns a double precision result (two 16-bit halves, one stack cell each).
As Garth said, the presence or absence of a decimal point makes a difference to what gets compiled. With no decimal point, the most significant cell returned by NUMBER is DROPped, and what's complied to the dictionary is LITERAL followed by the least-significant half of the number.
But if a decimal point was present, INTERPRET compiles...
- LITERAL followed by the least-significant half of the number, then
LITERAL followed by the most-significant half of the number.