\ This file:
\   https://anggtwu.net/UXN/1.f.html
\   https://anggtwu.net/UXN/1.f
\           (find-angg "UXN/1.f")
\  Author: Eduardo Ochs <eduardoochs@gmail.com>
\ Version: 2026aug30
\
\ See: (find-angg "elisp/2026-uf9.el")
\ Use: (setq last-kbd-macro (kbd "M-9 M-e"))
\
\ «.base»		(to "base")
\ «.begin-while-repeat»	(to "begin-while-repeat")
\ «.marker»		(to "marker")
\ «.prevword»		(to "prevword")
\ «.rfind»		(to "rfind")
\ «.see»		(to "see")
\ «.variable»		(to "variable")



\ «base»  (to ".base")
\ (find-uf9-g "decimal")
\ (find-uf9-g "hex")
\ (find-uf9-g "base")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)
decimal 100 hex .       \ 64
    hex 100 decimal .   \ 256

decimal base @ 1 - .    \ 9
    hex base @ 1 - .    \ f

\ Typo: (find-uf9file "GLOSSARY" "base        ( a -- )")




\ «begin-while-repeat»  (to ".begin-while-repeat")
\ (find-uf9-g "begin")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)

variable foo   4 foo !
: foo-- ( -- x ) foo @ dup 1 - foo ! ;
foo @ .
foo-- .
foo-- .
foo-- .
foo-- .

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)

variable foo
: foo.    foo @ . ;
: foodecr foo @ 1 - foo ! ;
: footest begin foo @ while foo. foodecr repeat ;
4 foo !
  footest   \ 4 3 2 1
  foo.      \ 0



\ «marker»  (to ".marker")
\ (find-uf9-f "marker")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)
words
marker aabbcc
words
: aa ;
: bb ;
: cc ;
words
aabbcc
words




\ «prevword»  (to ".prevword")
\ Based on: (find-uf9-f "words")
\      See: (find-uf9-f "rfind" "skipname")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)

: lastword ( -- addr )      vocs 0 th @ @ ;
: prevword ( addr -- addr ) count significant + @ ;
: .word    ( addr -- )      count significant type ;

: square   ( x -- x^2 )     dup * ;
: cube     ( x -- x^3 )     dup square * ;

lastword                                     .word
lastword prevword                            .word
lastword prevword prevword                   .word
lastword prevword prevword prevword          .word
lastword prevword prevword prevword prevword .word

lastword                                     16 dump
lastword prevword                            16 dump
lastword prevword prevword                   16 dump
lastword prevword prevword prevword          16 dump
lastword prevword prevword prevword prevword 16 dump



\ «rfind»  (to ".rfind")
\ (find-uf9-f "rfind")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)
: square dup * ;
: cube dup square * ;

' cube rfind . 16 dump
' cube rfind . count type




\ «see»  (to ".see")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)
: square dup * ;
: cube dup square * ;
5 cube .

see square
see cube

\ (find-uf9-k ":")
\ (find-uf9-k ";")
\ (find-uf9-f "dup")
\ (find-uf9-f "*")
\ (find-uf9-f "see")
\ (find-uf9-f "words")
\ (find-uf9-f "th")
\ (find-uf9-f "space")










\ «variable»  (to ".variable")
\ (find-uf9-g "variable")
\ (find-uf9-f "variable")
\ (find-uf9-k "(variable)")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)

variable foo
42 foo !
   foo @ .







 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)

: foobar s" Foo bar" ;
  foobar type
  foobar 1 - .



 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)
2 3 4 5 .s   \ 2 3 4 5
    nip .s   \ 2 3 5
   tuck .s   \ 2 5 3 5
  clear .s   \ stack empty

clear 20 30 40 50 0 pick .  \ 50
clear 20 30 40 50 1 pick .  \ 40
clear 20 30 40 50 2 pick .  \ 30










\ (find-uf9-g "begin")
\ (find-uf9-g "while")
\ (find-uf9-g "repeat")

.vocs





: vocword  ( addr -- addr ) count significant 2dup type space  + @ ;
: vocwords ( addr -- ) begin ?dup while vocword  repeat ;

vocs 0 th @ @  vocword vocword vocword
vocs 0 th @ @  vocwords
vocs 1 th @ @  vocwords
vocs 2 th @ @  vocwords
vocs 3 th @ @  vocwords



95: 回复: b


: vocwords ( addr -- ) begin ?dup while vocword  repeat ;









space .

vocs 1 th @ @ 16 dump
vocs 2 th @ @ 16 dump
vocs 3 th @ @ 16 dump


\ (find-uf9file "kernel.tal" "( `:` -")
\ (find-uf9file "kernel.tal" "( `;` -")
\ (find-uf9file "uf.f" "\\ `dup` ")
\ (find-uf9file "uf.f" "\\ `*` ")
\ (find-uf9file "uf.f" "\\ `see` ")
\ (find-uf9file "uf.f" "\\ `bl` ")
\ (find-uf9file "kernel.tal" "( `word` -")


\ (find-uf9-links                "loop")
\ (find-uf9-links               "(loop)")
\ (find-uf9file "uf.f"         ": loop ")
\ (find-uf9file "uf.f"        ": +loop ")
\ (find-uf9file "GLOSSARY"    "\n+loop ")
\ (find-uf9file "GLOSSARY"     "\nloop ")
\ (find-uf9file "kernel.tal" "( `(loop)` -")

 (eepitch-uf9)
 (eepitch-kill)
 (eepitch-uf9)

: test do i . 2 +loop ;
 9 5 test   \ 5 7
10 5 test   \ 5 7 9
 5 9 test   \ 9

: test do i . -2 +loop ;
 9 5 test   \ 5 3 1
10 5 test   \ 5 3 1
 5 9 test   \ 9






see square
see cube



\ (find-uf9-links                "dup")
\ (find-uf9-links                ":")

\ (find-uf9file "kernel.tal" "( `dup` -")


\ (find-uf9file "uf.f" "`*`" "compiles to MUL2")


\ (find-uf9-links                "dup")
\ (find-uf9-links                ":")
\ (find-uf9-links               "(loop)")







\ Local Variables:
\ coding:  utf-8-unix
\ mode: forth
\ End:
