mirror of
https://gitlab.cs.washington.edu/fidelp/frustration.git
synced 2024-11-16 07:48:10 +01:00
strip trailing whitespace
This commit is contained in:
parent
541eddad68
commit
8dee9a9bbc
2 changed files with 17 additions and 17 deletions
|
@ -46,7 +46,7 @@ Let's lay out a tail-recursive word in memory like this:
|
|||
[ Link field ]
|
||||
[ Name field ]
|
||||
[ --- Start of code field --- ]
|
||||
[ Subroutine call to duplicate the return address ] <--- A
|
||||
[ Subroutine call to duplicate the return address ] <--- A
|
||||
[ Subroutine call to drop the return address ] <--- B
|
||||
|
||||
... Your code goes here ...
|
||||
|
@ -158,7 +158,7 @@ LINE 5 --> : ( loop[ key 41 = ? ret ]loop ; immediate
|
|||
|
||||
: :noname ( -- xt ) here @ [ ' ] , ] ; immediate
|
||||
|
||||
:noname drop rdrop ;
|
||||
:noname drop rdrop ;
|
||||
: stars ( n -- ) loop[ dup 0= ? [ , ] 1 - 42 emit ]loop ;
|
||||
|
||||
( How does the above code work?
|
||||
|
|
|
@ -324,7 +324,7 @@ impl Core {
|
|||
* 102 -> ??? Add the top two values on the data stack.
|
||||
* ...
|
||||
* 200 -> ??? Push the value 3 onto the data stack
|
||||
* 202 -> ??? Push the value 4 onto the data stack
|
||||
* 202 -> ??? Push the value 4 onto the data stack
|
||||
* 204 -> ??? Return to caller
|
||||
*
|
||||
* Don't worry about the other instructions I am using here. I will
|
||||
|
@ -332,7 +332,7 @@ impl Core {
|
|||
*
|
||||
* I mostly want to point out the three instructions that I put
|
||||
* at address 200 because they are a subroutine,
|
||||
* a small self contained piece of code (6 bytes) that
|
||||
* a small self contained piece of code (6 bytes) that
|
||||
* performs a specific task.
|
||||
*
|
||||
* Do you think it's cool that you can count exactly how many bytes it
|
||||
|
@ -723,7 +723,7 @@ const PRIMITIVES: [Primitive; 16] = [
|
|||
* Number Instruction Meaning
|
||||
* ------ ----------- -------
|
||||
* 7 Literal(3) Push the value 3 onto the data stack
|
||||
* 9 Literal(4) Push the value 4 onto the data stack
|
||||
* 9 Literal(4) Push the value 4 onto the data stack
|
||||
* 65504 RET Return to caller
|
||||
*
|
||||
* A linked list is not a very fast data structure but this doesn't really
|
||||
|
@ -881,7 +881,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* Instruction Number Meaning
|
||||
* ----------- ------ -------
|
||||
* Literal(3) 7 Push the value 3 onto the data stack
|
||||
* Literal(4) 9 Push the value 4 onto the data stack
|
||||
* Literal(4) 9 Push the value 4 onto the data stack
|
||||
* RET 65504 Return to caller
|
||||
*
|
||||
* Here is a Forth subroutine consisting of a few subroutine calls strung
|
||||
|
@ -1121,7 +1121,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* ret
|
||||
* is_zero: move r0, 65535
|
||||
* ret
|
||||
*
|
||||
*
|
||||
* It wants to emit a jump to is_zero, but that symbol has not been seen
|
||||
* yet and is unrecognized. On top of that, the assembler also doesn't yet
|
||||
* know what address is_zero will have, so doesn't know what jump target to
|
||||
|
@ -1135,7 +1135,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* constraints, find a way to write 0= within the constraints.
|
||||
*
|
||||
* Here is a start at solving the problem
|
||||
*
|
||||
*
|
||||
* is_nonzero ( -- 0 )
|
||||
* Literal(0)
|
||||
* RET
|
||||
|
@ -1167,7 +1167,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* DRP <-- Discard it
|
||||
* Literal(0) <-- Put 0 on the data stack
|
||||
* RET <-- Return
|
||||
*
|
||||
*
|
||||
* Because we popped off and discarded one item from the return stack, the
|
||||
* final RET instruction will not return to 0= any more. Instead it will
|
||||
* skip one level and return to whoever called 0=. This has the result of
|
||||
|
@ -1179,7 +1179,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* Literal(0)
|
||||
* INV <-- f=65535 is now pushed to stack
|
||||
* RET <-- Return
|
||||
*
|
||||
*
|
||||
* I call this pattern "return-from-caller". It is used occasionally in
|
||||
* real Forth systems. My dialect of Forth will use it extensively to work
|
||||
* around my CPU's lack of conditional jump.
|
||||
|
@ -1426,7 +1426,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* optimization, by manually using the "return-from-caller" trick, RTO DRP,
|
||||
* to "get rid of" the x that is pushed on by the skipws CALL.
|
||||
*
|
||||
* skipws ( -- c ) RTO DRP ... Q RET ... skipws
|
||||
* skipws ( -- c ) RTO DRP ... Q RET ... skipws
|
||||
*
|
||||
* 1st loop: return stack: ( caller ) data stack: ( )
|
||||
* 2nd loop: return stack: ( ) data stack: ( )
|
||||
|
@ -1508,7 +1508,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
RET);
|
||||
|
||||
/* "over" is a good building block for further stack shuffling words. */
|
||||
|
||||
|
||||
// 2dup ( a b -- a b a b )
|
||||
d.entry(); d.name(4, *b"2du"); let twodup = d.here;
|
||||
forth!(over, over, RET);
|
||||
|
@ -1537,7 +1537,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* of instructions also starts at an even numbered address.
|
||||
* You might need to include an extra byte of data as "padding".
|
||||
*
|
||||
* In this case we set aside one byte for length and five bytes for
|
||||
* In this case we set aside one byte for length and five bytes for
|
||||
* characters, which is a total of six bytes, so no padding is needed.
|
||||
*/
|
||||
|
||||
|
@ -1936,7 +1936,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* Our numbers will be base-10. To build up a base-10 number digit by
|
||||
* digit, we'll need to be able to multiply by 10. Our CPU has no multiply
|
||||
* but it does have bit shift, which can be used to multiply or divide an
|
||||
* unsigned value by any power of two.
|
||||
* unsigned value by any power of two.
|
||||
*/
|
||||
|
||||
// x10 ( n -- n*10 )
|
||||
|
@ -2069,7 +2069,7 @@ fn build_dictionary(c: &mut Core) {
|
|||
* Forth names this "quit", for the reason that calling "quit" in
|
||||
* the middle of a compiled program is a reasonable way to bring
|
||||
* you back to top-level.
|
||||
*
|
||||
*
|
||||
* "quit" is called the "outer interpreter" because it is the outermost
|
||||
* interpreter loop that Forth uses. Some Forth implementations also
|
||||
* use an "inner interpreter" to execute their threaded code. Our Forth
|
||||
|
@ -2230,7 +2230,7 @@ fn main() {
|
|||
* This is an important, and dangerous, diversion. For it's
|
||||
* easy to lose sight of the problem amidst the beauty of the
|
||||
* solution."
|
||||
*
|
||||
*
|
||||
* -- Chuck Moore, "Programming a Problem-Oriented Language", 1970
|
||||
*/
|
||||
|
||||
|
@ -2255,7 +2255,7 @@ fn main() {
|
|||
* There is a shell script supplied that will do all of the above for you.
|
||||
*
|
||||
* bash build.sh
|
||||
*
|
||||
*
|
||||
* Please read frustration.4th if you want to learn more about how to
|
||||
* use Forth.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue