From 4de3bd5c0c325a22cfbe4db2db358f8b2d602c48 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Mon, 2 Jan 2023 14:27:00 -0600 Subject: [PATCH] Fixed a couple prelude bugs --- vweb/4th/prelude.f | 8 +++++--- vweb/src/app.css | 1 + vweb/src/index.html | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) 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. +

NovaForth Dictionary

Arithmetic and stack juggling

@@ -128,6 +133,7 @@ +
nota -- bIf the argument is a 0, returns 1. Otherwise returns 0
comparea b -- cCompares two strings for equality, returns 1 if they're equal and 0 otherwise
if / else / thencond --A conditional branch: "condition if truepath else falsepath then". The "else" branch is optional (prelude words)
begin / untilcond --A post-test loop: "until" jumps back to the corresponding "begin" as long as top of stack is 0 (prelude words)

Memory management