diff --git a/vweb/4th/prelude.f b/vweb/4th/prelude.f index 50e55b4..d4b8c60 100644 --- a/vweb/4th/prelude.f +++ b/vweb/4th/prelude.f @@ -2,11 +2,11 @@ : then resolve ; immediate : else r> $ jmpr >asm >r resolve ; immediate : variable create 0 , does> ; -: arshift $ arshift asm ; +: arshift [ $ arshift asm ] ; : lshift [ $ lshift asm ] ; : rshift [ $ rshift asm ] ; -: u> [ $ gt ] asm ; -: u< [ $ lt ] asm ; +: u> [ $ gt asm ] ; +: u< [ $ lt asm ] ; : rdrop r> pop ; : over 1 pick ; : nip swap pop ; @@ -23,3 +23,5 @@ : ror dup 1 rshift swap 23 lshift | ; : rol dup 23 rshift swap 1 lshift | ; : abs dup 0 < if negate then ; +: begin here >r ; immediate +: until r> here - $ brz #asm ; immediate \ No newline at end of file diff --git a/vweb/src/app.css b/vweb/src/app.css index af24972..00a84b5 100644 --- a/vweb/src/app.css +++ b/vweb/src/app.css @@ -31,4 +31,5 @@ td.word, td.signature { font-family: monospace; font-weight: bold; padding-right: 1em; + white-space: nowrap; } diff --git a/vweb/src/index.html b/vweb/src/index.html index 6d4348e..d39dbfc 100644 --- a/vweb/src/index.html +++ b/vweb/src/index.html @@ -55,6 +55,11 @@ that number plus one; if it's even, it returns half that number. The ".s" word prints the stack without modifying it and is a useful debugging tool.
++
: countdown begin dup . ." ... " 1 - dup not until pop ; +10 countdown+ Demonstrating a loop, this program counts from its argument down to 1. +
| not | a -- b | If the argument is a 0, returns 1. Otherwise returns 0 |
| compare | a b -- c | Compares two strings for equality, returns 1 if they're equal and 0 otherwise |
| if / else / then | cond -- | A conditional branch: "condition if truepath else falsepath then". The "else" branch is optional (prelude words) |
| begin / until | cond -- | A post-test loop: "until" jumps back to the corresponding "begin" as long as top of stack is 0 (prelude words) |