text
stringlengths 0
99.6k
|
|---|
Page 259
|
To use TEST in the way Brodie describes, it is important to remember that the '83 tick returns the code field address, and not the address of the paramter field. Just remember to use >BODY to do stuff like this, and you'll be fine. I.E.:
|
' TEST >BODY 3 + 7 TYPE
|
where
|
' TEST
|
gives the CFA (compilation address) of TEST
|
>BODY
|
converts this address to the PFA (address of parameter field), and the rest works as described by Brodie.
|
Note that the same remark applies to the definition of LABEL . In '83 Forth, LABEL would be:
|
: LABEL 8 * ['] "LABEL" >BODY 3 + + 8 TYPE SPACE ;
|
Note the addition of >BODY to convert the compilation address (CFA) to the address of the parameter field.
|
Internal String Operators
|
Page 266
|
MOVE is not part of the '83 standard. It is included in the Uncontrolled Reference Word set, and in Blazin' Forth, but its definition is different from that given by Brodie. Essentially, MOVE is just a smart CMOVE. It examines the addresses, and then picks CMOVE or CMOVE> as appropriate. This prevents accidentally overwriting data, and is in general one less worry for the hacker.
|
<CMOVE has been renamed CMOVE> in '83. (The idea is to emphasize function, instead of how its done. CMOVE> is usually used to slide strings towards high memory, as Brodie explains. That's why the upward pointing bracket.)
|
*fp0
|
Single-Character Input
|
Page 268
|
Following is from the Forth-83 standard:
|
"...characters received by KEY will not be displayed." Other than this, KEY behaves as described. To duplicate the behaviour of the KEY described by Brodie use the phrase:
|
KEY DUP EMIT
|
You might also examine the systems ?KEY routine, which works like KEY , but doesn't wait for the user to type a key.
|
Page 270
|
'83 systems return the ASCII code for every key pressed, including the return key. So the definition of BLOCKS in '83 Forth is:
|
: BLOCKS ( count --- )
|
SCR @ + SCR @ DO I LIST
|
KEY 13 = ( CR) IF LEAVE THEN LOOP ;
|
You can also use Blazin' Forths ?LEAVE :
|
: BLOCKS ( count --- )
|
SCR @ + SCR @ DO I LIST
|
KEY 13 = ( CR) ?LEAVE LOOP ;
|
String Input Commands, from the Bottom up
|
page 270
|
The definition for text is almost the same as Blazin' Forths TEXT. Blazin' Forth's TEXT follows the recommendation of the '83 standard team, and stores the count in the first byte of the string, as does WORD. Otherwise, works the same as described.
|
Page 271
|
The example
|
S0 @ 80 EXPECT
|
would be
|
TIB 80 EXPECT
|
in Forth-83 systems.
|
Note also that the '83 EXPECT does not store a null at the end of the string. This is one of the major improvements of the '83 standard. '83 standard systems use a count, instead of a delimiter, to determine the end of the input stream. '83 EXPECT stores the count of the characters received in the variable SPAN . More on this later.
|
Page 275
|
As you might discover, the FORM LOVE LETTER does not work as described. Certain names will tend to change the text colors, or do other odd things to the display. For example, using:
|
VITALS BJ,BLUE,FRED
|
the program will appear to work just fine. But using
|
VITALS VIOLA,BLUE,FRED
|
will cause a problem - the text will change white when printing the word VIOLA. Clearly, VIOLA causes a problem, while BJ does not. Why is this?
|
It has to do with the fact that '83 TEXT stores a count byte in the first byte of PAD. So when you execute the phrase
|
NAME 14 -TRAILING TYPE
|
You are TYPEing extra characters. In the case of BJ, you will be typing a ASCII 2, an ASCII B and an ASCII J. On the CBM-64, ASCII 2 is a do-nothing character - doesn't do anything at all. So the program appears to work fine. On the other hand, when NAME contains VIOLA (or any other 5 character name), you will be TYPING an ASCII 5, which is the character to EMIT if you want to change the character color to white.
|
There are two solutions to this problem. One is to change the definition of VITALS to the following:
|
: VITALS // modification 1
|
ASCII , TEXT ( 44) PAD 1+ NAME 14 MOVE
|
ASCII , TEXT PAD 1+ EYES 12 MOVE
|
1 TEXT PAD 1+ ME 14 MOVE ;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.