|
4 | 4 | \ This is PUBLIC DOMAIN (see public domain release statement below). |
5 | 5 | \ $Id: jonesforth.f,v 1.18 2009-09-11 08:32:33 rich Exp $ |
6 | 6 | \ |
7 | | -\ The first part of this tutorial is in jonesforth.S. Get if from http://annexia.org/forth |
| 7 | +\ The first part of this tutorial is in jonesforth.S. Get it from http://annexia.org/forth |
8 | 8 | \ |
9 | 9 | \ PUBLIC DOMAIN ---------------------------------------------------------------------- |
10 | 10 | \ |
|
82 | 82 | [ \ go into immediate mode (temporarily) |
83 | 83 | CHAR : \ push the number 58 (ASCII code of colon) on the parameter stack |
84 | 84 | ] \ go back to compile mode |
85 | | - LITERAL \ compile LIT 58 as the definition of ':' word |
| 85 | + LITERAL \ compile LIT 58 for the definition of the ':' word |
86 | 86 | ; |
87 | 87 |
|
88 | 88 | \ A few more character constants defined the same way as above. |
|
106 | 106 | \ RECURSE makes a recursive call to the current word that is being compiled. |
107 | 107 | \ |
108 | 108 | \ Normally while a word is being compiled, it is marked HIDDEN so that references to the |
109 | | -\ same word within are calls to the previous definition of the word. However we still have |
110 | | -\ access to the word which we are currently compiling through the LATEST pointer so we |
111 | | -\ can use that to compile a recursive call. |
| 109 | +\ same word within the definition are calls to the previous definition of the word. However we |
| 110 | +\ still have access to the word which we are currently compiling through the LATEST pointer |
| 111 | +\ so we can use that to compile a recursive call. |
112 | 112 | : RECURSE IMMEDIATE |
113 | 113 | LATEST @ \ LATEST points to the word being compiled at the moment |
114 | 114 | >CFA \ get the codeword |
|
130 | 130 | \ where OFFSET is the offset of 'rest' |
131 | 131 | \ condition IF true-part ELSE false-part THEN |
132 | 132 | \ -- compiles to: --> condition 0BRANCH OFFSET true-part BRANCH OFFSET2 false-part rest |
133 | | -\ where OFFSET if the offset of false-part and OFFSET2 is the offset of rest |
| 133 | +\ where OFFSET is the offset of false-part and OFFSET2 is the offset of rest |
134 | 134 |
|
135 | 135 | \ IF is an IMMEDIATE word which compiles 0BRANCH followed by a dummy offset, and places |
136 | 136 | \ the address of the 0BRANCH on the stack. Later when we see THEN, we pop that address |
|
148 | 148 | ; |
149 | 149 |
|
150 | 150 | : ELSE IMMEDIATE |
151 | | - ' BRANCH , \ definite branch to just over the false-part |
| 151 | + ' BRANCH , \ unconditional branch to just over the false-part |
152 | 152 | HERE @ \ save location of the offset on the stack |
153 | 153 | 0 , \ compile a dummy offset |
154 | 154 | SWAP \ now back-fill the original (IF) offset |
|
218 | 218 | \ FORTH allows ( ... ) as comments within function definitions. This works by having an IMMEDIATE |
219 | 219 | \ word called ( which just drops input characters until it hits the corresponding ). |
220 | 220 | : ( IMMEDIATE |
221 | | - 1 \ allowed nested parens by keeping track of depth |
| 221 | + 1 \ allows nested parens by keeping track of depth |
222 | 222 | BEGIN |
223 | 223 | KEY \ read next character |
224 | 224 | DUP '(' = IF \ open paren? |
@@ -288,7 +288,7 @@ \ FORTH allows ( ... ) as comments within function definitions. This works by h |
288 | 288 | will print out these characters: |
289 | 289 | <space> <space> - 1 2 3 |
290 | 290 |
|
291 | | - In other words, the number padded left to a certain number of characters. |
| 291 | + In other words, the number padded on the left to a certain number of characters. |
292 | 292 |
|
293 | 293 | The full number is printed even if it is wider than width, and this is what allows us to |
294 | 294 | define the ordinary functions U. and . (we just set width to zero knowing that the full |
@@ -1393,7 +1393,7 @@ EXCEPTION-MARKER, namely a function that just drops the stack frame and itself |
1393 | 1393 | To make it more like a C string, at runtime Z" just leaves the address of the string |
1394 | 1394 | on the stack (not address & length as with S"). To implement this we need to add the |
1395 | 1395 | extra NUL to the string and also a DROP instruction afterwards. Apart from that the |
1396 | | - implementation just a modified S". |
| 1396 | + implementation is just a modified S". |
1397 | 1397 | ) |
1398 | 1398 | : Z" IMMEDIATE |
1399 | 1399 | STATE @ IF ( compiling? ) |
@@ -1520,7 +1520,7 @@ EXCEPTION-MARKER, namely a function that just drops the stack frame and itself |
1520 | 1520 | ( |
1521 | 1521 | UNUSED returns the number of cells remaining in the user memory (data segment). |
1522 | 1522 |
|
1523 | | - For our implementation we will use Linux brk(2) system call to find out the end |
| 1523 | + For our implementation we will use the Linux brk(2) system call to find out the end |
1524 | 1524 | of the data segment and subtract HERE from it. |
1525 | 1525 | ) |
1526 | 1526 | : GET-BRK ( -- brkpoint ) |
@@ -1738,7 +1738,7 @@ EXCEPTION-MARKER, namely a function that just drops the stack frame and itself |
1738 | 1738 | ; |
1739 | 1739 | DECIMAL |
1740 | 1740 |
|
1741 | | -( (INLINE) is the lowlevel inline function. ) |
| 1741 | +( (INLINE) is the low-level inline function. ) |
1742 | 1742 | : (INLINE) ( cfa -- ) |
1743 | 1743 | @ ( remember codeword points to the code ) |
1744 | 1744 | BEGIN ( copy bytes until we hit NEXT macro ) |
|
0 commit comments