ion Diskette and Press RETURN : `:T^ۄ Writing : hܠ/r ;h|۠D;; D;   ;DDh ݠ   +ۄCopy complete: D Recor 8 "manual_index:e" SEQ ---> Index to Forth manuals 38 "intro:e" SEQ --\ 62 "manual1:e" SEQ \ 57 "manual2:e" SEQ \ 37 "manual3:e" SEQ \ 23 "manual4:e" SEQ \ 41 "manual5:e" SEQ f Utilities/Tools Source 62 "decompiler:fo" REL ---> Forth Disk Smart Decompiler Source 84 "full-forth" PRG ---> Forth with utilities for Thinkjet 'IEEE4' 82 "full-forthp" PRG ---> Forth with utilities for generic 'PRINTER' 84 "initds copied*, xG@maxCHtrunc!i eof_flag@) filename}posB firstrecCeofflag%dummy lastBtrace strore!xut contmin foro"h; ,ݠ 6@;Jڄ/Insert Destinat  > The FORTH Manual 29 "manual6:e" SEQ / 92 "manual7:e" SEQ / 27 "manual8:e" SEQ / 39 "manual9:e" SEQ / 35 "manual10:e" SEQ --/ 78 "gloss1:e" SEQ --\ 76 "gloss2:e" S-forth" PRG ---> Forth initialization application 4 "copy_disk:b" PRG ---> mBASIC program to copy relative files tools loaded 22 "system:fo" REL ---> Forth Disk with only error messages 412 "config:fo" REL ---> Forth Disk o EQ > Glossary of all Forth words 84 "gloss3:e" SEQ --/ 36 "forth" PRG ---> Base Forth system with no tools loaded 22 "system:fo" REL ---> Forth Disk with only error messages 412 "config:fo" REL ---> Forth Disk o 95 k CnB k lCZ k M0>$ k MA& k M.A )  L9 )(!identify (9i " L9 *π immediate (! checktype y(9""  k @^@g JG J2 @^@ JU JAU Jp J2 @^@g J(! setup-scr (9,SuperPET SuperFORTH EDITORiScreen #iiLINE 0iUvi iiBUFFER:,((!setdisp(9J L ,Pj  , v*  U \(!ldownj(9 ,Pj Ð@q(!lup(9 ,Pj @q(!lcopy(9Pj  Pj  @q(!ldel(9 ,  v2  0 (!lins*(9  $(9U00  k ψU0(! endfsedit l(9B ) (!runit(9, B+> (!doedit(9 ؑL   υk u k τk E k χk Yz k .gU k sU k@@push^( nextw( jump( mode(idxreg(9T(!n,r(9((*  K U9$ K ψ^ωg9(![n,r](9((* K Ϙ^ϙg9(!,*(9( (*U9(!ns++]V(ݑ`,-se(ݑ`a,st(ݑ`b,s(ݑ`d,s(ݑ`,s+(ݑ`[a,s](ݑ`[b,s](ݑ`[d,s](ݑ`n,u(ݐ@,u(ݑ`,--u(ݑ`,u++(ݑ`[n,u](ݑ&@[,u] (ݑ`[,--u](ݑ`[,u++]&(ݑ`,-u5(ݑ`a,uD(ݑ`b,uP(ݑ!idi2H(9((*Q ) p[$ ^k  gkL9(!idi,c(9( ^k  gkL9(!idi1(9((*Q(!idil(9(( *2*Q(!neg,(ݕ^com,5(ݕ^lsr,B(ݕ^rorda,K(ݗ bita,Y(ݗ lda,g(ݗ sta,u(ݗ eora,(ݗ adca,(ݗ ora,(ݗ adda,(ݗ cmpx,(ݖsjsr,(ݖsldx,(ݖsstx,(ݖssubb,(ݗ cmpb,(ݗ sbcb, (ݗ addd,(ݗ andb,%(ݗ bitb,3(ݗ ldb,A(ݗexg,J(ݕtfr,X(ݕswi2,e(9?(!swi3,r(9?(!ccod(9((*p(!-cc(ݜ$cs(ݜ%hi(ݜ"ls(ݜ#hs(ݜ$lo(ݜ%ne(ݜ&eq(ݜ'vc(ݜ(vs(ݜ)pl(ݜ*mi(ݜ+ge((ݜ,lt3(ݜ-gt>(ݜ.    '(ۄNOTE:  records may be read&2< F  PZd n x'„Enter name of file to copy : /&/(f:128)/,REL D 6ȇڄ*Ins  secondaryU  k constantLj k variableLG k userL($ k L primaryL(!pass1(9 ؒ9C)>i. { ؒ9 { CVÑ:9(J(!tightd(9(oo!o o(!loose(9 ooo  o(!pos-curs (9@   p0(!homeit(9UU0(!cright(92(!cleft(9T(!cdown%(9@(!cup<(9@(!chomeR(9 L( , vT C* ,0 (!copyfrom d(9 ^0 ` Lv @qP @  (!copyto(9 `Lv @q@ P  (!recover(9B(!+scr*(9BUB[B(!-scr?(9BT  B k 0/ k p k s ^ k  k 5 k \ k ϊ k lϋ k Gρ k ς k 2uσ k bω k eO,xL(ݐ,xj(ݑ`_,--xv(ݑ`,x++(ݑ`[n,x](ݑ&[,x](ݑ`[,--x](ݑ`[,x++](ݑ`,-x(ݑ`a,x(ݑ`b,x(ݑ`d,x(ݑ`,x+(ݑ`[a,x](ݑ`[b,x](ݑ`[d,x](ݑ`n,y,(ݐ ,y:(ݑ`,--yF(ݑ`,y++Q(ݑ``d,u\(ݑ`,u+h(ݑ`[a,u]t(ݑ`[b,u](ݑ`[d,u](ݑ`,rel(9_2(!,pc(9 K ό^ύg9(![,pc](9 K Ϝ^ϝg9(![n](9g9ϟ(!,dp(9p9(!#.(99(!die?(9((*,O(ݕ^asr,\(ݕ^asl,i(ݕ^rol,v(ݕ^ dec,(ݕ^ inc,(ݕ^ tst,(ݕ^ jmp,(ݕ^clr,(ݕ^nega,(ݖ@coma,(ݖClsra,(ݖDrora,(ݖFasra,(ݖGasla, (ݖHrola,(ݖIdeca,%(ݖJinca,3(ݖLtsta,A(ݖM stb,O(ݗ eorb,\(ݗ adcb,i(ݗ orb,w(ݗ addb,(ݗ ldd,(ݖsstd,(ݖsldu,(ݖsstu,(ݖsnop,(ݖsync,(ݖdaa,(ݖsex,(ݖrts,(ݖ9abx, (ݖ:rti,(ݖ;cwai,#(ݖ<mul,0(ݖ=swi,>(ݖ?leI(ݜ/notT(9p&)Up(!rel!_(9  [ K ! J(!bra,t(9 kL|(!brn,(9 kL|(!?apairs(9 !(!if,(9pLk^(!endif,(9 gk ^k !k |(!then,(9 (!else,((9k kTg(!b ert Source Diskette and Press RETURN : `5҇ܠ/܇ۄ Reading : ;ڠD;; " D;   ;"h; ,ݠ 6@;Jڄ/Insert Destinat!pass2(9C7{endifi\ebegini ؒ)i:M (!k ;(! screen$(editbuff (border(9 J2 @^@ JLvU JAU J p J2 !cnlj(9@@jE(!ctab{(92jT(!cdel(9 ,Pj   2 ?   q J(!cins(9 ,Pj   2 ? q J(!cerase(9 ,Pj   @ :(!crub&(9. ؑ (!cdel?T(9B B9(!clear](9 Lv @:P (!?done(9 k τk  k χk Uk  k ^k k  k ρ[ ϋK υk)(!getinput (9L , ) υ N 0(!docmdφ k <ψ k +g k  k  ؑ - (!fsedit(9,ߑ  B9, 9(! d$(x(y (u(s(pc$(a-(b7( cc@( dprI( stklookS( [n,y]^(ݑ& [,y]k(ݑ`[,--y]y(ݑ`[,y++](ݑ`,-y(ݑ`a,y(ݑ`b,y(ݑ`d,y(ݑ`,y+(ݑ`[a,y](ݑ`[b,y](ݑ`[d,y](ݑ`n,s(ݐ`,s (ݑ`,--s(ݑ`,s++!(ݑ`[n,s].(ݑ&`[,s];(ݑ`[,--s]I(ݑ`[,U k `U^ k `:g k `!p k  pL9(!rrO(9((* p(!inh(9((*(!stk(9((*L Lv i* (!imod (0 imod,8(9@*(jmpa,O(ݖNclra,](ݖOnegb,k(ݖPcomb,y(ݖSlsrb,(ݖTrorb,(ݖVasrb,(ݖWaslb,(ݖXrolb,(ݖYdecb,(ݖZincb,(ݖ\tstb,(ݖ]jmpb,(ݖ^clrb,(ݖ_suba,(ݗ cmpa,!(ݗ sbca,/(ݗ subd,=(ݗ anandcc,K(ݗ orccX(ݗ leax,g(ݗ 0leay,t(ݗ 1leas,(ݗ 2leau,(ݗ 3pshs,(ݖ4puls,(ݖ5pshu,(ݖ6pulu,(ݖ7cmpu,(ݗ%cmps,(ݗ%lds,(ݗ%sts,(ݗ%cmpd,(ݗ%cmpy,(ݗ%ldy,-(ݗ%sty,<(ݗ%egin,7(9kU(!until,P(9p U kL|(!end,b(9l(!while,(9C(!again,(9Uݝ(!repeat,(9 Þ e (!label(9k"9(!(ݜ&eq(ݜ'vc(ݜ(vs(ݜ)pl(ݜ*mi(ݜ+ge((ݜ,lt3(ݜ-gt>(ݜ. Jq(!+$%(9 2  %e  *  Jq %e q(!?pairs%(9!(!if&(9"kL^(!endif&4(9!^&)k  9(!then&J(9&S(!else&g(9^&)"kL ^&S^(!do&u(9"vkg(!loop&(9g&)" (! s((9L(w(!does>((9 "9's4 06~ uabort(((abort)((9( ok-prompt ((ok 0prompt) ()lowdp)(Hthaw),(-->)9(97)!L9!7 7[(!)E(97&U7[L97!T)! (! (!(number) )q(92 o xoo cold+j(9 $qL 9L97L9 $$9T oT9f of9xoLx9okeyboardrO9owO9)A abort+(9 ;SuperPET SuperFORTH - V 5.1 - Copyright 1 (!assembler .(# code.(9!!y'.L9(!end-code .(9!!$P (!;code.(9!.L9"'s(!fseek_/(fget_/#(reorder/1(9 K2 (!(idx)/>(9  v + Tg /-- @ /:-  @:@(!  Twi^  >^  1*U  * i ρ  Jo(!fixcmd1?(9v* :k ' aK z[_J  (!~2(9Lk *$k1F$  q 2&1 04z(94p3M$Screen #3g3^4(!prt-list 4(93 433 4_3 Lv 43  4_3 (! 2prt-list 4(93 43M 243 44_4_3 Lv 4 243  4_4_3 (!#prt4(4#cnt5I(mprint5U(94R  /I5] v )35]T5Q 5]^ E : * Screen -- DR *vg  ij) 9(!decompiler 7}(#2 W decompile 8(98k*9 C 9(i L9 *_9(!%8$(9""G81(!get$8p(9Lk *)wi+(! W flag-start $(alflag(9g  C* LL(!dropflag (9 g9 (!?gohereE(9 6   K Uk  C* C*{U (!>addro(9k 9 CJL g9 meit(9M  ؑ&|"G *π [compile] " ?UNKNOWN? Y(!strlit(9" C 2 w"(!0len7(9 T2 *) 2(!0strlitc(9" C k"(!1lit(9 C*(!2lit(9 C "' "G"- B eifNC  :+ {eifwhile eif^k(!?skipval (9L9L  k U *k  k Mk k ^V $k k C*22 k+loop&(9g&)"*(!/loop&(9g&)"M(!begin&(9!kU(!until&(9U&)"(!end'(9' (!while'(9&:C(!again'$(9U&)"(!repeat'5(9 '> e&S(!(;code)'L(9 ""9(!create'h(9 "G"p k *#C *2kTJ @ *, ( (2U[  (!number)(9LL 2*-k C9) *  *.L!L ;(! definitions )(9k :)59 9p *2 )5_9(! interpret *N(9985 John A. Toebesi$*]+ok,v(9(!cls,(9 (!home,(9U(!conload,(9 +>(!\,(9@2@j9(!chr-(9 k2*"(!base?-4(9 9(!hex.-K(9 L9(!rvstype-f(9 v*π (! (!sys indexline /Y(9 ^/b3wi(!index/(9/Iv/ (!findex/(9/Iv/b *(k^3wi  (!st/(jTO_03(hP_N0=(DS_R0H(iobuf_0S(FN_0_(h!fcb0m(9k JLkJk J0Dk9(!1 0wi(!editor2n(#. edit2(9L 2(!where2(9 2(!&emit2(9(!&type2(9'(!&cr3(9(2(!&rpt3(9Lv 2 (!&spaces3((9 30(!&.r3B(9 LA|*Q 3M3(!prt-on3W(9x9(!prt-off3|(9Lx9(* 94D(!wprint5a(94*5 "5S9p5_95k474"5S9g5_9(!execute$ 5(9 7 L9L79C9*8C9 79 9(!e-mod5(writeblk 61(9 p9 9 C9 ' '(!writef6B(9  k L 6N#7 4  L(! get-drive 8(9"Enter drive containing backup diski+Press return to accept 'DISK8/0' as defaulti8 (  q. J. J2 L $ config:fo q  L(! get-printer 8(9Enter printer devicei+Press returgz) gg  9 g9(!savedp(?abandon (9 *_9+(!sayaddr.(9 L9(!cfa->pfa N(9C(!cfa?p(9| "G"k(! associated (9T (9k ؑ|"G(! dobuildsdoes (9C "(!left(#[ ' |"G" cfa ] literal(!defend(9  'sk +k (!k ) {(!?branch(9  ؒ5k Bk)(! ?branchaddr ^(9 C (! markbegin (9g (!markthen (9U (! markrepeat (9p Ck"kU9LL(!specialJ(9U )H  k M2& k MC* k {+loopCM k {/loopC k {loopCv k edo" k U9kC(!vlist'(9 *?M[i """8 ) i(!;s'(#5 ~ ށ:((9!!y'#'s4 1~ ށ;(((9!"(!P(!;trace(@(9!" AP(!constant (S(9'P's~ variable (k(9(w's06~ user((9(w's ~ (ݜ 0-F44 42d :4"4 4@ .2f   forth S29" |8 $ oZ& JoZ&+~ :$8,v?9, 8@$$:" init-forth" free BDD7~ -dup &~ execute  "7~ utrace ((;trace) ' C55  ntrace-on 5 ] ~ trace-off O un ~ monitor f 40 50~ banksw ~ 7 ~ (bye) ~>r 74~ r> 5~ r ~ pick X anch'1"~ (loop) b-2d1"~ (+loop),m*b.2d1"~ (/loop)Om+b% b"|2d1"~ (do)Bx74~ in i'b~ jd~ k'h~ leaveb~ +7~ d+FBF4O_5YDD3D~*/mod(9 x (!m/mod(9 L   (!*/(9 (!1+40~ 2+,E0~ 1-=V0~ 2-Ng0~ >>_x/ DV0&~ <<p/ XI0&~ 2/GV~ 2*XI~ base(digit3BO06_\&ZO5 ~ sysread4 770402d5 ~ syswrite )4 77040 2d5 ~ r/wF4 BTTTTO ']BXIXIXIB4B'oADo1?&2b44D4BmA& 2dB, DDj&2a3F5 ~ release-disk =(9  (9U(!dr2(9^(!dr3(9g(!bl( in(0out (2nl( termbuff "(Rtib,(4 input-fcb <(( output-fcb G($ aux-output X(&key-fcbj(* printer-fcb |(, printer-name (%Y(printeral 4 5 'O~ space(9 (!spaces(9Ly  Lv (!erase(9L(!blanks(9 (!enclose0O4 3\E4F'&0 FD''0 FD&Bm'5 ~ expectB(9  vLJL2J  (k (!hld(6dpl(8numeral .0 W~ hold(9C[J(!sign (9 :-(!<#"(99(!#>;(9  (!#K(9 (!#sa(9f )(!d.rv(9 A|*Q w(!d.(9L(!.r(9 V (!?stack!(9z[U!K!(!?exec!(9!(!cfa!(9e(!pfa" (9 *?(!lfa"(9p(!nfa"1(9 *(![compile] "@(9)L! "(!compile"V(9! C (!literal"u(9  ""(!dlU^p"Gk#'#'9(g9(!forget#(9""G #D{! #7 {$*] #79 #' {$*] #'9 ""8 { e9 ) _9(!forth#(#9($(9)(!."$(9""ze decompiler:fo" 1 open-disk dr1 1 load user-const ( :$8,v?9,9 user-area (dup 6n4 4 3 ' 5 nI~ sp@ 0~ rp@ 6@~ @~ c@,O~ !$;77~ c!4L77~ +!D]77~ cmoveUs4 DB%'B/  B/  3F5 ~ toggleh7~ fill4 77 /0&5 ~ and -B~ d-FBFVDD3D~ negate'O_~ dnegate=O_BBV~ s->d0X~ c->sNj~ max`{7/~ minr7,~ +-(9:%(!d+-(9:;(!abs(9 (!dabs(9 (!u/hE+ %' % _$~@_~ decimal(9 9(!hex(99(!octal(99(!-1)(0=(1G(2P(3Y(4b(s0k(r0t(}sp!~|~ rp!~ disk-table (Juse(t update-flag (prev(p oL 9 (! open-disk (9   q$(f:128) q,rel quO )w 9(!+buff(9p k  (!buffera(9 j9 : C LD 9 9 C(!update(9stdink~ stdoutm~ key(9(!emit(92Uw (!set-curs 24 AC3D5 ~ get-curs $P4 4O6565 ~ crB(9L9+Uw(!queryc4 P4E 4V 싽2dE o0o oo5 ~ 0len{Ѯm&0J (!word(97 `C MkB:[  kJk2 q(! -trailing (9 Lv T* T (!dp&(hereYma ~ padc(9kπ(!allotx(9_[(!,(9k9^(!c,(9kJU(!back(9k(!c(!.(9V(!?(9(!bounds(9  (!.s(9zT L v C*U (!(line) (9 , !j`,(!.line 7(9 A3w(!list [(9 B9scr # iLv(^) di (!warning n( me iteral "(9 ""(!'"(9)L! "(!id."(9?w(!width"( voc-link #(lex-link #(fence#+(lexicon#;(9k: !(U^p"Gk#7#79(k: !g 9p* (!vocabulary #H(9k: !(k*2 kw(!(")$(9   (!"$(9""$k*2k  q(!""$(9L(!string%((9(Uy L(2(!mlen%6(9T*(!$@%](9(!$!%m(9 %e J 2 q(!$+%y(9   %e  * kD4B44044 i2j@46 7Z&0?045J& 42b' 55 n %h%h %d %d %d2dup 766~ drop z 3B~ 2drop 3D~ swap 76~ 2swap ĮDDBFFB~ over B~ rot 7A~ or7A~ xor7A~ 0=+'O_~ 0<#<,~ <4M7. >F]7- =Vm7' u<f}7" notu+c=4 70-4'2b5 ~/5.5 ~@lit~ clitO~ branch1~ 0briDiCiBB$B$  %BiEiD0&ܮBDCSDB3B~ u**B6B6C=EAB=EEoDiDB=oGAC=FFDD3D~ *"(9( (!m*e(9   ( (!m/r(9     (!/mod(9 V (!/(9 (!mod(9 (!first(`limit(|offset(@b/buf(b/scr (c/l(@blk%(:scr0(<openf;Q4 74Ľ2b5 ~ closefFq4 '5 ~ fgetchar e4 75 ~ fputchar 4 7742b5 ~ errorf4 75 ~ errormsg 4  *π JU9(!flush(9p2LvL  L9(! empty-buffers(9 ( 99L9(!block&(9   0j)  UDe  ) 9 C(!drnW(9 j9(!dr0(9L(!dr1~ 0type(9 w(!(0")(9 2  (!$->0$(9  qL J(!0"(9"""k 2 * qL k(!type2(9  f'x '(! (! (!counto(9 2 *(!(.")(9  2  w(! ?terminurrent(Fcontext(Dstate(Blatest(9(![(9L9(!](9π9(! immediate (9π(!smudge.(9@(!(find)Fg4 7@&%?&Z,00O65 ~@?:&˯5 ~ -find[(9 ke ) ke ssage (9 T p! d: Uk  stack empty message#  9i(!error (9 :)kw?  7+csp!2(>!csp!f(9!m9(!?error!q(9 !; (!?comp!(9)!(!?csp!(9!m! p^ (!location (9 ؑY(!?match(9  k k Q(!?endif(9U(!?repeat-(9^(!?begin?(9g(!dobrR(9 C :% {Jrepeat againelsee(!do0brd(9 C : {untilo e  95 k CnB k lCZ k M0>$ k MA& k M.A )  L9 )(!identify (9i " L9 *π immediate (! checktype y(9""  k @^@g JG J2 @^@ JU JAU Jp J2 @^@g J(! setup-scr (9,SuperPET SuperFORTH EDITORiScreen #iiLINE 0iUvi iiBUFFER:,((!setdisp(9J L ,Pj  , v*  U \(!ldownj(9 ,Pj Ð@q(!lup(9 ,Pj @q(!lcopy(9Pj  Pj  @q(!ldel(9 ,  v2  0 (!lins*(9 d$(9U00  k ψU0(! endfsedit l(9B ) (!runit(9, B+> (!doedit(9 ؑL   υk u k τk E k χk Yz k .gU k sU k @@push^( nextw( jump( mode(idxreg(9T(!n,r(9((*  K U9$ K ψ^ωg9(![n,r](9((* K Ϙ^ϙg9(!,*(9( (*U9(!,s++]V(ݑ`,-se(ݑ`a,st(ݑ`b,s(ݑ`d,s(ݑ`,s+(ݑ`[a,s](ݑ`[b,s](ݑ`[d,s](ݑ`n,u(ݐ@,u(ݑ`,--u(ݑ`,u++(ݑ`[n,u](ݑ&@[,u] (ݑ`[,--u](ݑ`[,u++]&(ݑ`,-u5(ݑ`a,uD(ݑ`b,uP((!idi2H(9((*Q ) p[$ ^k  gkL9(!idi,c(9( ^k  gkL9(!idi1(9((*Q(!idil(9(( *2*Q(!neg,(ݕ^com,5(ݕ^lsr,B(ݕ^ronda,K(ݗ bita,Y(ݗ lda,g(ݗ sta,u(ݗ eora,(ݗ adca,(ݗ ora,(ݗ adda,(ݗ cmpx,(ݖsjsr,(ݖsldx,(ݖsstx,(ݖssubb,(ݗ cmpb,(ݗ sbcb, (ݗ addd,(ݗ andb,%(ݗ bitb,3(ݗ ldb,A(%exg,J(ݕtfr,X(ݕswi2,e(9?(!swi3,r(9?(!ccod(9((*p(!-cc(ݜ$cs(ݜ%hi(ݜ"ls(ݜ#hs(ݜ$lo(ݜ%ne(ݜ&eq(ݜ'vc(ݜ(vs(ݜ)pl(ݜ*mi(ݜ+ge((ݜ,lt3(ݜ-gt>(ݜB eifNC  :+ {eifwhile eif^k(!?skipval (9L9L  k U *k  k Mk k ^V $k k C*22 k  secondaryU  k constantLj k variableLG k userL($ k L primaryL(!pass1(9 ؒ9C)>i. { ؒ9 { CVÑ:9J(!tightd(9(oo!o o(!loose(9 ooo  o(!pos-curs (9@   p0(!homeit(9UU0(!cright(92(!cleft(9T(!cdown%(9@(!cup<(9@(!chomeR(9 L , vT C* ,0 (!copyfrom d(9 ^0 ` Lv @qP @  (!copyto(9 `Lv @q@ P  (!recover(9B(!+scr*(9BUB[B(!-scr?(9BT  B k 0/ k p k s ^ k  k 5 k \ k ϊ k lϋ k Gρ k ς k 2uσ k bω k eOn,xL(ݐ,xj(ݑ`_,--xv(ݑ`,x++(ݑ`[n,x](ݑ&[,x](ݑ`[,--x](ݑ`[,x++](ݑ`,-x(ݑ`a,x(ݑ`b,x(ݑ`d,x(ݑ`,x+(ݑ`[a,x](ݑ`[b,x](ݑ`[d,x](ݑ`n,y,(ݐ ,y:(ݑ`,--yF(ݑ`,y++Q(ݑ`d,u\(ݑ`,u+h(ݑ`[a,u]t(ݑ`[b,u](ݑ`[d,u](ݑ`,rel(9_2(!,pc(9 K ό^ύg9(![,pc](9 K Ϝ^ϝg9(![n](9g9ϟ(!,dp(9p9(!#.(99(!die?(9((*r,O(ݕ^asr,\(ݕ^asl,i(ݕ^rol,v(ݕ^ dec,(ݕ^ inc,(ݕ^ tst,(ݕ^ jmp,(ݕ^clr,(ݕ^nega,(ݖ@coma,(ݖClsra,(ݖDrora,(ݖFasra,(ݖGasla, (ݖHrola,(ݖIdeca,%(ݖJinca,3(ݖLtsta,A(ݖM stb,O(ݗ eorb,\(ݗ adcb,i(ݗ orb,w(ݗ addb,(ݗ ldd,(ݖsstd,(ݖsldu,(ݖsstu,(ݖsnop,(ݖsync,(ݖdaa,(ݖsex,(ݖrts,(ݖ9abx, (ݖ:rti,(ݖ;cwai,#(ݖ<mul,0(ݖ=swi,>(ݖ.leI(ݜ/notT(9p&)Up(!rel!_(9  [ K ! J(!bra,t(9 kL|(!brn,(9 kL|(!?apairs(9 !(!if,(9pLk^(!endif,(9 gk ^k !k |(!then,(9 (!else,((9k kTg(! Ck"kU9LL(!specialJ(9U )H  k M2& k MC* k {+loopCM k {/loopC k {loopCv k edo" k U(!pass2(9C7{endifi\ebegini ؒ)i:M (!k ;(! screen$(editbuff (border(9 J2 @^@ JLvU JAU J p J2 (!cnlj(9@@jE(!ctab{(92jT(!cdel(9 ,Pj   2 ?   q J(!cins(9 ,Pj   2 ? q J(!cerase(9 ,Pj   @ :(!crub&(9. ؑ (!cdel?T(9B B9(!clear](9 Lv @:P (!?done(9 k τk  k χk Uk  k ^k k  k ρ[ ϋK υk)(!getinput (9L , ) υ N 0(!docmφ k <ψ k +g k  k  ؑ - (!fsedit(9,ߑ  B9, 9(! d$(x(y (u(s(pc$(a-(b7( cc@( dprI( stklookS(`[n,y]^(ݑ& [,y]k(ݑ`[,--y]y(ݑ`[,y++](ݑ`,-y(ݑ`a,y(ݑ`b,y(ݑ`d,y(ݑ`,y+(ݑ`[a,y](ݑ`[b,y](ݑ`[d,y](ݑ`n,s(ݐ`,s (ݑ`,--s(ݑ`,s++!(ݑ`[n,s].(ݑ&`[,s];(ݑ`[,--s]I(ݑ`[U k `U^ k `:g k `!p k  pL9(!rrO(9((* p(!inh(9((*(!stk(9((*L Lv i* (!imod (0 imod,8(9@*jmpa,O(ݖNclra,](ݖOnegb,k(ݖPcomb,y(ݖSlsrb,(ݖTrorb,(ݖVasrb,(ݖWaslb,(ݖXrolb,(ݖYdecb,(ݖZincb,(ݖ\tstb,(ݖ]jmpb,(ݖ^clrb,(ݖ_suba,(ݗ cmpa,!(ݗ sbca,/(ݗ subd,=(ݗ a ?andcc,K(ݗ orccX(ݗ leax,g(ݗ 0leay,t(ݗ 1leas,(ݗ 2leau,(ݗ 3pshs,(ݖ4puls,(ݖ5pshu,(ݖ6pulu,(ݖ7cmpu,(ݗ%cmps,(ݗ%lds,(ݗ%sts,(ݗ%cmpd,(ݗ%cmpy,(ݗ%ldy,-(ݗ%sty,<(ݗ ssage (9 T p! d: Uk  stack empty message#  9i(!error (9 :)kw?  7+csp!2(>!csp!f(9!m9(!?error!q(9 !; (!?comp!(9)!(!?csp!(9!m! U^p"Gk#'#'9(g9(!forget#(9""G #D{! #7 {$*] #79 #' {$*] #'9 ""8 { e9 ) _9(!forth#(#8($(9)(!."$(9"" +loop&(9g&)"*(!/loop&(9g&)"M(!begin&(9!kU(!until&(9U&)"(!end'(9' (!while'(9&:C(!again'$(9U&)"(!repeat'5(9 '> e&S(!(;code)'L(9 ""9(!create'h(9 "G"p k *#C *2kTJ @ *, ( (2U[  (!number)(9LL 2*-k C9) *  *.L!L ;(! definitions )(9k :)59 9p *2 )5_9(! interpret *N(9985 John A. Toebesi$*]+ok,v(9(!cls,(9 (!home,(9U(!conload,(9 +>(!\,(9@2@j9(!chr-(9 k2*"(!base?-4(9 9(!hex.-K(9 L9(!rvstype-f(9 v*π (! (!sys indexline /Y(9 ^/b3wi(!index/(9/Iv/ (!findex/(9/Iv/b *(k^3wi  (!st/(jTO_03(hP_N0=(DS_R0H(iobuf_0S(FN_0_(h!fcb0m(9k JLkJk J0Dk9(!1 0wi(!editor2n(#. edit2(9L 2(!where2(9 2(!&emit2(9(!&type2(9'(!&cr3(9(2(!&rpt3(9Lv 2 (!&spaces3((9 30(!&.r3B(9 LA|*Q 3M3(!prt-on3W(9x9(!prt-off3|(9Lx9(* 94D(!wprint5a(94*5 "5S9p5_95k474"5S9g5_9(!execute$ 5(9 7 L9L79C9*8C9 79 9(!e-mod5(writeblk 61(9 p9 9 C9 ' '(!writef6B(9  k L 6N#7 4 U 9,(! W flag-start $(alflag(9g  C* LL(!dropflag (9 g9 (!?gohereE(9 6   K Uk  C* C*{U (!>addro(9k 9 CJL g9ameit(9M  ؑ&|"G *π [compile] " ?UNKNOWN? Y(!strlit(9" C 2 w"(!0len7(9 T2 *) 2(!0strlitc(9" C k"(!1lit(9 C*(!2lit(9 C "' "G"- (!?stack!(9z[U!K!(!?exec!(9!(!cfa!(9e(!pfa" (9 *?(!lfa"(9p(!nfa"1(9 *(![compile] "@(9)L! "(!compile"V(9! C (!literal"u(9  ""(!dlk*2 kw(!(")$(9   (!"$(9""$k*2k  q(!""$(9L(!string%((9(Uy L(2(!mlen%6(9T*(!$@%](9(!$!%m(9 %e J 2 q(!$+%y(9   %e  *9kC(!vlist'(9 *?M[i """8 ) i(!;s'(#5 ~ ށ:((9!!y'#'s4 1~ ށ;(((9!"(!P(!;trace(@(9!" AP(!constant (S(9'P's~ variable (k(9(w's06~ user((9(w's ~ pfa N(9C(!cfa?p(9| "G"k(! associated (9T (9k ؑ|"G(! dobuildsdoes (9C "(!leftؑ#[ ' |"G" cfa ] literal(!defend(9  'sk +k (!k ) {(!?branch(9  ؒ5k Bk)(! ?branchaddr ^(9 C (! markbegin (9g (!markthen (9U (! markrepeat (9iteral "(9 ""(!'"(9)L! "(!id."(9?w(!width"( voc-link #(lex-link #(fence#+(lexicon#;(9k: !(U^p"Gk#7#79(k: !g 9p* (!vocabulary #H(9k: !( Jq(!+$%(9 2  %e  *  Jq %e q(!?pairs%(9!(!if&(9"kL^(!endif&4(9!^&)k  9(!then&J(9&S(!else&g(9^&)"kL ^&S^(!do&u(9"vkg(!loop&(9g&)" (!s((9L(w(!does>((9 "9's4 06~ uabort(((abort)((9( ok-prompt ((ok 0prompt) ()lowdp)(Hthaw),(-->)9(97)!L9!7 7[(!)E(97&U7[L97!T)! (! (!(number) )q(92o xoo cold+j(9 $qL 9L97L9 $$9T oT9f of9xoLx9okeyboardrO9owO9)A abort+(9 ;SuperPET SuperFORTH - V 5.1 - Copyright 1(!assembler .(# code.(9!!y'.L9(!end-code .(9!!$P (!;code.(9!.L9"'s(!fseek_/(fget_/#(reorder/1(9 K2 (!(idx)/>(9  v + Tg /-- @ /:-  @:@(!  Twi^  >^  1*U  * i ρ  Jo(!fixcmd1?(9v* :k ' aK z[_J  (!~2(9Lk *$k1F$  q 2&1 04z(94p3M$Screen #3g3^4(!prt-list 4(93 433 4_3 Lv 43  4_3 (! 2prt-list 4(93 43M 243 44_4_3 Lv 4 243  4_4_3 (!#prt4(4#cnt5I(mprint5U(94R  /I5] v )35]T5Q 5]^ E : * Screen -- DR *vg  ij) 9(!decompiler 7}(#2 W decompile 8(98k*9 C 9(i L9 *_9(!%8$(9""G81(!startup8p(9$ system:foL (indent(cpf(maxaddr( indent-step (0brloc(brloc+(ind9(9(!ind+F(9M'[(!ind-](9'%[M(!aind-s(9Ò'(!.v(9 CL(!.u(9 C(!'cfa(9""#"(!n a,(ݗ cmpx,(ݖsjsr,(ݖsldx,(ݖsstx,(ݖssubb,(ݗ cmpb,(ݗ sbcb, (ݗ addd,(ݗ andb,%(ݗ bitb,3(ݗ ldb,A(ݗ stb,O(ݗ eorb,\(ݗ adcb,i(ݗ orb,w(ݗ addb,(ݗ ldd,(ݖsstd,(ݖs ݜ$cs(ݜ%hi(ݜ"ls(ݜ#hs(ݜ$lo(ݜ%ne(ݜ&eq(ݜ'vc(ݜ(vs(ݜ)pl(ݜ*mi(ݜ+ge((ݜ,lt3(ݜ-gt>(ݜ.leI(ݜ/notT(9p&)Up(!rel!_(9  [ K ! J(!bra,t(9 kL .-F44 42d :4"4 4@ .2f   forth S29" |8 $ oZ& JoZ&+~ 8$8,v?8, 6m$$8" full-forthp" fre BDD7~ -dup &~ execute  "7~ utrace ((;trace) ' C55  ntrace-on 5 ] ~ trace-off O un ~ monitor f 40 50~ banksw ~ 7 ~ (bye) ~>r 74~ r> 5~ r ~ pick Xanch'1"~ (loop) b-2d1"~ (+loop),m*b.2d1"~ (/loop)Om+b% b"|2d1"~ (do)Bx74~ in i'b~ jd~ k'h~ leaveb~ +7~ d+FBF4O_5YDD3D~*/mod(9 x (!m/mod(9 L   (!*/(9 (!1+40~ 2+,E0~ 1-=V0~ 2-Ng0~ >>_x/ DV0&~ <<p/ XI0&~ 2/GV~ 2*XI~ base(digit3BO06_\&ZO5 ~ sysread4 770402d5 ~ syswrite )4 77040 2d5 ~ r/wF4 BTTTTO ']BXIXIXIB4B'oADo1?&2b44D4BmA& 2dB, DDj&2a3F5 ~ release-disk =(9  (9U(!dr2(9^(!dr3(9g(!bl( in(0out (2nl( termbuff "(Rtib,(4 input-fcb <(( output-fcb G($ aux-output X(&key-fcbj(* printer-fcb |(, printer-name (%Y(printeral 4 5 'O~ space(9 (!spaces(9Ly  Lv (!erase(9L(!blanks(9 (!enclose0O4 3\E4F'&0 FD''0 FD&Bm'5 ~ expectB(9  vLJL2J  (k (!hld(6dpl(8numeral .0 W~ hold(9C[J(!sign (9 :-(!<#"(99(!#>;(9  (!#K(9 (!#sa(9f )(!d.rv(9 A|*Q w(!d.(9L(!.r(9 V ldu,(ݖsstu,(ݖsnop,(ݖsync,(ݖdaa,(ݖsex,(ݖrts,(ݖ9abx, (ݖ:rti,(ݖ;cwai,#(ݖ<mul,0(ݖ=swi,>(ݖ?andcc,K(ݗ orccX(ݗ leax,g(ݗ 0leay,t(ݗ 1leas,(ݗ 2leau,(ݗ 3pshs,(ݖ|(!brn,(9 kL|(!?apairs(9 !(!if,(9pLk^(!endif,(9 gk ^k !k |(!then,(9 (!else,((9k kTg(!begin,7(9kU(!until,P(9p U kL|(!end,b(9l(!while,(9C(!again,(9eze" decompiler:fo" 1 open-disk dr1 1 load user-const ( 8$8,v?8,8 user-area (dup 6n4 4 3 ' 5 nI~ sp@ 0~ rp@ 6@~ @~ c@,O~ !$;77~ c!4L77~ +!D]77~ cmoveUs4 DB%'B/  B/  3F5 ~ toggleh7~ fill4 77 /0&5 ~ and -B~ d-FBFVDD3D~ negate'O_~ dnegate=O_BBV~ s->d0X~ c->sNj~ max`{7/~ minr7,~ +-(9:%(!d+-(9:;(!abs(9 (!dabs(9 (!u/hE+ %' % _$~@_~ decimal(9 9(!hex(99(!octal(99(!-1)(0=(1G(2P(3Y(4b(s0k(r0t(}sp!~|~ rp!~ disk-table (Juse(l update-flag (prev(h oL 9 (! open-disk (9   q$(f:128) q,rel quO )w 9(!+buff(9p k  (!buffera(9 j9 : C LD 9 9 C(!update(9stdink~ stdoutm~ key(9(!emit(92Uw (!set-curs 24 AC3D5 ~ get-curs $P4 4O6565 ~ crB(9L9+Uw(!queryc4 P4E 4V 싽2dE o0o oo5 ~ 0len{Ѯm&0J (!word(97 `C MkB:[  kJk2 q(! -trailing (9 Lv T* T (!dp&(hereYma ~ padc(9kπ(!allotx(9_[(!,(9k9^(!c,(9kJU(!back(9k(!c(!.(9V(!?(9(!bounds(9  (!.s(9zT L v C*U (!(line) (9 , !j`,(!.line 7(9 A3w(!list [(9 B9scr # iLv(^) di (!warning n( me4puls,(ݖ5pshu,(ݖ6pulu,(ݖ7cmpu,(ݗ%cmps,(ݗ%lds,(ݗ%sts,(ݗ%cmpd,(ݗ%cmpy,(ݗ%ldy,-(ݗ%sty,<(ݗ%exg,J(ݕtfr,X(ݕswi2,e(9?(!swi3,r(9?(!ccod(9((*p(!-cc(?Uݝ(!repeat,(9 Þ e (!label(9k"9(!(ݜ&eq(ݜ'vc(ݜ(vs(ݜ)pl(ݜ*mi(ݜ+ge((ݜ,lt3(ݜ-gt>(ݜ.leI(ݜ/notT(9p&)Up(!rel!_(9  [ K ! J(!bra,t(9 kL kD4B44044 i2j@46 7Z&0?045J& 42b' 55 n %h%h %d %d %d2dup 766~ drop z 3B~ 2drop 3D~ swap 76~ 2swap ĮDDBFFB~ over B~ rot 7A~ or7A~ xor7A~ 0=+'O_~ 0<#<,~ <4M7. >F]7- =Vm7' u<f}7" notu+c=4 70-4'2b5 ~/5.5 ~@lit~ clitO~ branch1~ 0briDiCiBB$B$  %BiEiD0&ܮBDCSDB3B~ u**B6B6C=EAB=EEoDiDB=oGAC=FFDD3D~ *"(9( (!m*e(9   ( (!m/r(9     (!/mod(9 V (!/(9 (!mod(9 (!first(`limit(|offset(@b/buf(b/scr (c/l(@blk%(:scr0(<openf;Q4 74Ľ2b5 ~ closefFq4 '5 ~ fgetchar e4 75 ~ fputchar 4 7742b5 ~ errorf4 75 ~ errormsg 4  *π JU9(!flush(9p2LvL  L9(! empty-buffers(9 ( 99L9(!block&(9   0j)  UDe  ) 9 C(!drnW(9 j9(!dr0(9L(!dr1~ 0type(9 w(!(0")(9 2  (!$->0$(9  qL J(!0"(9"""k 2 * qL k(!type2(9  f'x '(! (! (!counto(9 2 *(!(.")(9  2  w(! ?termin urrent(Fcontext(Dstate(Blatest(9(![(9L9(!](9π9(! immediate (9π(!smudge.(9@(!(find)Fg4 7@&%?&Z,00O65 ~@?:&˯5 ~ -find[(9 ke ) ke (9 g9 (!?gohereE(9 6   K Uk  C* C*{U (!>addro(9k 9 CJL g9 gz) gg  9 g9(!savedp(?abandon (9 *_9+(! C 2 w"(!0len7(9 T2 *) 2(!0strlitc(9" C k"(!1lit(9 C*(!2lit(9 C "' "G"- ؑ#[ ' |"G" cfa ] literal(!defend(9  'sk +k (!k  (!?skipval (9L9L  k U *k  k Mk k ^V $k k C*22 k Ck"kU9LL(!specialJ(9U )H  k M2&  k userL($ k L primaryL(!pass1(9 ؒ9C)>i. { ؒ9 { CVÑ:9(!pass2(9C7{endifi\ebegini ؒ)i:Ms-curs (9@   p0(!homeit(9UU0(!cright(92(!cleft(9T(!cdown%(9@(!cup<(9@(!chomeR(9 L(!cnlj(9@@jE(!ctab{(92jT(!cdel(9 ,Pj   2 ? @qP @  (!copyto(9 `Lv @q@ P  (!recover(9B(!+scr*(9BUB[B(!-scr?(9BT B B9(!clear](9 Lv @:P (!?done(9 k τk  k 5 k \ k ϊ k lϋ k Gρ k ς k 2uσ k bω k eOφ k <ψ k +g k  k  ؑ - (!fsedi(ݑ`,-x(ݑ`a,x(ݑ`b,x(ݑ`d,x(ݑ`,x+(ݑ`[a,x](ݑ`[b,x](ݑ`[d,x](ݑ`n,y,(ݐ ,y:(ݑ`,--yF(ݑ`,y++Q(ݑ`[n,y]^(ݑ& [,y]k(ݑ`[,--y]y(ݑ`[,y++](ݑ`,-y(ݑ`a,y(ݑ`b,y(ݑ`d9 K ό^ύg9(![,pc](9 K Ϝ^ϝg9(![n](9g9ϟ(!,dp(9p9(!#.(99(!die?(9((*U k `U^ k `:g k `!p k ݕ^clr,(ݕ^nega,(ݖ@coma,(ݖClsra,(ݖDrora,(ݖFasra,(ݖGasla, (ݖHrola,(ݖIdeca,%(ݖJinca,3(ݖLtsta,A(ݖMjmpa,O(ݖNclra,](ݖOnegb,k(ݖPcomb,y(ݖSlsrb,(ݖTrorb,(ݖVasrb,(ݖsayaddr.(9 L9(!cfa->pfa N(9C(!cfa?p(9| "G"k(! associated (9T (9k ؑ|"G(! dobuildsdoes (9C "(!left(indent(cpf(maxaddr( indent-step (0brloc(brloc+(ind9) {(!?branch(9  ؒ5k Bk)(! ?branchaddr ^(9 C (! markbegin (9g (!markthen (9U (! markrepeat (9p^ (!location (9 ؑY(!?match(9  k k Q(!?endif(9U(!?repeat k MC* k {+loopCM k {/loopC k {loopCv k edo" k U95 k CnB k lCZ k M0>$ k MA (!k ;(! screen$(editbuff (border(9 J2 @^@ JLvU JAU J p J2 @^@g JG J2 @^@ JU JAU Jp J2 @^  q J(!cins(9 ,Pj   2 ? q J(!cerase(9 ,Pj   @ :(!crub&(9. ؑ (!cdel?T(9L ,Pj  , v*  U \(!ldownj(9 ,Pj Ðχk Uk  k ^k k  k ρ[ ϋK υk)(!getinput (9L , ) υ N 0(!docmd$(9U00  k ψU0(! endfsedit l(9B ) (!runit(9, t(9,ߑ  B9, 9(! d$(x(y (u(s(pc$(a-(b7( cc@( dprI( stklookS( @@push^( nextw( jump( mode(idxreg(9T(!n,r(9((,y(ݑ`,y+(ݑ`[a,y](ݑ`[b,y](ݑ`[d,y](ݑ`n,s(ݐ`,s (ݑ`,--s(ݑ`,s++!(ݑ`[n,s].(ݑ&`[,s];(ݑ`[,--s]I(ݑ`[,s++]V(ݑ`,-se(ݑ`a,st(ݑ`b,s(ݑ`d,s(ݑ`,s+(ݑ`[a,s](ݑ`[b,s]( pL9(!rrO(9((* p(!inh(9((*(!stk(9((*L Lv i* (!imod (0 imod,8(9@*(!idi2H(9((*Q ) p[$ ^k  gkL9(!idi,Waslb,(ݖXrolb,(ݖYdecb,(ݖZincb,(ݖ\tstb,(ݖ]jmpb,(ݖ^clrb,(ݖ_suba,(ݗ cmpa,!(ݗ sbca,/(ݗ subd,=(ݗ anda,K(ݗ bita,Y(ݗ lda,g(ݗ sta,u(ݗ eora,(ݗ adca,(ݗ ora,(ݗ add(9(!ind+F(9M'[(!ind-](9'%[M(!aind-s(9Ò'(!.v(9 CL(!.u(9 C(!'cfa(9""#"(!nameit(9M  ؑ&|"G *π [compile] " ?UNKNOWN? Y(!strlit(9" -(9^(!?begin?(9g(!dobrR(9 C :% {Jrepeat againelsee(!do0brd(9 C : {untilo e B eifNC  :+ {eifwhile eif^k& k M.A )  L9 )(!identify (9i " L9 *π immediate (! checktype y(9""  k  secondaryU  k constantLj k variableLG@g J(! setup-scr (9,SuperPET SuperFORTH EDITORiScreen #iiLINE 0iUvi iiBUFFER:,((!setdisp(9JJ(!tightd(9(oo!o o(!loose(9 ooo  o(!po@q(!lup(9 ,Pj @q(!lcopy(9Pj  Pj  @q(!ldel(9 ,  v2  0 (!lins*(9 , vT C* ,0 (!copyfrom d(9 ^0 ` Lv B+> (!doedit(9 ؑL   υk u k τk E k χk Yz k .gU k sU k B k 0/ k p k s ^ k  k *  K U9$ K ψ^ωg9(![n,r](9((* K Ϙ^ϙg9(!,*(9( (*U9(!n,xL(ݐ,xj(ݑ`_,--xv(ݑ`,x++(ݑ`[n,x](ݑ&[,x](ݑ`[,--x](ݑ`[,x++]ݑ`[d,s](ݑ`n,u(ݐ@,u(ݑ`,--u(ݑ`,u++(ݑ`[n,u](ݑ&@[,u] (ݑ`[,--u](ݑ`[,u++]&(ݑ`,-u5(ݑ`a,uD(ݑ`b,uP(ݑ`d,u\(ݑ`,u+h(ݑ`[a,u]t(ݑ`[b,u](ݑ`[d,u](ݑ`,rel(9_2(!,pc( c(9( ^k  gkL9(!idi1(9((*Q(!idil(9(( *2*Q(!neg,(ݕ^com,5(ݕ^lsr,B(ݕ^ror,O(ݕ^asr,\(ݕ^asl,i(ݕ^rol,v(ݕ^ dec,(ݕ^ inc,(ݕ^ tst,(ݕ^ jmp,( urrent(Fcontext(Dstate(Blatest(9(![(9L9(!](9π9(! immediate (9π(!smudge.(9@(!(find)Fg4 7@&%?&Z,00O65 ~@?:&˯5 ~ -find[(9 ke ) ke ssage (9 T p! d: Uk  stack empty message#  9i(!error (9 :)kw?  7+csp!2(>!csp!f(9!m9(!?error!q(9 !; (!?comp!(9)!(!?csp!(9!m! U^p"Gk#'#'9(g9(!forget#(9""G #D{! #7 {$*] #79 #' {$*] #'9 ""8 { e9 ) _9(!forth#(#:($(9)(!."$(9"" +loop&(9g&)"*(!/loop&(9g&)"M(!begin&(9!kU(!until&(9U&)"(!end'(9' (!while'(9&:C(!again'$(9U&)"(!repeat'5(9 '> e&S(!(;code)'L(9 ""9(!create'h(9 "G"p k *#C *2kTJ @ *, ( (2U[  (!number)(9LL 2*-k C9) *  *.L!L ;(! definitions )(9k :)59 9p *2 )5_9(! interpret *N(9985 John A. Toebesi$*]+ok,v(9(!cls,(9 (!home,(9U(!conload,(9 +>(!\,(9@2@j9(!chr-(9 k2*"(!base?-4(9 9(!hex.-K(9 L9(!rvstype-f(9 v*π (! (!sys indexline /Y(9 ^/b3wi(!index/(9/Iv/ (!findex/(9/Iv/b *(k^3wi  (!st/(jTO_03(hP_N0=(DS_R0H(iobuf_0S(FN_0_(h!fcb0m(9k JLkJk J0Dk9(!1 0wi(!editor2n(#. edit2(9L 2(!where2(9 2(!&emit2(9(!&type2(9'(!&cr3(9(2(!&rpt3(9Lv 2 (!&spaces3((9 30(!&.r3B(9 LA|*Q 3M3(!prt-on3W(9x9(!prt-off3|(9Lx9($*r640S3(!&lmode5(9LAGfk&Q3(!&init5(9U54535H4(!h-lin5(93M+2-@30+2(!n-lin5(9 3^|2 A3|2(!pr-scr6(94Up3M$Screen #3g3^4l(!prt-list 67(94 6A33 53 Lv 63  53 (! 2prt-list 9  q,prg qsO Kf  q ( pqp(8f qpq(!buffers? 8{(9   -n  E : * Screen -- DR *vg  ij) (!hld(6dpl(8numeral .0 W~ hold(9C[J(!sign (9 :-(!<#"(99(!#>;(9  (!#K(9 (!#sa(9f )(!d.rv(9 A|*Q w(!d.(9L(!.r(9 V (!?stack!(9z[U!K!(!?exec!(9!(!cfa!(9e(!pfa" (9 *?(!lfa"(9p(!nfa"1(9 *(![compile] "@(9)L! "(!compile"V(9! C (!literal"u(9  ""(!dlk*2 kw(!(")$(9   (!"$(9""$k*2k  q(!""$(9L(!string%((9(Uy L(2(!mlen%6(9T*(!$@%](9(!$!%m(9 %e J 2 q(!$+%y(9   %e  *9kC(!vlist'(9 *?M[i """8 ) i(!;s'(#5 ~ ށ:((9!!y'#'s4 1~ ށ;(((9!"(!P(!;trace(@(9!" AP(!constant (S(9'P's~ variable (k(9(w's06~ user((9(w's ~ ((9 "9's4 06~ uabort(((abort)((9( ok-prompt ((ok 0prompt) ()lowdp)(Hthaw),(-->)9(97)!L9!7 7[(!)E(97&U7[L97!T)! (! (!(number) )q(92o xoo cold+j(9 $qL 9L97L9 $$9T oT9f of9xoLx9okeyboardrO9owO9)A abort+(9 ;SuperPET SuperFORTH - V 5.1 - Copyright 1(!assembler .(# code.(9!!y'.L9(!end-code .(9!!$P (!;code.(9!.L9"'s(!fseek_/(fget_/#(reorder/1(9 K2 (!(idx)/>(9  v + Tg /-- @ /:-  @:@(!  Twi^  >^  1*U  * i ρ  Jo(!fixcmd1?(9v* :k ' aK z[_J  (!~2(9Lk *$k1F$  q 2&1 0(!&8lpi4(9$&l8D3(!&6lpi4(9$&l6D3(!&perf4(9$&l1L3(!&-perf4(9$&l0L3(!&wrap4(9$&s0C3(!&-wrap4(9$&s1C3(!&uni5(9$&k0W3(!&bi5,(9$&k1W3(!&reset5A(9$z3(!&test5U(9$E3(!&hires5i(9$*r1280S3(!&lores5|(9 7 L9L79C9*8C9 79 9(!e-mod7(writeblk 7(9 p9 9 C9 ' '(!writef7(9  k L 7#7 4  g  C*  7 )7 ' o(!freeze8(9 $q$*] $ 0A-F44 42d :4"4 4@ .2f   forth S29" |8 $ oZ& JoZ&+~ :A$9,v?:%, :H#~$$:A" full-forth" free BDD7~ -dup &~ execute  "7~ utrace ((;trace) ' C55  ntrace-on 5 ] ~ trace-off O un ~ monitor f 40 50~ banksw ~ 7 ~ (bye) ~>r 74~ r> 5~ r ~ pick X anch'1"~ (loop) b-2d1"~ (+loop),m*b.2d1"~ (/loop)Om+b% b"|2d1"~ (do)Bx74~ in i'b~ jd~ k'h~ leaveb~ +7~ d+FBF4O_5YDD3D~   */mod(9 x (!m/mod(9 L   (!*/(9 (!1+40~ 2+,E0~ 1-=V0~ 2-Ng0~ >>_x/ DV0&~ <<p/ XI0&~ 2/GV~ 2*XI~ base(digit3BO06_\&ZO5 ~ sysread4 770402d5 ~ syswrite )4 77040 2d5 ~ r/wF4 BTTTTO ']BXIXIXIB4B'oADo1?&2b44D4BmA& 2dB, DDj&2a3F5 ~ release-disk =(9  (9U(!dr2(9^(!dr3(9g(!bl( in(0out (2nl( termbuff "(Rtib,(4 input-fcb <(( output-fcb G($ aux-output X(&key-fcbj(* printer-fcb |(, printer-name (%Y(ieee4eral 4 5 'O~ space(9 (!spaces(9Ly  Lv (!erase(9L(!blanks(9 (!enclose0O4 3\E4F'&0 FD''0 FD&Bm'5 ~ expectB(9  vLJL2J  (k zeload dr1 1 load printers ) user-const ( :A$9,v?:%,: user-area (dup 6n4 4 3 ' 5 nI~ sp@ 0~ rp@ 6@~ @~ c@,O~ !$;77~ c!4L77~ +!D]77~ cmoveUs4 DB%'B/  B/  3F5 ~ toggleh7~ fill4 77 /0&5 ~ and -B~ d-FBFVDD3D~ negate'O_~ dnegate=O_BBV~ s->d0X~ c->sNj~ max`{7/~ minr7,~ +-(9:%(!d+-(9:;(!abs(9 (!dabs(9 (!u/hE   + %' % _$~@_~ decimal(9 9(!hex(99(!octal(99(!-1)(0=(1G(2P(3Y(4b(s0k(~r0t(|Lsp!~|~ rp!~ disk-table (Juse(gp update-flag (prev(cl oL 9 (! open-disk (9   q$(f:128) q,rel quO )w 9(!+buff(9p k  (!buffera(9 j9 : C LD 9 9 C(!update(9stdink~ stdoutm~ key(9(!emit(92Uw (!set-curs 24 AC3D5 ~ get-curs $P4 4O6565 ~ crB(9L9+Uw(!queryc4 P4E 4V 싽2dE o0o oo5 ~ 0len{Ѯm&0J (!word(97 `C MkB:[  kJk2 q(! -trailing (9 Lv T* T (!dp&(hereYma ~ padc(9kπ(!allotx(9_[(!,(9k9^(!c,(9kJU(!back(9k(!c kD4B44044 i2j@46 7Z&0?045J& 42b' 55 n %h%h %d %d %d2dup 766~ drop z 3B~ 2drop 3D~ swap 76~ 2swap ĮDDBFFB~ over B~ rot 7A~ or7A~ xor7A~ 0=+'O_~ 0<#<,~ <4M7. >F]7- =Vm7' u<f}7" notu+c=4 70-4'2b5 ~/5.5 ~@lit~ clitO~ branch1~ 0briDiCiBB$B$  %BiEiD0&ܮBDCSDB3B~ u**B6B6C=EAB=EEoDiDB=oGAC=FFDD3D~ *"(9( (!m*e(9   ( (!m/r(9     (!/mod(9 V (!/(9 (!mod(9 (!  first(_hlimit({offset(@b/buf(b/scr (c/l(@blk%(:scr0(<openf;Q4 74Ľ2b5 ~ closefFq4 '5 ~ fgetchar e4 75 ~ fputchar 4 7742b5 ~ errorf4 75 ~ errormsg 4  *π JU9(!flush(9p2LvL  L9(! empty-buffers(9 ( 99L9(!block&(9   0j)  UDe  ) 9 C(!drnW(9 j9(!dr0(9L(!dr1 ~ 0type(9 w(!(0")(9 2  (!$->0$(9  qL J(!0"(9"""k 2 * qL k(!type2(9  f'x '(! (! (!counto(9 2 *(!(.")(9  2  w(! ?termin else 0 cpf ! swap 0= endif ; -->( Smart Decompiler - Part Levin ) : identify ( nfa -- nfa ) cr dup id. base @ over hex 0 d. space base !  0 else drop ." primary" 0 end-case ;  ?abandon repeat maxaddr ! ; : pass2 ( addr -- ) begin 2+ begin ?endif while location ind- ." endif" cr repeat begin ?begin while location  flag-start dup 2+ swap ! flag-start @ 5 erase checktype cr if dup 0 indent ! pass1 pass2 r -- addr ) ?branchaddr 1 swap >addr ; : markrepeat ( addr -- addr ) ?branchaddr 4 - 2 swap >addr ; : location ( addr -- addr ) dup sayaddr space ; ddr -- addr ) dup 2+ @ dup 0< if \ *** backward branch, what type is it really drop ind- ?repeat if ." repeat" else ." again" endif else  over + 2- dup @ brloc - \ is target a branch if drop ind+ ." if" markthen \ no, must be if no else else 2+ dup @ dup 0< \ target branch backward? if + over swap u< \ do we bound it?  ( Smart Decompiler - Part Nein ) : ?skipval ( addr -- addr n ) cpf @ if 0 cpf ! 0 else dup @ begin-case  else 'cfa compile = if 1 cpf ! 0 else 0 end-case endif ; else 'cfa (do) case ind+ ." do" else 'cfa compile case nameit 1 cpf ! else 0brloc case do0br 2+ else brloc case dobr 2 dup c@ 128 and if ." immediate " endif ; : checktype ( nfa -- t=can decompile this word ) pfa cfa dup @ begin-case 'cfa >addr @ case ." secondary" 1 -->( Smart Decompiler - Part Christmas ) : pass1 ( addr -- ) dup maxaddr ! begin 2+ defend 0= while ind+ ." begin" cr repeat location dup maxaddr @ - while special 0= if nameit endif cr ?abandon repeat ind dup @ 'cfa ;s = if  endif drop savedp @ dp ! ; : % ( -- ; word to decompile ) [compile] ' nfa deco -->( Smart Decompiler - Part Dwarfs ) : ?match ( addr n -- addr t=type n at addr ) over flag rot = rot rot = and dup if dropflag endif ; : ?endif ( ad \ *** forward branch - beware of null else aind- ." else" 2- if markthen endif endif ;  if ind+ ." if" markthen \ yes, must be if no else else aind- ." while" \ not bound - must be while markrepeat endif \ distinguish it from again else swap drop ind+ ." if" \ must be if with else ?  dup 'cfa clit = if drop 1 else dup 'cfa (+loop) = over 'cfa (loop) = or over 'cfa (/loop) = or  -->( Smart Decompiler - Part Bo ) : special ( adr -- adr n ) 1 swap cpf @ 0= if dup @ begin-case 'cfa clit case ind 1lit 1+ el+ else 'cfa (0") case ind ." 0" 0strlit + else 'cfa (") case ind strlit + else 'cfa (.") case ind ." ." strlit + else drop swap 0= swap end-case swap  else 'cfa bl @ case ." constant" .v 0 else 'cfa cpf @ case ." variable" .v 0 else 'cfa hld @ case ." user" .u 0 else 'cfa forth @ case dobuildsdoes  ?branch if ?branchaddr maxaddr @ over u< if dup maxaddr ! endif 2dup u< not if markbegin else drop endif 2+ else ?skipval + endif ." ;" else nameit endif ; -->( Smart Decompiler - Part Friday ) forth definitions : decompile ( addr -- ) decompiler [compile] decompiler here savedp ! identify mpile ; dr -- addr t=endif here ) 1 ?match ; : ?repeat ( addr -- addr t=repeat here ) 2 ?match ; : ?begin ( addr -- addr t=begin here ) 3 ?match ; : dobr ( a -->( Smart Decompiler - Part Ait ) : do0br ( addr -- addr ) dup 2+ @ dup 0< if drop ind- ." until" \ backward branch else 2 = if markthen endif \ adopt orphan null elses endif endif endif ; -->  over 'cfa lit = or if drop 2 else dup 'cfa (") = over 'cfa (.") = or if drop dup 2+ c@ 1+ else dup 'cfa (0") = if drop dup 2+ 0len  se 'cfa lit case ind 2lit 2+ else 'cfa (+loop) case ind- ." +loop" 2+ else 'cfa (/loop) case ind- ." /loop" 2+ else 'cfa (loop) case ind- ." loop" 2+  ( Smart Decompiler - Part Won ) 12 lexicon decompiler decimal immediate decompiler definitions 0 variable flag-start here 5 allot 0 over 3 + ! flag-start ! : flag ( -- F N ) flag-start @ 3 + @  -->  swap 3 + ! ; ( link in list ) 0 variable savedp : ?abandon ?terminal if savedp @ dp ! quit endif ; ) Structured Compilation Only Used in the form BEGIN .. WHILE .. REPEAT to build a structured loop whose termination clause is tested before executing the body of the loop. It compiles a 0BRANCH which at runtime removes the oken delimited by the character c. It will place the token at HERE with a preceding byte count. XOR ( n2 n1 -- n3 ) Logical Performs a bit-wise Exclusive-Or on single precision values n2 and n1 leaving the single prec cfa->pfa dup nfa pfa = ; : associated ( addr -- nfa of word containing address ) begin begin  ( Smart Decompiler - Part Golf ) 0 variable left 0 variable indent 0 variable cpf 0 variable maxaddr 3 variable indent-step ' 0branch cfa constant 0brloc p 2+ ? ; : 'cfa ( -- ;name - compilation mode only ) [compile] [ [compile] ' cfa ] [compile] literal ; immediate swap - 1+ ; : 0strlit ( addr -- addr len ) chr " emit space dup 2+ dup 0type 0len chr " emit space ; : 1lit ( addr -- addr ) dup 2+ c@ . ; : 2lit ( addr -- addr )  -->( Smart Decompiler - Part Sicks ) : defend ( addr - addr t=end of defn ) dup @ dup 'cfa (;code) = over 'cfa quit = or over 'cfa ;s = or swap cfa? not or            -dup if dup 2+ c@ swap @ else 0 0 endif ; : dropflag ( -- ) flag if flag-start @ dup 3 + @ flag-start ! drop endif drop ; : ?gohere ( addrs addrl -- flag )  ( Smart Decompiler - Part Too ) : >addr ( f addr -- ) here 5 allot swap over ! swap over 2+ c! 0 over 3 + ! flag-start @ top item on the stack and terminates the loop if it is zero. The address addr and value n are used by the compiler to determine the extent of the loop and for error checking. WIDTH ( -- addr ) Variable User variablision result n3. he maximun length of a word that will be retained when a word's header is created in the dictionary. The value of this variable is normally 31. WORD ( c -- ) Parsing Used to parse out the next t  1- dup @ [ ' sayaddr cfa @ ] literal = until dup cfa? until cfa->pfa nfa ;  ' branch cfa constant brloc : ind ( -- ) left @ indent @ + spaces ; : ind+ ( -- ) ind indent-step @ indent +! ; : ind- ( -- ) indent-step @ negate -->( Smart Decompiler - Part Fayve ) : nameit ( cfa -- cfa ) ind dup @ dup cfa? if cfa->pfa nfa dup c@ 128 and if ." [compile] " endif id. else ." ?UNKNOWN? " sayaddr dup 2+ @ dup cfa cfa? if ." ' " nfa id. else dup cfa? if ." [ ' " cfa->pfa nfa id. ." cfa ] literal" else . endif endif ;  cpf @ 0= and over maxaddr @ u< not and ; : ?branch ( addr --  dup if over @ over @ 2dup < if 2drop 1 else = dup if drop over 2+ c@ over 2+ c@ u< endif endif else 1 endif rot rot 2drop ;  begin 2dup 3 + @ ?gohere 0= while 3 + @ repeat 3 + 2dup @ ( get old link ) swap rot ! ( set new link ) e that contains the maximun length of a word that will be retained when a word's header is created in the dictionary. The value of this variable is normally 31. WORD ( c -- ) Parsing Used to parse out the next taddr t=loc has branch ) dup @ dup 0brloc = swap brloc = or cpf @ 0= and ; : ?branchaddr ( addr -- addr addr ) dup 2+ dup @ + ; : markbegin ( addr -- ) 3 swap >addr ; : markthen ( add -->( Smart Decompiler - Part Tree ) : sayaddr ( addr -- ) base @ hex swap 0 5 d.r base ! ; : cfa->pfa ( cfa -- pfa ) 2+ ; : cfa? ( cfa -- t=cfa really is a cfa )  : dobuildsdoes ( cfa -- nfa) 2+ @ associated dup id. ; -->  indent +! ind ; : aind- ( -- ) left @ indent @ + indent-step @ - spaces ; : .v ( addr -- addr ) space dup 2+ @ 0 d. ; : .u ( addr -- addr ) space du endif ; : strlit ( addr -- addr len ) chr " emit space dup 2+ count dup 1+ rot rot type chr " emit space ; : 0len ( addr -- len ) dup 1- begin 1+ dup c@ 0= until  ion words to ensure that all modified buffers have been written out before the user exits the current session of Forth. If it is set to 1, then there are modified buffers, otherwise no buffers need to be flushed. USE ( -- add ( -- addr ) Variable Multi-cell variable (array) containing the initial values for the user area variables at compiler initialization time. The variables contained include DP, BASE, UABORT, THAW, UTRACE, VOC-LINK, FENC d must execute TRACE-OFF as its first command and exit via ;TRACE. VARIABLE ( n -- ) Defining Used in the form n VARIABLE to define a word whose runtime action is to place its address on the stack. That addr s to the vocabulary defined before it. The last vocabulary block in the chain will be the Forth vocabulary block which will have a 0 in its Pseudo-CFA. This is used by FORGET to ensure that all vocabularies are properly updated. VOCABU Variable Compiler Contains 0 if Forth is interpeting, 1 if Forth is compiling a colon definition. STDIN ( -- fcb ) I/O Returns the file control block associated with the standard input file when forth was invokedEAD_ to read len bytes from the file controlled by fcb into memory starting at addr. Usually, the value n returned by SYSREAD_ indicates the number of bytes read although in error cases it can not be trusted. SYSWRITE ( addr len fcb  for self sarting applications at boot time. THEN ( addr n -- ) Structured Compilation Only Used in the form IF ... THEN, or IF ... ELSE ... THEN to delimit the end of a conditional clause. IF uses addr and n for erroration. TRACE-OFF ( -- ) Tracing Disables the trace mechanism of the inner interpreter. TRACE-ON ( -- ) Tracing Enables the trace mechanism of the inner interpreter. The tracing actions that  single precision result u4 and remainder u3. U< ( u1 u2 -- f ) Comparison Compares unsigned single precision values u1 and u2 leaving a flag true if u1 to define a variable that resides in the User area. The value n indicates the ofE, WIDTH, and WARNING. UTRACE ( -- addr ) Variable Contains the Code Field Address of the user trace word. When tracing is enabled, if UTRACE is set to zero, then the standard default tracer will be invoked. This tess will point to the storage area for that variable and will have an initial value of n. VLIST ( -- ) Command Lists all the words in the CONTEXT vocabulary to the current output device. Pressing the RUN/LARY ( -- ) Defining Used in the form n VOCABULARY to define a vocabulary for a specific class of words. The vocabulary will be linked into the current chain of vocabularies. When invoked, the defined voca. STDOUT ( -- fcb ) I/O Returns the file control block associated with the standard output file when forth was invoked. STRING ( n -- ) Defining Used in the form n STRING to define a stri-- ) I/O Writes len bytes starting at addr to the file controlled by fcb. It calls the system routine SYSWRITE_ to do it and does not append a CR to the end of the data like PUTREC_ does. TERMBUFF ( -- addr ) I/O A checking and to set the limits of the clauses. Alternate word for ENDIF, may be used interchangeably. TIB ( -- addr ) Variable Contains the address of the Terminal Input Buffer from which the interpreter is to pthe interpreter performs are dependent on the value of UTRACE. TYPE ( addr len -- ) Output Outputs the the string at address addr for length len to the current output device. U* ( u1 u2 -- ud3 ) Aritthe Code Field Address of the error recovery word to be executed when an error occurs and WARNING is set to -1. Upon entry to the error word, the error number will be on the user stack. UNTIL ( addr n -- ) Structuredst recently accessed buffer to be set so that the buffer will be written back out to mass storage. Multiple calls to UPDATE do not reset the flag. UPDATE-FLAG ( -- addr ) Variable A flag used by the Mass Storage manipulatfset into the user area where the variable is located. The programmer does not specify an initial value for a User variable. USER-AREA ( -- addr ) Variable Returns the address of the start of the user area. USER-CONSTracer simply prints the name of each word being executed as long as any shift key is held down. Otherwise, UTRACE contains the Code Field Address of a word to be executed between each word in the code being traced. The user trace worSTOP key will terminate the list while CONTROL will slow it down. VOC-LINK ( -- addr ) Variable Points to the Pseudo-Code Field Address of the Pseduo block of the most recently defined vocabulary. This CFA in turn pointbulary will set the CONTEXT pointer to point to its chain of dictionary entries. WARNING ( -- addr ) Variable Variable that controls the action the system takes when an error occurs. WHILE ( addr n -- addr nng variable with the name that can contain a string up to n bytes long. SWAP ( n2 n1 -- n1 n2 ) Stack Exchanges the top two items on the stack. SYSREAD ( addr len fcb -- n ) I/O Calls the system routine SYSRddress of the terminal input buffer. ( 82 bytes ) THAW ( -- addr ) Variable Contains the CFA of a word to be executed after a Forth Cold Start. Should NEVER be zero; the default is the CFA address of ABORT. Can be usedarse its commands. Normally it points to termbuff, but is changed for executing strings. TOGGLE ( c addr -- ) Memory Exclusive-ORs the byte at address addr with the byte value c, leaving the result in the same memory lochmetic Multiplies unsigned single precision value u1 by u2 leaving the unsigned double precision result ud3. U/ ( ud1 u2 -- u3 u4 ) Arithmetic Divides unsigned double value ud1 by unsigned single u2 leaving the unsigned Compilation Only Used in the form BEGIN ... flag .. UNTIL to form a structured loop. It compiles in a 0BRANCH which at execution time takes the top value from the stack and reiterates the loop if the value is a zero. The address  rompt string, which is displayed using PROMPT @ COUNT TYPE - if prompt is zero then there is no prompt. QUERY ( -- ) Terminal I/O Reads a line from the screen and places the characters in TERMBUFF. Also, IN is set  ed. It will never terminate ( unless called again ) until Forth itself terminates. R ( -- r ) Stack Copies the top item on the return stack to the parameter stack. R/W ( addr n flag -- ) Mass St nto the top of the dictionary. RELEASE-DISK ( n -- ) Mass Storage Releases drive n from use by Forth, closing the relative file ( Forth-disk ) opened by the OPEN-DISK command. REPEAT ( addr n addr n -- ) Compile  e! RP@ ( -- addr ) Stack Returns the address of the top item on the return stack. S->D ( s -- d ) Numeric Converts a single length integer to a double length integer by extending the sign thruric output string if n is negative. SMUDGE ( -- ) Dictionary Flips the smudge bit in the last word defined. If the smudge bit is set the word will appear in a VLIST but cannot be used or forgotten. While a word L will indicate the number of digits to the right of the rightmost decimal point. Otherwise, DPL will be set to -1. NUMERAL ( n -- c ) Numeric Output Converts the value n to the single corresponding ASCII character c r as the default prompt. OPEN-DISK ( addr len n -- ) Mass Storage Allocates forth drive n to the file whose name is at addr for length len. If the drive already has a file allocated to it, then that file is automatically ren values n1 and n2 leaving result n3. OUT ( -- addr ) Variable Variable containing the number of characters EMITTED since the last carriage return. Backspaces and other control characters count as characters. OUTay be used but should not be relied upon for saving information. PFA ( nfa -- pfa ) Dictionary Returns the PFA of a word, given it's NFA. PICK ( nk ... n1 k -- nk ... n1 nk ) Stack Given k on the top of the soutput device. It is initialized by COLD to whatver name is stored in PRINTER-NAME. This is used by the printer extensions when creating any hardcopy output. PRINTER-NAME ( -- addr ) File I/O A string variable containing theto zero. A null is placed after the last non-blank character read from the screen. The File from which QUERY reads is controlled by the FCB contained in INPUT-FCB. QUERY DOES NOT check for EOF or errors when reading from the input file. QUorage Reads or writes buffer at addr from/to virtual block n according to flag where a true flag indicates reading. R0 ( -- addr ) Variable Contains the address of the initial value of the return stack. For the 6Immediate Terminates a BEGIN ... WHILE ... REPEAT block, causing a branch back to the word after BEGIN. Completes compilation of a BEGIN ... WHILE ... REPEAT by filling in the proper branch address and removng the compiler flags and addre the high order word. S0 ( -- addr ) Variable Stack Contains the initial value of the parameter stack. ( 88 hex ) SCR ( -- addr ) Variable Disk Contains the screen number of the last screen LISis being defined the bit is set. SP! ( -- cleared ) Stack Clears the parameter stack. SP@ ( -- addr ) Stack Returns the current value of the parameter stack pointer. This does not include the val regardless of the current base. OCTAL ( -- ) Numeric Output Sets the current numeric base to 8. OFFSET ( -- addr ) Variable Contains the current Mass Storage drive offset to determine the leased before the new one is allocated. Any updated buffers from any drive are flushed. OPENF ( addr1 addr2 -- fcb ) File I/O Calls the system routine OPENF_ to open the file whose name is given by the null terminated string at PUT-FCB ( -- addr ) Terminal I/O A variable used by the output routines EMIT and TYPE to contain the FCB of the file to which all I/O is to go. It is initialized to point to the standard output file by COLD. OVER tack, copies item #k from the top of the stack ( not counting k ) to the top of the stack. 1 PICK is DUP, 2 PICK is OVER. PREV ( -- addr ) Variable Variable containing the address of the most recently used buffer.  name of the default hard-copy device. It is opened by COLD and the resulting FCB is stored into PRINTER-FCB. PROMPT ( -- addr ) Variable If the value in PROMPT is non-zero, then PROMPT contains the address of the pIT ( -- cleared ) Interpreter This is the main word of the interpreter. If executed, it will clear both stacks, and start interpreting from the screen again, effectively interrupting whatever was executing when it was call502 & 6510 this is 01FF. R> ( -- r ) Stack Removes the top item from the return stack and places it on the parameter stack. REL, ( addr -- ) Dictionary Compiles a relative offset to addr isses. ROT ( n3 n2 n1 -- n2 n1 n3 ) Stack Moves the third item from the top of the stack to the top. ROTates the top 3 items on the stack. RP! ( -- ) Stack Clears the return stack. Use with carTed or EDITed. SET-CURS ( c l -- ) Terminal I/O Moves the cursor to line l column c on the video screen. Home is 1 1. SIGN ( n d -- d ) Numeric Output Puts a minus sign in the current formatted numeue of addr left by this SP@. SPACE ( -- ) I/O Emits an ASCII space character ( 20 hex ) to the screen. SPACES ( n -- ) I/O Emits n spaces to the screen. STATE ( -- addr )  current default drive. It is set to 256 * the current default drive. OK-PROMPT ( -- addr ) String Returns the address of a string which consists of the text OK followed by a carriage return. It is used by the interpreteaddr1 for the mode given by the null terminated string at addr2. If the open is successful, then an FCB for that file is returned, otherwise a 0 is returned. OR ( n2 n1 -- n3 ) Logical Performs a bit-wise inclusive or o ( n2 n1 -- n2 n1 n2 ) Stack Copies the second item on the stack to the top of the stack. PAD ( -- addr ) Miscellaneous Address of scratch pad string area used by numeric output words, also several other words. It m Ex: If 1 BLOCK returns A406 (hex) then PREV @ will return A404, because the 2 bytes of block identification are included. PRINTER-FCB ( -- addr ) File I/O A variable contining the file control block for the standard printing  LATEST ( -- nfa ) Dictionary Returns the Name Field Address of the most recently defined word in the context vocabulary. LEAVE ( -- ) Structured Used to cause early termination of a DO loop. containing other vocabularies or lexicons. Before any word in a lexicon can be referenced, the lexicon itself must be activated by invoking the lexicon defined. At that point, the bank associated with that lexicon will be selected. LF he single precision value n to be placed on the stack at runtime. LITERAL ( n -- ) Compilation Numeric or ( n -- n ) Execution Compiles the value n into the current definition if the interpreter is in the compilation n -- ) Stack Moves the top value from the user stack to the return stack. ? ( addr -- ) Numeric Output Displays on the current output device the value ( in the current base ) of the contents of the sues error n if flag is true (1). ?EXEC ( -- ) Error-check Issues error 12 if the FORTH interpreter is not in the execution state. ?PAIRS ( n2 n1 -- ) Error-check Issues error 19 if values n1 contents n of memory address addr. [ ( -- ) Compilation Immediate Puts the FORTH interpreter into the execution state. [COMPILE] ( -- ) Compilation Compilation Only Used to overide address addr and value n are used to delimit the extent of the loop and for compiler error checking. LOWDP ( -- addr ) Lexicon A variable used by the lexicon words to save the dictionary pointer when compiling into by unsigned single u2 producing unsigned double result ud4 and unsigned single precision remainder u3. MAX ( n1 n2 -- max[n1,n2] ) Arithmetic Returns the larger of two signed numbers on the stack. MESSAGE ( n -- ) hat message 4 will never print. MIN ( n1 n2 -- min[n1,n2] ) Arithmetic Returns the smaller of two signed numbers on the stack. MLEN ( addr -- n ) Strings Returns the maximum length n for a string variable ingle precision number on the top of the stack. NFA ( pfa -- nfa ) Dictionary Converts the Parameter Field Address of a dictionary entry to its corresponding Name Field Address. NL ( -- 13 )  It replaces the current index value with the limit value so that the loop will not re-iterate at the end of the loop. Note that it does not branch out of the loop. If LEAVE is not used within a DO loop, then the results are unpredictaA ( pfa -- lfa ) Dictionary Converts the Parameter Field Address of a dictionary to its corresponding Link Field Address. LIMIT ( -- addr ) Constant Returns the address of one byte past the end of mode. Otherwise it does nothing. LOAD ( n -- ) Mass Storage Causes the interpreter to take its input from screen n and to execute the Forth code on that screen as if it had been entered from the terminal. LOOP address on the top of the stack. ?COMP ( -- ) Error-check Issues error number 17 if the FORTH interpreter is not in the compilation state. ?CSP ( -- ) Error-check Issues error number  and n2 are not the same. It is used to ensure that the proper conditionals are paired at compilation time. ?STACK ( -- ) Error-check Issues error 1 if the stack has underflowed and error 7 if the stack has ovthe precedence of an immediate word and force it to be compiled into a definition instead of it executing when encountered. ] ( -- ) Compilation Puts the FORTH interpreter into the compilation state. current a lexicon. If the current vocabulary is not a lexicon, then the value of lowdp is meaningless. M* ( n1 n2 -- d ) Arithmetic Multiplies single precision values n1 and n2 producing a double precision result d. M/  Error Handling Outputs message number n to the current output device. If n is zero then no message is printed. If WARNING is set to 0 then the text MESSAGE # followed by the error number will be printed, except for message 1 whiat addr. The other string words will not let the string grow beyond this length. MOD ( n2 n1 -- n3 ) Arithmetic Returns the single precision remainder from dividing single precision value n2 by single precision value n1 Constant Returns the ASCII value ( 13 decimal ) of a carriage return. NOT ( f1 -- f2 ) Boolean Negates the flag f1 leaving f2=1 if f1=0 otherwise f2=0. NUMBER ( addr -- d ) Numeric Input Convertsble. LEXICON ( n -- ) Defining Used in the form n LEXICON to define a vocabulary for a specific class of words that resides in bank n. Unlike a vocabulary defined with VOCABULARY, lexicons are restricted from the Mass Storage buffers. LIST ( n -- ) Utility Outputs the contents of screen n to the current output device. LIT ( -- n ) Numeric Execution Only Compiled by LITERAL to cause t ( addr n -- ) Loops Compilation Only Used in the form DO ... LOOP to build an iterative loop whose index value increments by one each time through the loop. It compiles (LOOP) into the current defintions. The 20 if the current stack top is not the same as the value in CSP as saved by !CSP. It is used to ensure that all structures are completed when a ; is encountered in defining a word. ?ERROR ( flag n -- ) Error-check Iserflowed. ?TERMINAL ( -- flag ) Terminal Input Returns a true (1) flag if the STOP key has been pressed by the user. Otherwise returns a false (0) flag. @ ( addr -- n ) Memory Returns the current the byte count preceded text at addr according to the current base leaving the result double precision value d and issuing error message 0 if any part of the number is unconvertable. If any decimal points were present in the number, then DP ( d n1 -- n2 n3 ) Arithmetic Divides double precision value d by single precision value n1 producing single precision result n3 and remainder n2. M/MOD ( ud1 u2 -- u3 ud4 ) Arithmetic Divides unsigned double ud1ch will print as STACK EMPTY. When warning is set to 1 then the message will be taken from the line corresponding to the message number relative to line 0 on screen 4 of drive 0. When warning is 2, the action is the same as for 1 except t . MONITOR ( -- ) Utility Invokes the builtin Waterloo monitor. Entering the Q command returns you to the Forth environment. NEGATE ( n -- -n ) Arithmetic Returns the two's complement of the s ouble or pairs of single precision values on the stack. 3 ( -- 3 ) Constant Places the single precision value 3 on the stack. 4 ( -- 4 ) Constant Places the single precision value  compiles in ;s, ensures that the definition is complete and puts the user back into execution mode. ;S ( -- ) Control Used in one of two manners. When loading and in execution mode, causes loading of the cur rue (1) flag if n2 < n1 in a signed comparision, otherwise it leaves a false (0) flag. <# ( d -- d ) Numeric Output Used in the form <# #S #> to set up the numeric output pointers for the numeric formatting words dictionary entry is built for the word being defined. For example, : DEFINE ... ; followed by DEFINE FOO would result in an entry for FOO being built and whose action at runtime is given by the DOES> part of DEFINE. =  Numeric Output Outputs the value of the top signed single precision value according to the current base with no leading spaces, an optional minus sign and a single trailing space. ." ( -- ) Outputsign in a field at least n1 characters wide, padding with spaces on the right if necessary. .S ( -- ) Debugging Prints the current contents of the stack non-destructively starting with the bottom of the stack ore /LOOP is paired with a DO and to determine the extent of the loop. /MOD ( n2 n1 -- n4 n3 ) Artihmetic Divides n2 by n1 leaving the integer result n3 and the modulus n4. 0 ( -- 0 ) Constant R) flag if n < 0, otherwise it leaves a false (0) flag. 0= ( n -- flag ) Relational Leaves a true (1) flag if n = 0, otherwise it leaves a false (0) flag. 0BRANCH ( n -- ) Control Executt Returns the single precision value 1 to the stack. 1+ ( n -- n+1 ) Arithmetic Adds 1 to the single precision value on the stack. 1- ( n -- n-1 ) Arithmetic Subtracts 1 from the single precc Divides the top value on the stack by 2. 2DROP ( n n -- ) Stack or ( d -- ) Removes the top double precision or top two single precision values from the stack. 2DUP ( n2 n1 -- n2 n1 n2 n1 ) 4 on the stack. : ( -- ) Defining Compilation Only Used in the form : ... ; to define as an executable FORTH secondary and to enter compilation to construct the body of the word. It crearent screen to terminate. When executed from within a definition, causes the current defintion to terminate and control to transfer to the calling word. ;TRACE ( -- ) Control Used in the form : ... ;trace  #S, #, SIGN, and HOLD. It does not affect the double precision number to be formatted. << ( n2 n1 -- n3 ) Logical Performs n1 logical shift left operations on value n2 leaving the result n3. If n1 is zero then no shi ( n2 n1 -- flag ) Relational Returns a true (1) flag if n1 = n2 otherwise leaves a false (0) flag. > ( n2 n1 -- flag ) Relational Returns a true (1) flag if n2 > n1 otherwise leaves a false (0) flag Used in the form ." " to cause to be printed to the terminal when executed. In compilation mode it compiles (.") into the current definition along with the string to be printed. .LINE ( n2 n1 -- ) Mass Stn the left. / ( n2 n1 -- n3 ) Arithmetic Divides n2 by n1 leaving the integer result n3 = int(n2/n1) /LOOP ( addr n -- ) Compiling Compilation Only Used in the form DO ... /LOOP to construct a loeturns the 16 bit ( single precision ) value zero. 0" ( -- addr) String Immediate Used in the form 0" " where is a constant string. Returns the address of the string, suitable for passing to 0TYPE ion Only Used to implement the conditional branches to support IF, WHILE, and UNTIL. It removes the top value on the stach and transfers control to the address compiled into the dictionary following the 0BRANCH if the value n is zero. Oision value on the stack. 2 ( -- 2 ) Constant Returns the single precision value 2 to the stack. 2* ( n -- n*2 ) Arithmetic Multiplies the top number on the stack by 2. 2+ ( nStack or ( d -- d d ) Duplicates the top double or top two single precision values on the stack. 2SWAP ( d2 d2 -- d1 d2 ) Stack or ( n4 n3 n2 n1 -- n2 n1 n4 n3 ) Transposes the place of the top two dtes an entry for in the CURRENT vocabulary and resets CONTEXT to the same vocabulary. ; ( -- ) Defining Compilation Only Used in the form : ... ; to terminate the definition of . It to terminate the definition of a user defined forth trace word. It compiles in (;trace), ensures that the definition is complete and puts the user back into execution mode. < ( n2 n1 -- flag ) Relational Leaves a tft operations takes place. If n1 > 15 then n3 will be zero. so that when the defining word is executed, a . >> ( n2 n1 -- n3 ) Logical Performs n1 logical shift rights on value n2 leaving the result n3. If n1 is zero then no logical operations will be done. If n1 is > 15 then the result n3 will be zero. >R ( orage Causes line n2 relative to line 0 of screen n1 to be printed without any trailing blanks. .R ( n2 n1 -- ) Numeric Output Outputs the value of signed single precision value n2 with an optional leading minus op whose index and limit values are unsigned. The increment value for the loop is specified on the stack as in HEX FFFF E800 DO ... 4 /LOOP which creates a loop that goes from E800 to FFFE in increments of 4. addr and n are used to ensu or other system routines. If used in the immediate mode, the string will be copied to PAD. In compilation mode, the string is compiled into the dictionary using (0"). 0< ( n -- flag ) Relational Leaves a true (1therwise it transfers control to the instruction immediately past the address. 0TYPE ( addr -- ) Output Outputs a string starting at addr and terminated by a null (0) byte. 1 ( -- 1 ) Constan -- n+2 ) Arithmetic Adds 2 to the single precision value on the stack. 2- ( n -- n-2 ) Arithmetic Subtracts 2 from the single precision value on the stack. 2/ ( n -- n/2 ) Arithmeti -- d2 addr2 ) Numeric Input Converts the ASCII text number starting at addr1+1, using d1 as an initial converted value, multiplying it by the current base for each digit converted. The conversion is done according the the current base, t n1 -- n5 n4 ) Arithmetic Multiplies n2 by n3 producing an intermediate double precision result which is divided by n1 to leave the result n4 and the modulus n5 + ( n2 n1 -- n3 ) Arithmetic Adds n2 to n1 leaving  ( n2 n1 -- n3 ) Arithmetic Applies the sign of the top value n1 to the second value n2. If n1 is negative then n3 will be the negated value of n2, otherwise n3 will be equal to n2. +BUFF ( addr1 -- addr2 flag ) Mass St n (+LOOP). addr and n are used by +loop to ensure that it is paired with a DO and to determine the extent of the loop. , ( n -- ) Dictionary Places the value n at the top of the dictionary, incrementing the - 0 ) Duplicates the top item on the stack only if it is non-zero. -FIND ( -- 0 ) Dictionary or ( -- nfa len 1 ) Locates the entry in the dictionary that corresponds to the next word in the input streemich causes the PFA to be compiled into the dictionary if Forth is in compile state. ( ( -- ) Compiling Immediate Used in the form ( ) to cause to be taken as a comment by the outer interprete It is compiled into a definition by +LOOP. (.") ( -- ) Output Execution Only Compiled by ." into a definition to print a constant string. (/LOOP) ( n -- ) Loops Execution Ong word by ;CODE to indicate the start of the machine language portion of the defining word. When executed, it puts the address of that machine language code into the CFA of the most recently defined word and terminates execution of the defincurrent session of FORTH without releasing any disks or flushing any buffers. (DO) ( n2 n1 -- ) Loops Execution Only Compiled by DO to indicate the start of a loop. When executed it takes the top two items ontherwise only a false (0) flag is returned. (LINE) ( n2 n1 -- addr len ) Mass Storage Returns the address addr and length len of line n2 relative to line 0 of screen n1. The length will always be 64. (LOOP) ( -- ) erminating the conversion when an unconvertable digit is reached, leaving address addr2 pointing to that digit and d2 as the final result of the conversion. * ( n2 n1 -- n3 ) Arithmetic Multiplies n1 by n2 leaving the the result n3 = n2+n1. +! ( n addr -- ) Memory Adds n to the current value at address addr. +$ ( addr2 len addr1 -- ) Strings Concatenates the string at address addr2 for length len in front of the curorage Advances buffer pointer addr1 to the next buffer returning flag indicating whether or not the new pointer addr2 is the same as the buffer pointed to by PREV. +LOOP ( addr n -- ) Compiling Compilation Only  dictionary pointer by 2. - ( n2 n1 -- n3 ) Arithmetic Subtracts n1 from n2 leaving the result n3 = n2-n1. --> ( -- ) Loading Immediate When encountered on a screen being loaded, cause. If a match is found, it leaves the nfa of the first entry that matches along with the length byte from that entry and a true (1) flag to indicate success. Otherwise it leaves a false (0) flag. The search is done first on the CONTEXT r. (") ( -- addr len ) Strings Execution Only Compiled by " into a definition to leave the address addr and length len of a constant string, suitable for TYPE. (+LOOP) ( n -- ) Loops ly Compiled into a definition by /LOOP. It increments the current loop index by value n, exiting the loop when the unsigned loop index reaches or exceeds the unsigned loop limit. (0") ( -- addr ) Strings Execuing word. (;TRACE) ( -- ) Control Compiled by ;TRACE to indicate the end of a forth tracing word, passing control back to the inner interpreter so that the next word may be executed. (ABORT) ( -- )  the stack, n1 the initial index and n2 the limit, and moves them to the top of the return stack with the index on top. (FIND) ( addr nfa -- 0 ) Dictionary or ( addr nfa -- pfa len 1 ) Locates the first word in t Loops Execution Only Compiled by LOOP as a loop terminator. When executed it increments the current loop index by 1, terminating the loop when the loop index reaches or exceeds the loop limit. (NUMBER) ( d1 addr1 result n3 = n2*n1. */ ( n3 n2 n1 -- n4 ) Arithmetic Multiplies n2 by n3 producing an intermediate double precision result which is divided by n1 to leave a single precision result n4 = (n2*n3)/n1. */MOD ( n3 n2 rent string stored in the string variable at addr1 putting the result into the string variable. If the combined string is larger than the maximum length allocated in the string variable then it will be truncated on the right. +- Used in the form DO ... +LOOP for constructing a loop whose index increments by a value other than 1. For example, a loop that counts from 0 down to -5 would be coded as -5 0 DO ... -1 +LOOP. The termination conditions for +LOOP are given id the FORTH interpreter to immediately advance to the next screen to continue loading. -1 ( -- -1 ) Constant Returns the 16 bit value minus 1 . -DUP ( n -- n n ) Stack or ( 0 -and then on the CURRENT vocabulary. -TRAILING ( addr len1 -- addr len2 ) Output Adjusts the length len1 for a string at addr so that the length len2 reflects the string with all trailing blanks truncated. . ( n -- ) Execution Only Increments the current loop index by value n, exiting the loop when n is positive and the loop limit is reached or surpassed, or when n is negative and the loop limit is surpassed. Otherwise it continues the current loop. tion Only Compiled by 0" into a definition to leave the address addr of a null terminated constant string, suitable for 0TYPE and system routines. (;CODE) ( -- ) Defining Execution Only Compiled into a definin Error The user error handler word. It transfers control to the user word whose CFA is stored in UABORT. In the default system, it transfers control to ABORT. (BYE) ( -- ) Command Terminates the  he dictionary starting with the nfa given that matches the byte count preceded string at addr. If a match is found, then the pfa of the dictionary entry, along with the length/flag byte, is put on the stack along with a true (1) flag. O MPS, LDS, STS, CMPD, CMPY, LDY, STY, SWI2, SWI3, EXG, TFR, All of the above apply to their corresponding 6809 family op code with the comma removed. The following condition codes are defined: MI - minus PL  t this word NOT will over-ride the word NOT in the Forth vocabulary. Forth-like words that control program flow are: IF, ENDIF, THEN, ELSE, BEGIN, UNTIL, END, WHILE, AGAIN, and REPEAT, . A Simple Example: The following CODE word defines the Forth word ) ,U STX, ( and replace what used to be the second item ) PUSH JMP, ( and let push put the third item back on the ) ( stack at the top ) END-CODE INITIAL CONDITIONS - When a word defin The Y register (Forth Instruction Pointer) points to immediately after the Forth entry that invoked this code word. 2. Debugging Hints: --------- ------ If one follows the syntax rules exactly, he will have no problems when he assnes, you really only have to preserve the Y register. 2) Make sure you code constants to distinguish them from possible register conflicts. The best example woule be coding A (which the assembler took to mean the A register) when you reallure that he coded them correctly. If the above steps fail, then in all probability there is either a problem in the original design, or possibly there is a problem with the assembler itself. In either of these cases, the novice should consult an expert GLOSSARY -------- The following is a functional spec of each word in this implementation of Forth. It may also be used as a reference for the Forth programmer. It is not intended to be sufficent information to teach the begining Forth programmer the uTYPE. If used in the immediate mode, the string will be copied to PAD. In compilation mode, the string is compiled into the dictionary using (") . "" ( -- addr 0 ) String Defines a null string based at PAD with lenge number being formatted and leaving the address addr and length len of the final formatted string on the stack suitable for calling TYPE. It is typically used in the sequence <# #S #> TYPE to print the value of an unsigned double number the string stored in the string variable at addr1. If the combined string is too long to fit into the maximum space allocated for the string variable then it is truncated on the right to fit. $@ ( addr1 -- addr2 len ) Strin - plus/positive VS - overflow set VC - overflow clear CS - carry set CC - carry clear EQ - equal zero NE - not equal 0= - equal zero 0< - less than zero ( same as MI ) The logical operator NO ROT. (ROT is already defined in Forth and there would be no need to write such a code word; it is presented here only as an example.) CODE ROT 2 N,U LDX, ( get the second item ) 4 N,U LDD, ( get the third item - D is untoucheed by the Forth assembler is called by the inner interpreter, the user routine receives the machine in the following known states: The U and S registers point to the top of the PARAMETER and RETURN stacks respectively wheembles his words. However in the unfortunate event that he gets a syntax error while assembling, he can follow these steps to correct it. 1) Make sure you are saving the registers when doing a system call!!! Almost all of the reasonable system caly meant Decimal 10. 3) Compare the code written with the original design. This simple checking will eliminate over 80% of all errors. In doing so, one should look especially to ensure that all the correct conditionals are paired. 4)  before proceeding further. he assembler commands. Often one will leave off a comma from a structured statement and it will be interpreted as a standard Forth command. 5) Finally, one should carefully check each of the address modes to ensse of each word. ! ( n addr -- ) Memory Stores value n at address addr. !CSP ( -- ) Error-check Saves the current stack pointer for comparison by ?CSP to ensure that a definition is cth count 0. # ( d1 -- d2 ) Numeric Output Divides d1 by the current base, putting the character value of the modulus (digit) in the current numeric formatted output string and leaving the remainder d2 for further pr. #S ( d -- 0 0 ) Numeric Output Converts an unsigned double value d into a numeric formatted output string. See #> for usage. $! ( addr2 len addr1 -- ) Strings Stores the string at addr2 for length g Returns the current location and length of the string stored in the string variable at addr1 suitable for calling TYPE. ' ( -- pfa ) Dictionary Immediate Used in the form ' to return the parameter fT is available to complement the above functions. Even though the complement functions are available (for example, both carry set and carry clear) some programmers may prefer to use the NOT function. The code produced in either case is the same. Note thad in the ) ( rest of the routine so that PUSH will put ) ( this value onto the top of the stack ) 4 N,U STX, ( put the second item where it belongs ) X 1 PULU, ( pop the top item re both stacks grow down in memory. The X register points to the CFA of the current word being executed. Since this is a code word, the X register will point to your CFA. The X register does not have to be preserved. ls have a tendency to needlessly destroy the X and Y registers. PRINTF_ only destroys the Y register when it decides to scroll the screen. Since the X register is unimportant and the U and S registers are never destroyed by system routi Check the spelling of all the assembler commands. Often one will leave off a comma from a structured statement and it will be interpreted as a standard Forth command. 5) Finally, one should carefully check each of the address modes to ensield address of or to generate an error message if is not found in the dictionary. Note that this differs from the non-standard Brodie Tic which returns the CFA rather than the PFA. Also, understand that ' calls LITERAL , whomplete when the semicolon is encountered. " ( -- addr len ) String Immediate Used in the form " " where is a constant string. Returns the address and length of the string, suitable for passing to ocessing. It is typically used in the form <# # # #> where each individual # indicates a single digit in the output string. #> ( d -- addr len ) Numeric Output Completes formatted numeric output by dropping the doubl len into the string variable at addr1. It truncates the string if it is too long to fit into the maximum space allocated for the string variable. $+ ( addr2 len addr1 -- ) Strings Appends the string at addr2 for length len to end. The UNTIL, or END, requires the termination condition to be checked. In a standard assembler this would appear as: LABEL EQU * BNE LABEL While unde always paired with a general opcode. d) Combinations of structured constructs follow the rules given below. Any structured constructs may be combined with another as long as one of the constructs is completely contained within a subu s: BEGIN, ... WHILE, and WHILE, ... REPEAT,. This makes: BEGIN, ... IF, ... ENDIF, ... WHILE, ... REPEAT, legal, but makes: BEGIN, ... IF, ... WHILE, ... ENDIF, ... REPEAT, illegal because the IF, is inside the BEGIN follows the same syntax rules as the other constructs and may be contained within another contruct. By its Forth nature, the assembler is a macro assembler, with the full power of Forth available to it. The user should understand that while definind to do) for later use by the word defining the instruction. Thus any Forth words that do any of these things may serve as macros. Because the user never leaves the interpret state, any Forth word can be used at any time in the CODE definition. As exampes 3 NOP instructions to be assembled into the code at the point it is used. : -LSLD, 0 DO LSLB, ROLA, LOOP ; This Forth word, used in the form: n -INX, would cause some number n of LSLB ROLA instructions to be assemblere only very simple examples to help explain the concept. Several words are predefined for the convience of the Forth assembler programmer. BOT is equivalent to 00 N,U and is used in the form: BOT LDD, to reference the First word on the stack. The low reter. NEXT is a simple return point that terminates the word. It is used in the form: NEXT JMP, . Some code words will of course take arguments from the stack and wish to remove these from the stack. Two jump addresses are provided that drop one and twolso provided in the assembler. It is intended to be used to set the value of PREVIOUSLY DEFINED CONSTANTS to the current location in the dictionary so that the label can later be used as an address by other assembly words. It can be used in the form: , COMB, LSRB, RORB, INCB, TSTB, JMPB, CLRB, SUBA, CMPA, SBCA, SUBD, ANDA, BITA, LDA, STA, EORA, ADCA, ORA, ADDA, CMPX, JSR, LDX, STX, SUBB, CMPB, SBCB, ADDD, ANDB, BITB, LDB, r the Forth assembler it would be written as: BEGIN, EQ UNTIL, As with the others, the condition reverses in the translation. 6. Combining constructs- The syntnit of the other. For example: This is legal: IF, ... BEGIN, ... AGAIN, ... ENDIF, because the BEGIN, ... AGAIN, construct is completely contained inside the IF, and the ENDIF,. However: IF, ... BEGIN, ... ENDIF, ... WHILE, construct while the ENDIF, is not. Because of this nesting of constructs, one can also put a construct inside another like it. For example to have nested IF statements, one would write: IF, ... IF, ... ENDIF, g CODE words Forth stays in the interpret state and does not enter the compile state that colon ( : ) uses when defining words. 6809 instructions such as LDA, and STA, simply cause the proper op code to be added to the dictionary. Words which affect the les: 60 3 / # LDA, will perform the division of the hex numbers 60 and 3 and leave the result on the stack, this will then be assembled into the load immedate instruction. The same function would be served by 20 # LDA, id into the dictionary at this point. [Before defining such macros the user should set CONTEXT and CURRENT to ASSEMBLER so that the assembler vocabulary is searched and that the words being defined are added to that vocabulary. This may be donorder byte can be referenced by BOT LDA, while the high order byte can be referenced by BOT 1+ LDA, SEC works similar to BOT except that it references the second value on the stack. It is equivalent to 02 N,U. To terminate the run-time code of most Fo arguments from the stack, to save the programmer from coding these frequently used routines. These words are POP and TWOPOP respectively, used in the form: TWOPOP JMP, (After popping the words from the stack, these words go to NEXT .) An additional word 0 CONSTANT XYZ CODE .......... LABEL XYZ ................. XYZ JMP, ....... END-CODE Note that LABEL cannot be used by forward references. (In most cases the average Forth programmer will prefer the Forth Conditional constructs over the use o STB, EORB, ADCB, ORB, ADDB, LDD, STD, LDU, STU, NOP, SYNC, DAA, SEX, RTS, ABX, RTI, CWAI, MUL, SWI, ANDCC, ORCC, LEAX, LEAY, LEAS, LEAU, PSHS, PULS, PSHU, PULU, CMPU, Cax rules for combining constructs are very simple: a) Any opcode (general or inherent) may be included anywhere in the definition of a word. b) A conditional is always paired with a structured conditional. c) An address mode is , ... AGAIN, is illegal because the BEGIN, is inside the IF, ... ENDIF construct but the AGAIN, to match it is outside. BEGIN, ... WHILE, ... REPEAT, is not a special case for the syntax rules; It is treated as if you have two construct... ENDIF, and the assembler would automatically pair the outermost IF, and ENDIF, with each other and pair the innermost ones with each other. Anytime that the programmer pairs two constructs to form a new construct, this new constructmode of the instruction, such as # or ,X simply change the value of the variable MODE . And numeric data for the instruction, such as the 3 in 3 # LDA, or the address AB00 in AB00 JSR, simply place that information on the stack (as Forth would be expecten this case, this example simply shows Forth math is available at assembly time. BLUE # LDA, The constant BLUE returns a value on the stack used by LDA, : 3NOP, NOP, NOP, NOP, ; Not the most useful of macros, 3NOP, simply cause with the command ASSEMBLER DEFINITIONS. When complete, the command FORTH DEFINITIONS will return to the Forth vocabulary, or any desired vocabulary can be selected.] This ability to use other Forth words as macros is virtually limitless, the above arth CODE words, the programmer will wish to jump to the inner interpreter [NEXT] to begin interpreting the next word. Several constants have been defined as addresses that can be jumped to to terminate a CODE word in the proper way and reenter the interp is provided to avoid duplication of code in returning results on the stack from CODE words. By loading the value to put onto the stack into the D register and JMPing to PUSH, the value will be pushed onto the top of the user stack. The word LABEL is a f LABEL.) The Forth assembler defines the following 6809 family instructions: NEG, COM, LSR, ROR, ASR, ASL, ROL, DEC, INC, TST, JMP, CLR, NEGA, COMA, LSRA, RORA, INCA, TSTA, JMPA, CLRA, NEGB s LABEL ,PC LDX, LABEL [,PC] STX, e) Absolute and absolute indirect - Instructions directly addressing memory are the default when no modifier (such as ,DP) is given. Indirect requires a modifier of [N]. F , and U) the following modifiers exist Modifier Example Use Assembler Equivalent N,R 5 N,S LEAS, LEAS 5,S [N,R] 2 [N,S] LDD, LDD [2,S] ,R ,X U] ANDA, ANDA [A,U] B,R B,U SUBA, SUBA B,U [B,R] [B,S] JSR, JSR [B,S] D,R D,Y LEAY, LEAY D,Y [D,R] [D,X] JMP, JMP [D TFR A,DP PSHS D PULS X,Y,U would be coded as: D Y EXG, A DPR TFR, D 1 PSHS, X Y U 3 PULS, NOTE: A, B, D, and CC are valid hexadecimal num UNTIL, we can generate 3 more giving a total of 8 possible combinations. The syntax and use for each of these combinations is presented below: a) IF, ... THEN, IF, ... ENDIF, - This construct represents the simplest of program flow e that the conditional changes when coding the IF, statement and there is no label necessary in the Forth code. The reason the conditional inverts is because the IF, inverts the condition given it before assembling it into th f two alternate paths is to be taken based on a condition. It is an extension of the basic IF statement above with the ELSE clause added. The equivalent code for this construct in a standard assembler would be: the standard assembler. c) BEGIN, ... AGAIN, - This construct is used whenever you want to build an infinite loop into your code. In standard assembler this would appear as: LABEL EQU * EQ WHILE, REPEAT, Note that the condition reverses in the translation from the standard assembler to Forth; or example: LDD $EFFC STX LABEL LDY [$0220] STD [LABEL] would be coded in Forth assembler as EFFC LDD, LABEL STX, 0220 [N] LDY, LA  LDD, LDD ,X [,R] [,U] STD, STD [,U] ,--R ,--S STY, STY ,--S [,--R] [,--Y] LDX, LDX [,--Y] ,R++ ,S++ ADDD, ADDD ,S++ ,X] g) Register Instructions - The EXG and TFR instructions take the two register in front of the instruction. The Stack push/pull instructions want the registers followed by the number of registers. For all of these i bers!!! If you use constants that are equal to those values you MUST put a 0 in front of that constant to distinguish them. For example: A means the A register while 0A means the value 10 Decimal. 5. Structured statements- Th constructs. It is used around a section of code to be executed only under certain conditions. The IF, statement requires that a condition be specified for which the code is to be executed. BNE LABEL e dictionary. This is done to allow the programmer to code the condition for entering the then clause, which is the more logical form, instead of him having to code the non-entry condition as in the standard assembler. Because THEN  BNE LABEL BRA LABEL2 LABEL EQU * LABEL2 EQU * Under the Forth assembler, the programmer would have written: y code> BRA LABEL while in the Forth environment, you would write: BEGIN, AGAIN, Although BEGIN, is used in the other loop construc ranch out of the loop, otherwise it will execute the code between the WHILE, and the REPEAT, before going back to the BEGIN, to check the condition again. This construct would appear in standard assembler as: LABEL EQ this is due to WHILE, negating the condition checked. e) BEGIN, ... UNTIL, BEGIN, ... END, - This construct is used to set up a loop whose loop body is always executed first and the condition for termination is checked at the BEL [N] STD, f) Indexed instructions - This is where the Forth assembler has the most options. Since indexed instructions can be fairly varied, some general codes have been built in. For each of the indexing registers (X, Y, S  [,R++] [,U++] SUBD, SUBD [,U++] ,-R ,-S CLR, CLR ,-S ,R+ ,S+ TST, TST ,S+ A,R A,X LDX, LDX A,X [A,R] [A, nstructions, the names to use to indicate the registers is: D A B X Y U S PC CC and DPR DPR is used because it interferes with DP that is integral to the Forth compiler. To Illustrate: EXG D,Y e remaining group of assembler words are the structured statements which implement the high-level language constructs. The 10 structured statements can be used in 5 unique combinations. Due to the synonyms for THEN, for ENDIF, END, and  LABEL EQU * Under the Forth assembler this could be written: EQ IF, ENDIF, The two important things to notice ar , and ENDIF, are synonyms, it doesn't matter how one codes the construct because the same results are produced. b) IF, ... ELSE, ... THEN, IF, ... ELSE, ... ENDIF, - This construct represents a program flow construct where one o  EQ IF, ELSE, ENDIF, Again note that the Forth assembler code does not need the labels required by ts, this is the only construct that allows the use of AGAIN,. d) BEGIN, ... WHILE, ... REPEAT, - This construct is used when you set up a loop that has a termination condition that is checked before the body of the loop is execu U * BNE LABEL1 BRA LABEL LABEL1 EQU * Under the Forth assembler, you would code: B! void any potential problems with nulls or other characters that may be in the new buffer. The command SCLR provided with the Pseudo-Editor will perform this function, taking the number of the screen to be cleared from the top of the stack. SCLR may also ! screen will be loaded from disk if necessary, then displayed on the edit screen. The edit display mode will show the screen inside an editing frame to show the physical shape of it. Additional information on the display are a status line and the buffe! F3 - Puts the current line down into the visual buffer F4 - Moves the cursor down one line, wrapping to the top of the screen if you go off the bottom. F5 - Enters the command mode ( currently unimplemented ) F6 - Copi! a drive then it will advance you to screen 1 of the next drive. The STOP key exits the full screen editor, copying the edited text to the disk buffer. A Shifted STOP (RUN) exits the full screen editor, copying the edited text to the disk b!SuperFORTH Index to manual7: 1. THE ASSEMBLER 2. DEBUGGING HINTS -------------------------------------------------------------------------------- 1. THE ASSEMBLER ------------- When writing an a!o this coding in a time-effective manner. To allow easy translation of a Forth word into assembly language, the Forth assembler includes all the high-level language constructs found in the standard Forth environment, using the same naming conventions bu!words such as USER, VARIABLE, and DOES> but will rarely if ever be used by the average Forth programmer. When either CODE or ;CODE is executed, it sets the programmer into the assembler environment in which he stays until executing the E!hat the RPN syntax dictates that the order of operands be reversed. 3. Inherent opcodes- The words correspond to all the implied addressing mode machine language instructions. They are used by just naming them. For example: To generate th!) Accumulator- Any instruction accessing the accumulator such as: ASLB would be written in Forth as: ASLB, b) Immediate- Any instruction using immediate data such as: LDA #3 would be writte!ecimal. Unlike the standard assembler, the Forth assembler requires you to explicitely state that you want direct page addressing. d) PC relative addressing - Instructions using PC relative addressing are marked similary to Dir!be used to erase an entire screen of information. 2. THE FULL SCREEN EDITOR --- ---- ------ ------ In addition to the Pseudo-Editor, a Full Screen Editor is provided. This editor allows the programmer to edit an entire screen of text at one time and!r where you can hold lines. The screen can be edited as with the Commodore screen editors by typing over old data, positioning with the cursor keys, and the use of the insert/delete key. In addition, supplemental functions are provided by the shifted fu!es the visual buffer onto the current editing line destroying what was on that line. F7 - Moves the cursor up one line wrapping to the bottom of the screen if necessary. F8 - Does nothing F9 - Saves the curren!uffer and then immediately loading the contents of it via the LOAD command. The RVS key recovers the current screen, abandoning all changes since the text was last saved to the disk buffer. If you wish to leave the editor without saving any changes (si!pplication program, you may find that a word written as a standard Forth colon defined word does not execute fast enough to suit your specific needs. One way in which you could speed it up is to completely restructure your code if possible to get as much!t appending a comma to the name to distinguish it as an assembler word. 1. Forth interface- The words are the ones necessary to enter the assembler environment. They are used in the form: CODE ... END-CODE where is the word!ND-CODE word at which point his word will be finished and he can test it. 2. Basic syntax- When you use a standard assembler, you are forced to place only one assembly language instruction per line, but in Forth you may put them any way yo!e machine language instruction to return from a subroutine: RTS You would write: RTS, and likewise with all the other inherent opcodes. 4. General opcodes- The basic syntax for a general opcode in the Forth assem!n in Forth as: 3 # LDA, c) Direct page - Instructions directly accessing memory through the DP register (or zero page as the SuperPET uses it) such as: STA $32 would be written as: 32 ,DP S ect page except that ,PC is used instead of ,DP. If you want an indirect PC relative address then you use [,PC] instead. For example: LDX LABEL,PCR STX [LABEL,PCR] would be coded in Forth assembler a! provides a number of editing options by means of the function keys on the SuperPET in a manner similar to the standard Waterloo editing functions. The Full Screen Editor is evoked by the command: n EDIT where n is the screen to be edited. The required!nction keys: F0 - Inserts a blank line at the current line, copying the last line (pushed off by the insert) into the visual buffer. F1 - Does nothing F2 - Deletes the current line and copies it to the visual buffer !t screen and moves to the previous screen to edit. If you are editing screen #1 then this key does nothing. F. - Saves the current screen and moves to the next sequential screen to edit. If you are editing screen 8191 of nce the last save) type a RVS and then a STOP key. The CLR key will erase the contents of the entire screen leaving you with a blank screen. Pressing the RVS key will recover whatever text was last saved to the disk buffer. he edited text to the disk b! speed as possible, but this is not always an effective solution. The most viable solution would be to recode the word in machine language. This is very feasible because Forth interfaces well with machine language. The Forth assembler provides a way to d! being defined and the ... indicates other arbitrary assembler code. The other form is: ;CODE ... END-CODE where the ;CODE corresponds to the DOES> (1) part of a defining word. This latter construct is used in the definition of !u please due to the parser used. To help separate assembly language statements for readability, all Forth assembler opcodes and statements end with a comma. Also when translating from a standard assembler to a Forth assembler remember t!bler is very close to that for a standard assembler, but the operands are given in reverse order with a comma appended to the end. To illustrate how this is done, we will treat each of the machine language addressing modes separately: a! TA, Note that the dollar sign required by the standard assembler to represent hexadecimal values is not used by the Forth assembler. This is because the implicit base for all numbers used in the Forth assembler is 16 or hexad" uch faster than looking up an error oneself. The command: 1 WARNING ! selects this mode of error control. Yet another mode available to the user is selected by 2 WARNING ! This mode functions the same as the previous mode with the exce" sh to perform : WARNING @ saving the previous value of WARNING on the stack. This can then be restored to WARNING when the load is finished. Also, as this mode does use the other errors on screen 4; it should not be selected if a FORTH-DISK is not" FORTH will normally expect the word run here to end by calling either QUIT or ABORT (QUIT is normally preferred, ABORT does a warm start). It is extremely unnatural for the routine to try to continue with the running of the program. If the user really b" mode is used, MESSAGE is treated as if the value contained in WARNING were 1 [ ONE ]. Of special interest is the use of the word ERROR with 0 as an argument (on the stack). In all cases except when WARNING is set to zero, this special case will cause no"SuperFORTH Index to manual6 1. THE PSEUDO EDITOR 2. THE FULL SCREEN EDITOR -------------------------------------------------------------------------------- 1. THE PSEUDO EDITOR --- ------ ------ Two editors are "command PEDIT with the screen number to be edited on the stack. Thus a command: 50 PEDIT will set up screen 50 ( in the current base ) to be edited on will set up screen 50 ( in the current base ) to be edited on the FORTH-DISK. (A FORTH-DISK mus"to the line to be edited, type in your changes, and hitting return. All SuperPET line edit functions work, thus you can insert or delete letters with the insert/delete key. Lines can be moved as in Basic simply by changing the line number and then hittin"s taking place is to type the HOME key and then the RETURN key. HOME, of course, homes the cursor, placing it on this edit command line. RETURN then causes this line to be taken as a command and the screen is refreshed. The pseudo editor does not use up" to it as a argument (on the stack as in: 50 SCLR). Finally, you may have noticed that though we are doing standard Forth commands, the OK prompt is not being written on the screen (which would conflict with the text, and be taken as text itself the nex" will happen automatically if the buffer space is needed for a different block; it can be forced by the command FLUSH. If a buffer is marked for update, the BYE command will give an error and not leave FORTH. (BYE) can be used if desired to leave SuperFO"ption that MESSAGE #4, which warns that a definition of a word already exists, is not given. This mode may be selected during a load that will deliberately redefine an existing word, keeping an unwanted MESSAGE from being displayed. In mode 1 the warning" open as disk 0; this should be no problem, as it is intended to be used mainly when loading from a FORTH-DISK. The final error mode available is to let the user handle his own ERROR processing. This mode is selected by setting WARNING to -1. BEFORE do"elieves he has dealt with an error in a way that will allow him to continue processing, one entry from the RETURN STACK must be removed, as the routine which calls the user ERROR handler never expects a return and has no code following the call. R> DROP " message to be displayed and normal error cleanup to take place; it is intended for use where a user wishes to print his own message from the program (one not on screen four) and then use standard Forth to do his error cleanup. This user control of ERRO"provided with SuperPET SuperFORTH. One is a full screen editor, covered in the next section. The other is a simple editor we call the "Pseudo Editor". This editor consists of just a few commands and relies on Commodore's own screen editor functions to le"t be open to access the screen.) The contents of the screen will be displayed, and the screen will be ready to be edited. The major command used in the Pseudo Editor is the double underline ( __ ). It is defined as a word which takes a number and place"g return. The Double underline will accept a blank line (null string) to clear the line. This command is the heart of the Pseudo Editor. The double underline command will limit each line to the maximum size of 64 and give a TRUNCATED warning if the lin" all lines of the video screen when editing. The remaining few blank lines at the bottom of the display will allow the user "scratch space" where immediate Forth commands may be used. This may well be the strongest feature of the Pseudo Editor; the user"t time the line is edited). Instead, the PEDIT command turns off the OK prompt. The ENDEDIT command simply turns on the OK prompt again. ENDEDIT has no other effect than to restore the prompt. Since the word endedit is displayed after the last line show!RTH but in that case the updated information will not be written to the disk. The preferred resolution to this event is to give the command FLUSH and then re-issue the BYE command. Before any screen is first used, it should be cleared to all blanks to a" NOT UNIQUE is printed for 4 MESSAGE . If exception 4 is taken with the word ERROR, rather than MESSAGE, then an error indication will still be written from line 4 of screen 4 if WARNING contains a value of 2 . Before selecting this mode the user may wi"ing this, you should have placed the CFA (Code field address) of a word you wish to be executed on an ERROR into the user variable UABORT . This routine will find the error code on the stack as it starts to run. As this code is run on an ERROR condition,"will do this and should therefore be placed in any such ERROR handler definition. We stress again, this is not a normal way for an user ERROR routine to terminate. Also, please note, this entire discussion relates to ERROR only, not MESSAGE. When the -1 KRS is an advanced feature, seldom if ever used by most Forth programmers. 1 [ ONE ]. Of special interest is the use of the word ERROR with 0 as an argument (on the stack). In all cases except when WARNING is set to zero, this special case will cause no"t the user edit a screen. Despite its simplicity, it is a very useful editor, and some users may elect to use the Pseudo Editor almost exclusively. Once loaded (From screen # 2 on the FORTH-DISK on the release disk), the Pseudo editor is invoked by the "s the string that follows it into that line number on the current screen. As each line on the screen is listed with a line number and a double underline proceding it, that line can be edited by simply using the SuperPET screen edit functions to position "e was too long. The very first line of the screen will be written to indicate the screen being edited followed by the word PEDIT. This is the same command that is used to start the editor. Thus a very simple way to have the screen refreshed as editing i" can freely move between the editor at the top of the monitor and the interactive area at the bottom, testing things as they are written. A command SCLR is also added to FORTH when the Pseudo Editor is loaded. This command simply clears the screen given" n, you can simply move the cursor to that line and press RETURN when you are through editing. The Pseudo editor commands, of course, properly set update if (and only if) a change is made to the text; marking the buffer to be rewritten back to disk. This# will serve as a flag bit when applications are built. The first byte of the NFA therefore takes this form: +---+---+---+---+---+---+---+---+ ! I ! S ! r ! name-length ! +---+---+---+---+---+---+---+---+ The next# tations. Both the LFA and the CFA are two bytes in length. The PFA may be of any size, dependent upon the function of the word it serves, including 0 bytes in length. 6. TRACE FUNCTIONS ----- --------- Trace functions have been built into this vers# run; otherwise the contents of UTRACE are taken as the CFA of a user routine to be run. The standard system trace routine simply prints the name of each word that is being called by NEXT. It then waits for the user to # y scroll past before anything else may be done. It is usually much more pratical to define the following word: : TRACE [COMPILE] ' CFA TRACE-ON EXECUTE TRACE-OFF ; This word will then let the user trace any word. It may be used in the form: TRACE word # to show some of the features of SuperPET SuperFORTH and to assist the new user in learning Forth. When loaded, STACKVIEW puts the user in a modified interpreter that displays the contents of the stack after every command. The topmost 7 (if that many a#f you type TRACE Forth will pause before the execution of each word invoked by and show you the contenst of the stack as well as the word it is to execute next. Pressing any key causes it to go on to the next word. This provides a# 1. ERROR MESSAGE CONTROL ----- ------- ------- Though by nature Forth does little error checking, the user does have control over the error handling that is provided. This control is provided thru the variable WARNING . The value of WARNING controls# FULL STACK 8 DISK ERROR 9 ERROR 9 10 ASSEMBLER CONDITIONAL PAIRING ERROR 11 ERROR 11 12 LEXICONS NOT ALLOWED IN LEXICONS 13 CURRENT AND CONTEXT BOTH LEXICONS 14 ERROR 14 15 ERROR#ORTH by the command: 0 WARNING ! If rather than 0 the value of WARNING is set to 1 [one], Forth will automatically look up an error for the user. These errors are expected to be found one per line on screen 4 of the currently opened FORTH-DISK. Th#rrors from a screen will require that the screen be brought into memory if not already there, so there may be a slight speed trade-off for the added utility of having your error code looked up for you; the choice is up to the user. If an error requires s# bytes contain the name (in ASCII) of the word being defined, one per byte. The entire name is stored, unlike some Forth implememtations that only store the first three letters. Also, no high order bits are set; some Forths set the high order bit of the #ion of Forth. Trace allows the program to take special action each time the inner interpreter (NEXT) is about to execute a word. The words that allow the user to control the trace function are as follows: TRACE-ON Turns on Trace Mode, each time# press RETURN. If you type any character and press RETURN, then the default trace will enter th Waterloo monitor. A user trace routine should be exited by: ;TRACE to reenable tracing and continue to execute the current word#. Special attention was paid to the design of the inner interpreter in this version of Forth to allow tracing to be acomplished with no extra no-ops in the interpreter when trace is not in use; there is no speed penalty for having trace in the system wh#re even there) items on the stack are displayed in reverse video in the upper right hand corner of the screen. Because they are on the screen, STACKVIEW should not be used with the pseudo editor. To exit from stack view, simply type QUIT or cause any e#n excellent opportunity to see exactly what is going on in a word and is useful for debugging words that 'blow the stack'. An adventuresome programmer may wish to modify the tracing facilities offered on the stackview screen to his own personal tastes. # what will happen when an error occurs. If the value of WARNING is set to 0 [ Zero ] (the normal start up state of FORTH) , then any error that FORTH detects will cause an error message to be printed with an error number. These error codes indicate the c# 15 16 ERROR 16 ( NEVER USED ) 17 COMPILATION ONLY 18 EXECUTION ONLY 19 CONDITIONALS NOT PAIRED 20 DEFINITION NOT FINISHED 21 IN PROTECTED DICTIONARY 22 USE ONLY WHEN LOADING 23 ERRO#us if a user wishes to use error mode 1 it is important to be sure both that a FORTH-DISK is currently opened (as disk 0) and that screen number 4 of this FORTH-DISK has the error messages that the user wishes to be displayed, one per line, as on the rel"creen 4 to be brought into memory it may also cause another block on the FORTH-DISK to be written out to disk (or forgotten if the update flag is not set), which may have to be reloaded later. In general this is all transparent to the user and is still m#last byte. Following the name is one final byte which contains the length of the name plus one. This byte makes it extremely easy to traverse the name field in the reverse direction. The Link, Code, and Parameter Fields are standard among Forth implemen# NEXT is about to call a word the trace routine will be entered. TRACE-OFF Turns off Trace Mode. UTRACE User variable that controls the action of the trace function. If zero, the standard system default trace routine is#. The user trace routine will find the CFA of the word being traced on the RETURN STACK . If TRACE-ON is given as a regular Forth command, the user will find that he is tracing the outer interpreter and that quite a bit of information ma#en it is not in use. Trace is obviously an advanced feature and may not be needed by all Forth users. A good example of using the trace features in Forth is found in the STACKVIEW words described below. 7. STACKVIEW --------- STACKVIEW is included#rror (such as typing FLURB or any other command not likely to be in the dictionary). To return to it simply type STACKVIEW. You can enter and exit the mode at will. An additional feature provide by loading the STACKVIEW screen is its trace facility. I Some possibilities include printing the depth of the return stack, the location being executed, or even 'watching' locations modified by an application. The variations are endless. Pressing any key causes it to go on to the next word. This provides a#ause of the error. These codes can be interpreted as follows: 1 STACK EMPTY 2 DICTIONARY FULL 3 HAS INCORRECT ADDRESS MODE 4 NOT UNIQUE 5 BUFFERS NOT FLUSHED, USE (BYE) 6 DISK RANGE? 7 #R 23 24 FORWARD REFERENCE NOT RESOLVED These same messages are, of course, used for both MESSAGE and ERROR; we will use a lower case word "error" here to mean both MESSAGE and ERROR calls. The value of WARNING can of course be set to zero in F# ease diskette. Of course the user is free to change the wording of any such error messages. There are also slots for some messages that can be defined by the user; these simply print the error number on the release diskette. Of course, displaying such e$ &-PERF Enable and disable automatic skipping over page perforations. Not an essential printer feature but supported if available. &8LPI &6LPI Select the line height density. Used to allow f$ ode of at least 132 chars/line. If your printer does not support such a mode, then you may not use the WPRINT word described above, but by no means does it limit Forth. &NORMAL Revert to th$ hex) Function ------- --- -------- 0000 - 00ff Zero Page Ram 0100 - 3fff System Ram 0400 - 0480 System message buffer 0480 - 09ff System ram and stack space 0A00 - 0a5a Forth $ Video screen memory 9000 - 9FFF Bank switched ram/Lexicon area Bank 9 Decompiler Lexicon Bank 10 Full screen editor Bank 11 Forth Assembler A000 - E7FF System ROMs E800 - EFFF$mal programs and may be extended if necessary by changing the values of the contents S0 and R0 then executing the code SP! and RP!. When doing so, you must be careful that the area allocated can hold the stacks without overflowing. Use of this method m$ , the current screen number for editing, while the latter case includes DP , BASE , and THAW. The user area lives at 0AA3 hex at runtime. It is 100 hex bytes in size. At FREEZE time the bottom 18 decimal bytes are copied into an array in the dictionary$ pointer 4 VOC-LINK - vocabulary list pointer 6 LEX-LINK - Lexicon list pointer 8 FENCE - Forget protection 10 WIDTH - Maximum width of a word (63) 12 WARNING - Error message control fla$update flag to ensure modified buffers are written out 48 IN - Current input pointer 50 OUT - Current output pointer 52 TIB - Input buffer 54 HLD - Pointer for numeric output 56 $inal input buffer ( 82 bytes min.) 214 - 246 available 5. DICTIONARY STRUCTURE / NFA / LFA / CFA / PFA ---------- --------- --- --- --- --- The following is a discussion of the internal format in which Forth words are structured. If y$mmon for all Forth implementations, so will be of particular interest to the advanced programmer: The first byte of the NFA contains the length of the word's name in the lower five bits of the byte; thus word names can be up to 31 letters in length. $our screend to fit on a page instead of 3. If your printer does not support this, then change the counts assigned in the definition of WPRINT. &PAGE Advance to the top of the next page. &WIDE S$e normal width print mode from &WIDE or &DENSE The remaining & words are designed to allow you to take advantage of any special features that your printer may support. Underlining, graphics, special carriage control, character set selection, italics, a$CLM interface code 0a5b - 0aa3 Forth initialization code 0aa4 - 0b99 User area 0b9a Start of Forth dictionary memend-7971 FIRST - Start of disk buffers (~$60DA) memend-778 LIMIT - End of$ I/O area F000 - FFFF System Rom 3. STACK STRUCTURES ----- ---------- As shown previously in the memory map, FORTH runs two stacks. The user stack is implemented using the 6809 U register while the RETURN STACK is implemented u$akes it very straightforward to call system routines directly from forth routines by pushing the parameters onto the RETURN stack and then Calling the system routine with the CALL word. 4. USER-AREA --------- The user area is an area which contains $ called USER-CONST. (These are copied back to the user area at boot time.) The average user will use user variables simply by their names and need not be concerned with their position im memory; the following information is presented only for the curiou$g 14 UTRACE - CFA of a routine to do tracing 16 THAW - CFA of startup routine 18 UABORT - CFA of word to execute when error occurs 20 thru 34 unused Volatile user area: 36 OUTPUT-FCB - Primary ou$ DPL - Decimal point location 58 BLK - Present load block ( 0 = terminal ) 60 SCR - Present screen 62 CSP - Compiler error check 64 OFFSET - present drive selected 66 STATE - Compiling/$ou have no interest in this topic you may skip to the next section. Each entry in the Forth dictionary is composed of the following parts: * The NFA, Name Field Address, stores the name of the entry. * The LFA, Link Field Address, links words together #Of the 3 high order bits, bit 7 is the immediate bit, indicating that the word is to be executed even if found during a compile; bit 6 is the smudge bit, set to indicate that this word is not to be found during dictionary searches; bit 5 is reserved, it $elect double width printing - generally referred to as 'expanded' print mode - typically 40 chars/line. &DENSE Select dense printing mode - generally referred to as 'compressed' print mode - This assumes a m$nd test commands are all examples of words that should be coded. Screen 20 shows some of the words designed for the HP Thinkjet printer. 2. KEY LOCATIONS, MEMORY MAP: --- --------- ------ --- Key locations in the memory map include: Address ($ disk buffers (~$7CF6) Limit of Forth User stack memend-266 S0 - Top of user stack (~$7EF6) Limit of return stack memend-10 R0 - Top of return stack (~$7FF6) 8000 - 8800 $sing the 6809 S register. The area for both of these stacks is allocated from the top of memory when FORTH initializes. Currently, there are 256 bytes for the return stack and 512 bytes for the user stack. Both of these are more than sufficient for nor$system type variables for that user. In this implementation, these variables are of two types, those which are valid for only that session of Forth and those which are retained when Forth is frozen and then rebooted. An example of the former would be SCR$s. These locations may change in a future revision, the final authority in the event of a conflict is the code itself. Non-volatile user area & user constants: Offset Function 0 BASE - Current base 2 DP - Dictionary$tput device FCB 38 AUXOUTPUT - secondary output device FCB 40 INPUT-FCB - query input device FCB 42 KEY-FCB - keyboard input device FCB 44 PRINTER-FCB - printer output FCB 46 UPDATE-FLAG - $Interpreting state 68 CONTEXT - vocabulary pointer 70 CURRENT - vocabulary pointer 72 LOWDP - Lexicon dictionary save pointer 74-81 DSKTABLE - forth disk fcb table (4 words) 82 - 213 TERMBUFF - Term$ in the same vocabulary. * The CFA, Code Field Address, is the address of the code to be run for this word. * The PFA, Parameter Field Address, varies dependent upon the word being defined. The NFA is structured as follows; this structure is not co% in program debugging. A special feature of SuperFORTH is that it takes advantage of the banks on the SuperPET by using them as swappable vocabularies - called LEXICONS. With these LEXICONS, you can load development tools such as the assembler or edito% SuperFORTH Index to manual2: 1. PRINTER WORDS 2. KEY LOCATIONS, MEMORY MAP: 3. STACK STRUCTURES 4. USER-AREA 5. DICTIONARY STRUCTURE / NFA / LFA / CFA / PFA % start with an ampersand '&', henceforth pronounced 'printer' Because almost everyone has a different type of printer and even method of interfacing, the printer I/O has been made extremely flexible. The resulting printer words are divided into three cl% ept that the output goes to the printer instead of the terminal. Some additional words are: &RPT ( n c -- ) Prints n occurances of the character c on the printer. PRT-ON ( -- ) Enables echoing of all terminal output to the printer. PR%tion. Please note that while you do have the right to make legal copies of the software that these copies and the original must remain in your possession. You do not have the right to "lend" copies ( or the original and retain the copies ) of the softwa%eives the Forth concept of obtaining the best performance from the system. In some areas our words violate 79 standards by having greater utility ( see CMOVE ); however, we do not see this as a major problem. The extensible nature of Forth will, of cours% Special attention has been paid to File I/O and I/O redirection. Much attention was paid to string functions, lacking in many Forths. Many users coming to Forth from other languages, such as Basic, find the string functions convenient. In particular, %lexibility. There is a built in TRACE function that does not use the extra NO-OPs that many other Forths use, which significantly slow down the inner interpreter. Strings and the interpreter have been specially designed to allow the direct execution of a%, thus the name entries look to Forth like normal strings. Vocabulary - The Vocabulary structure has been constructed to allow for the expansion of swappable virtual vocabularies ( lexicons), and makes use of the ' smart forget ' by Kilbridge. LOADING%e main menu (or CLM), simply enter the forth ye command. WHAT IS IN SuperPET SuperFORTH ---- -- -- -------- ---------- SuperFORTH provides a number of interfaces to the SuperPET as well as a number of utilities. Among these are a full-screen editor, r into the banks and leave all of main memory free for the nucleus and your particular application. When you use APPLICATION, these development tools are not saved, resulting in a smaller program file. tionally it has trace facilities built in to assist% 6. TRACE FUNCTIONS 7. STACKVIEW 1. PRINTER WORDS ------- ----- A number of printer words have been supplied on the release Forth disk. These words are simple definitions made with the general file I/O words explained previously. %asses: device independant, device specific, and general features. The device independant and the general features words are assumed to be applicable to all printers while the device specific words are used only by certain printers such as a reverse line%T-OFF ( -- ) Disables output echoing to the printer. MPRINT ( n1 n2 -- ) Prints screens n1 to n2 on the printer, three to a page utilizing the word PRT-LIST. WPRINT ( n1 n2 -- ) Prints screens n1 to n2 on the printer, ei%re; such is itself a violation of copyright, and you will further be considered to have aided in violation of copyright if further copies are made at such time. DESIGN PHILOSOPHY ------ ---------- This Forth system has evolved from Forth systems in us%e, allow it to be simply adapted to the 79 standard should this be required. In cases where Fig-Forth and Forth-79 differ, words were chosen for their greatest utility. For example, the Fig-forth use of VARIABLE, which allows the user to define the init%since the SuperPET operating system is very much at home with null terminated strings, SuperFORTH provides both standard forth strings and the null terminated form. Double precision words have been built in. This is because not only do most programmers % string as a series of Forth words. Special Prompt control gives the user extra flexibility over the enviroment. The Dictionary structure - By allocating one more byte to each dictionary entry than most implementations, much faster search time was achei% SuperPET SuperFORTH ------- -------- ---------- FORTH like any other system program may be loaded from the main menu or from within CLM. To do so, simply type forth to load it. If you have a single disk drive or FORTH is not on the default disk %an assembler, I/O statements, a decompiler, and printer support words. Support is built into SuperFORTH to support redirection of I/O as well as simaltaneous logging of all I/O to an external file. Additionally it has trace facilities built in to assist$e coded to do nothing or perform another substitutable feature. For example, reverse printing on a commodore printer is a very logical substitute for bold face printing. These words are: &BOLD &-BOLD Enable and disable bold face printing. &PERF%They are implemented to work with the file whose FCB is stored in the variable PRINTER-FCB. During initialization, this is opened to whatever device name is stored in the string variable PRINTER-NAME. To help distinguish these words in usage, they all % feed or special character set selector. The device independant words that are assumed by the remainder of the Forth environment are: &emit &type &cr &spaces &.r All of which do exactly as their corresponding mates without the ampersand exc%ght to a page utilizing the word 2PRT-LIST. These words are dependant upon several general features words that select modes and features offered by most printers. If your printer does not offer the feature, then the word should b%e on the North Carolina State University campus and local community. It does not adhere to all Forth-79 standards, but rather uses features of both Forth-79 and Fig-forth selected for their greatest usefulness. It is the hope of the authors that this ach%ial value of variables, was selected over the 79 standard, which leaves them undefined. Major areas of attention to this implementation include: The Disk system - Disk compatiability is maintained. Forth can read and write other Commodore disks. I/O -%use these functions, but they are used internally by the other Forth words, making Forth smaller and faster than it would be otherwise. Special attention to functionality - Many "hooks" have been designed in to Forth to allow it the greatest speed and f%ved, speeding up compiling and word traverse time. The Fig-forth 3 letter system was abandoned for a system which stores the full word up to 31 characters in length. The name in the dictionary doesn't have extra bits set to indicate the ends of the words% then you must enter the drive in front of the name like: disk.forth Once FORTH has loaded, it will clear the screen and print the start-up banner. At that point you are in FORTH and can enter any forth command. To terminate FORTH and return to th&C3l& INDEX TO MANUALS IN SUPERPET SUPERFORTH The manuals, number from 1 through 10, are found on the release disk, and may be read in any standalone editor, loaded alone, in 6809 mode. manual1:e 1. OPENING THE FORTH DISK & A / PFA 6. TRACE FUNCTIONS 7. STACKVIEW, VISUAL STACK manual3:e 1. FREEZE / BUILDING YOUR OWN COPY OF FORTH 2. THAW / HOW TO HAVE FORTH AUTOSTART 3. APPLICATION 4'C3NB& 3. SIN , COS , AND SQRT 4. CASE STATEMENT 5. DUMP 6. THE FORTH DECOMPILER manual9:e 1. SYS 2. MULTI SCREEN TRANSFER 3. SCREEN DUMP 4. STATU& SSSSS PPPPPP EEEEEEE TTTTTTT SSSSSSS PPPPPPP EEEEEEE TTTTTTT SS SS PP PP EE TT SS PP PP EE &F OOOOO RRRRRR TTTTTTT HH HH SSSSSSS FFFFFFF OOOOOOO RRRRRRR TTTTTTT HH HH SS SS FF OO OO RR RR TT HH HH SS FF OO OO RR RR TT HH &right 1983, 1985 John A. Toebes, VIII and Hal Levin 6304 Wingate St. Alexandria, VA, 22312 Permission to copy this material is hereby granted, provided this notice is included in the copied material. Any prod&language. To have written such a manual would have been a major effort that would have taken up far to many resources that could have better been spent on other tings. Instead we recommend an excellent manual, " STARTING FORTH " by Leo Brodie, as a text&uperPET SuperFORTH. Much of this information is presented for advanced programmers' needs and will be of little use to the beginner. It is suggested that if you are just learning FORTH you scan the manual but do not worry if there are sections you do not&ural when entered. SuperPET SuperFORTH is case sensitive and will treat TEST1 Test1 and test1 as three different words. One section of this manual is a reference list of the FORTH words. Each entry contains the word itself, a stack diagram, and a short& 2. COMPATIBILITY WITH THE COMMODORE DISK WORLD 3. THE FORTH DISK WEDGE 4. INDEX 5. SCREEN SHAPE AND SIZE 6. NUMBER OF BUFFERS 7. BLOCK STRUCTURE 8. CON&. BUILDING A BOOTABLE APPLICATION: manual4:e 1. ERROR MESSAGE CONTROL manual5:e 1. SMART CMOVE vs %manual2:e9*manual3:e%#manual4:e+manual5:e)"manual6:e'!manual7:e\-manual8:e.manual9:e'/manual10:e#gloss1:eN0 gloss2:eLgloss3:eT3forth$5system:fo5 5 config:fo5decompiler:fo >full-forthTfull-forthpRinit-forthT copy_disk:b disk_index:e( SuperFORTH: Index to manual1: 1. OPENING THE FORTH DISK 2. COMPATIBILITY WITH THE COMMODORE DISK WORLD 3. THE FORTH DISK WEDGE 4. INDEX 5. SCREEN SHAPE AND SIZE ( H-DISK is a file under the Commodore Disk Operating System. Also, SuperPET SuperFORTH can read and write other Commodore files (this is documented further in a later section). The benefits of this system are many, as discussed below. The FORTH-DISK is i( ie would use a Forth Drive. After FORTH is loaded, before you can load, create, or edit screens, or perform FORTH disk functions which use the words BUFFER or BLOCK, you must open the FORTH-DISK to FORTH. The command that does this for the FORTH-DISK pr( H-DISK files on the same diskette with different names without conflict; this gives the advantage of allowing one to keep track of the data by the file names given to the files. An added advantage is that this system is compatible with all Commodore disk() RELative file. The 0 is the FORTH-DISK number; you may have 0, 1 2 and/or 3 open as FORTH-DISKS. The word OPEN-DISK finds the previous information on the stack and opens the proper file as a FORTH-DISK. If the file does not exist it is created for yo( used the utility program for Basic called the WEDGE. This program helps make up for the lack of disk functions in Basic by 'wedging' extra code into Basic which can be activated by the > or @ symbols. A Forth 'Wedge' is provided in source form on the re( : OPEN " forth.disk" 0 OPEN-DISK ; The companion word CLOSE may also be defined: : CLOSE 0 RELEASE-DISK ; See the section on BLOCK STRUCTURE of this manual for information on how to overlap information across multiple FORTH-DISKS and still access it(easily, the tilde character (~) was chosen (shifted up- arrow). Thus all wedge commands start with tilde character. Also, and this differs from the function of the Basic wedge, the tilde must be followed by a space. This is becauseit is defined as a Fo(e entire disk for Forth data may be wasteful of space, 3) as there are neither filenames nor a standard index system, it is often hard to find information stored out on the disk, or even to determine what is stored on the disk, and 4) this type of implem(( scratch all files begining with FUM ) ~ I ( Intialize the disk ) ~ C:X=Y ( Copy file Y to file X ) ~ $:A* ( List all files in directory begining with A ) The Forth wedge is not used to load or save( 6. NUMBER OF BUFFERS 7. BLOCK STRUCTURE 8. CONLOAD 9. OTHER FILES UNDER FORTH 1. OPENING THE FORTH DISK ------- --- ----- ---- The FORTH-DISK is a relative file on the diskette. See the next section (mplemented as a REL type file under the Commodore Disk Operating System (DOS) . Each block of the FORTH-DISK is made of 8 records, each 128 bytes in length ( total 1024 bytes ) . Such a file can be read not only by FORTH but by the Waterloo languages inc(ovided on the release diskette is simply: " forth.disk" 0 OPEN-DISK where: " forth.disk" is the name of the FORTH-DISK to be opened. This file is called "forth.disk" on the release diskette. Note that you can put any file name there as long as it follo( drives. There is a price paid for this utility: a small amount of disk space is used to support the relative file. However, for a FORTH-DISK that takes up an entire 4040 diskette this is only 12 sectors, a small price to pay for such utility. In additi(u. Once opened, Buffers, and thus Screens, can be accessed in the normal Forth manner. The disk remains open until either a RELEASE-DISK command (with the FORTH-DISK number as input on the stack) or another OPEN-DISK command for the same FORTH-DISK, whic(lease diskette and can be loaded if desired by the user. It is technically not a true wedge, for it has no need to 'wedge' into existing code; but the term wedge will be used here to describe this useful utility, in that its function is the same as that ( directly with a single set of block numbers. 2. COMPATIBILITY WITH THE COMMODORE DISK WORLD ------------- ---- --- --------- ---- ----- Many Forth implementations take an entire disk drive and break it down into 1024 byte sections called Blocks or( rth word and all Forth words are delimited by a space. Following this space are standard wedge commands. These commands could include: ~ $ ( list the directory ) ~ S:FOO ( scratch file FOO ) ~ S:FUM* (entation is usually hardware-dependent, that is, if other disks of a different size become available it will not work on the new hardware without modification. We have implemented our system to be compatible with the Commodore disk file system. The FORT) Basic files, as this function would be meaningless. The function of loading a machine language file is already provded by the Forth word SYSREAD. [Also, Forth provides SYSWRITE to save a machine language file, a function the Basic Wedge wll not perform.(for a further discussion of the structure of this file. The file that we are calling the FORTH-DISK is functionally the same as the collection of information Leo Brodie refers to in "Starting FORTH" as the Forth Drive. You can use your FORTH-DISK as Brod(luding mBASIC. Thus you can write a program in mBasic that prints or even modifies the FORTH-DISK file. You can backup the file with standard backup and copy programs. You can VERIFY the diskette without damaging the file. You can keep several small FORT(ws the form filename where is optional and defaults to DISK8/0. You may not put either a filetype designator--such as (F:80)--nor can you put a file format such as ,REL or ,SEQ because OPEN-DISK requires that the file be a (F:128(on, an advantage is gained in that this allows the inteligent 4040 drive to deal with the overhead of the actual track and sector manipulation, off loading it from the CPU. 3. THE FORTH DISK WEDGE --- ----- ---- ----- Most Commodore disk owners have(h forces a RELEASE-DISK of the previously opened file. Example: 0 RELEASE-DISK Users who elect to use the same file name for all FORTH-DISKS may find it handy to define a word like the following, which assumes the file is always to be named DISK :(of the Basic wedge. Unfortunately, both the > and @ symbols already have meaning in Forth that would make them impractical to use as the key to call the wedge. Looking for a key that would avoid such conflicts, be easy to remember, and could be reached ( Screens ( depending upon how they are used ). Such a system is very simple to implement, but has several disadvantages. Among these are: 1) The entire disk is used to hold Blocks so other types of files can not co-exist with the Forth data, 2) Using th) r and/or location of the buffers. These values are set upon startup of SuperPET SuperFORTH based upon MEMEND_ (at $22). As each block takes 1028 bytes of space to store, the difference between FIRST and LIMIT must stay an integer multiple of 1028; you ) ] The tilde may be entered on a line by itself to read the disk error channel. Currently the wedge assumes drive number 8 is to be used. 4. INDEX ----- The word INDEX is provided on the release Forth-disk. INDEX will cause the first line of each s) ur changes you should give an EMPTY- BUFFERS command to be sure your new buffers are not considered to contain data and thus not flushed to disk. To actually change the value of a constant, use ' (tick) to give the PFA of the word and ! to store the val) ural way to use INDEX; the latter may be preferred by experienced Forth programmers. Due to the speed problems of the SuperPET internal I/O routines and to provide greater utility to the programmer by not forcing out any buffers that he has in memory, I)OCK is given, N is taken from the stack as a block number and effects the loading of the selected block into memory (in the case when the block is not already present). An address returned on the stack is the location of the first byte from that block. T). In this, as in most standard implementations of FORTH, the screen is divided into 16 lines of 64 characters each. The first line of this screen is used as the index line and contains a comment indicating what is on that particular screen. 6. NUMBER ) one logical file. To achieve this each of the FORTH-DISKs are simply opened with a different Forth-file number (and name if on the same physical device). Thereafter, referring to a screen greater than 8191 on drive zero causes it to be searched for on a)advised to leave this set at seven; it will be very practical for most applications; the advanced programmer, however, may wish to increase it when doing heavy disk work or may reduce it to regain some space for the dictionary. The buffers are generally)ber. The next 1024 bytes are the data section of the block. The block ends in two Null (zero value) bytes. These bytes must be nulls; if you elect to work at the block level, do not change them ! 8. CONLOAD ------- A conditional load word has been) are loaded before defining words that use them. If the word is already loaded, the screen is not reloaded. It may also be of use to the user for the same purpose. CONLOAD must be loaded from screen 1 before loading the other screens. 9. OTHER FILES UN)can change either by 1028, but if one is changed by a value other than a multiple of 1028 the other must be changed by a value that will maintain this relationship. See the next section for an explanation of block structure and the use of the additional )creen in the range given to it on the current drive to be displayed on the current output device. These lines are by convention comment lines which describe the contents of the screen. INDEX may be called in two ways, as follows, where n1 < n2 : n1 n2 )ue desired to it. Thus: HEX 7C00 ' LIMIT ! DECIMAL would store 7C00 hex into LIMIT, setting it to the highest safe place possible assuming nothing else is loaded with FORTH. Generally, you will want to change the value of FIRST. 7. BLOCK STRU)NDEX does not use the normal Forth word R/W but rather does its own I/O, bringing in only the first line of each screen. Thus the current content of the buffers is neither affected nor displayed by INDEX. There is also a Fast Index command provided: FI)he rightmost 12 bits in the word prior to this (addr-2) contain the block number. This twelve-bit quantity limits the maximum block number to 8191, though the true limit on a 4040 disk is based on its 171K capacity. This would limit a FORTH-DISK to 8191 )OF BUFFERS ------ -- ------- The disk buffers are where blocks brought in from the FORTH-DISK are kept in memory. More disk buffers will generally help speed up disk usage by allowing more such blocks to remain in memory, however, each buffer takes s)nother drive as follows: IF block > 8191 then block = block - 8191 and drive# = drive# + 1 The other 3 initial bits the Block contain both the update flag (the indication that the block has been modified and therefore must be written to disk) and al) at the top of memory (though they need not be; a user may move them for any reason; to reserve space, for example). The position of the buffers is controlled by two constants, FIRST and LIMIT. Changing the values of these constants will change the numbe) defined and used on many of the screens on the release diskette. This word, CONLOAD, will load a screen if the word that follows it is not found in the dictionary. It is used to ensure that sets of words (for example, Bit manipulation or Trig functions)*DER FORTH ----- ----- ----- ----- Several words have been provided to ease access to SuperPET files, as documented below. The user is assumed to understand the concepts of the SuperPET file system. With the exception of ERRORMSG, these routines are )four bytes (1028 as opposed to 1024). The buffers can be changed at any time, even if a Forth-disk is open, as long as the buffers are not in use. Therefore, before changing either constant you should do a FLUSH or EMPTY-BUFFERS command. After making yo)INDEX Causes all screens in the range n1 to n2 inclusive to be indexed. n2 n1 INDEX Parameters passed in this manner, as with a Forth DO loop, will cause screens n1 to n2-1 to be indexed. The first form is the more nat)CTURE ----- --------- Each Block of data is 1024 bytes long but takes up 1028 bytes in memory due to overhead. Additional information such as the block number, update flag, and trailing nulls account for the extra bytes. When a command such as: N BL)NDEX, which displays only lines that begin with a "(" as the first character and displays only up to the ")" . FINDEX functions as INDEX above. 5. SCREEN SHAPE AND SIZE ------ ----- --- ---- The standard Forth Blocks and Screens are 1024 bytes long)screens on larger secondary storage systems, such as a Winchester drive, but the user has two options: 1) keeping multiple FORTH-DISKs with different filenames to index their functionality, or 2) treating several (up to four) physical FORTH-DISK files as)pace away that could be used for other things. The number of disk buffers is implementation-dependent in FORTH. Some systems have as few as two. Our typical system has seven, but this can easily be changed by the user. The beginning FORTH programmer is )so the Forth drive number (zero through three) as follows: +---+---+---+---+---+---+---+---+ | U | n n n | | +---+---+---+---+---+---+---+---+ The high order bit ( Bit 7 ) is the update flag, bits 6 and 7 are the drive num* SuperPET SuperFORTH Index to manual 3 1. FREEZE / BUILDING YOUR OWN COPY OF FORTH 2. THAW / HOW TO HAVE FORTH AUTOSTART 3. APPLICATION 4. BUILDING A BOOTABLE APPLICATION: 1. FREEZE* simply interfaces to the system rom routines of the same names. OPENF Opens a file. Used in the form: 0" filename" 0" mode" OPENF where filename is the name of the file to be opened and mode is* ies of the language on a single diskette, with words selected for a particular class of application in each. Much of the Forth code of SuperPET SuperFORTH is provided on screens on the release diskette. This gives the user the ability to select only the* stack. FPUTCHAR Writes a byte to a file. Used in the form: char fcb FPUTCHAR to write byte char to the file controlled by fcb. SYSREAD Reads a given number of bytes from a file into a given *nvoke whatever application was loaded last (provided it was not flushed out by some other command). An example of freezing a copy of Forth could be: " disk/1.my-forth" freeze FREEZE does some reorganization of memory before saving it. User varia*turns the code. ERRORMSG Returns the address AND LENGTH of the latest system error message. Note that Forth copies the message to a buffer at $0400 so that it is not destroyed by any I/O you may us*esirable to have Forth perform some function when first loaded. This may be something as simple as opening a FORTH-DISK for the user automatically, or may be as complete as running an entire program. Control of such auto starting features is done through*the word DEFINITIONS. Remember that FORTH is normally an immediate word, and thus in the following examples is preceded by [COMPILE] to have it compiled into the startup word's definition. Once the word is defined, the CFA (Code Field Address) * an application could examine the screen and perform actions based on what it finds. CURRENT and CONTEXT vocabularies have not been selected and thus must be selected before QUIT (The outer interpeter) is called. Thus the word must either 1)* rebooted. As an example, a legal definition of an auto start word would be: : STARTUP [COMPILE] FORTH DEFINITIONS QUIT ; An even simpler form of nearly the same word is: : STARTUP ABORT ; This word would work to start Forth if its CFA* / BUILDING YOUR OWN COPY OF FORTH ------ -------- ---- --- ---- -- ----- An important feature of SuperPET SuperFORTH is its ability to save a bootable image of itself. The word that does this is called FREEZE. This allows the user to build into FO* how the file will be accessed. NOTE: This cannot be done in immediate mode as two immediate mode strings as both reside at pad CLOSEF Closes a file. The file control block is provided on * features of SuperPET SuperFORTH that are desired. For example, the 6809 assembler package is provided on several screens that need only be loaded if the user wishes to write assembly code into the Forth program. The format of FREEZE is : " Prg-n* memory location. Used as: addr len fcb SYSREAD. It returns the actual number of bytes read. SYSWRITE Writes a given area of memory to a file. It takes an address and length with a fcb like: addr l*bles are copied into a user constant area, and in general things are made ready for the restart that will happen when the module produced is booted. This should not concern the average user. FREEZE is provided on the release diskette, screen # 5, and mue to output it. This form is compatible with the string representations so " hi there mom" fcb SYSWRITE will work as expected. ERRORF Returns the error code for a given file. Takes the fcb and re* the variable THAW. In order to have SuperPET SuperFORTH autostart, simply write a word that calls the Forth commands you wish performed. The only consideration that need be made here is that when this word runs, Forth is still coming up, and the follow* of the word should be stored into the variable THAW . This can be done, in the case of the word STARTUP, by the following line: ' STARTUP CFA THAW ! Once THAW is set, the current copy of Forth need only be saved with FREEZE, and it will auto start when* set CURRENT and CONTEXT and end by calling QUIT or 2) End by calling ABORT (which sets both CONTEXT and CURRENT to FORTH), in which case a warm start will reset the screen to the normal startup state. Both CURRENT and CONTEXT can be set by * were stored into THAW; however it would do nothing special during the startup process. (Because both ABORT and QUIT leave the code path and do not return to execute the word " ; ", two bytes of storage could be saved by replacing the " ; " in the d*RTH the features he most often uses and omit those not desired. Having words built in saves the user the delay of compiling Forth source code; omitting others not desired both saves space and improves compile speed. It may be desired to keep multiple cop* the stack. Used in the form: fcb CLOSEF FGETCHAR Reads a byte from a file controlled by the given fcb and places it on the stack. Thus fcb FGETCHAR would read a single byte from the file and place it on the *ame" FREEZE where " Prg-name" places a pointer to a filename-string and a length on the stack, indicating the name of the code to be frozen as. Note that although it is frozen as a specific name, that under CLM only, the command forth will rei*en fcb SYSWRITE This form is compatible with the string representations so " hi there mom" fcb SYSWRITE will work as expected. ERRORF Returns the error code for a given file. Takes the fcb and re*st be loaded before using. A later section of this document will take the user step by step through building your own Forth system, including the use of FREEZE. 2. THAW / HOW TO HAVE FORTH AUTOSTART ---- --- -- ---- ----- --------- Often it is d+efined word with " [ SMUDGE " as in: : STARTUP .... ABORT [ SMUDGE This more eloquent form need not concern the beginning Forth programmer.) The normal value of THAW before it has been set to a user start routine, and the value it should be*ing must be considered: The terminal screen will still have whatever text was on it when the copy of Forth being run was booted. Thus most auto-start applications that wish to write to the screen will wish to clear it first. If desired, such+ N is provided on the release diskette. While the Forth module provided with this system may not be further distributed, application programs saved by the APPLICATION command may be freely distributed. APPLICATION is an extremely simple way to protect th+ ot in servicable form, so the word APPLICATION does not simply return the user to FORTH. Two choices are available; if the user depresses the STOP key, forth will terminate and return from where it was invoked (either CLM or the main menu); if a RETURN + (APPLICATION does this by modification of the name and link fields of the words.) The user's own work is also offered a fair amount of protection by APPLICATION. Permission is granted to purchasers of valid copies of SuperPET SuperFORTH to distribute su+ SuperFORTH Index to manual5 1. SMART CMOVE vs where is the first word that will be forgotten. APPLIC+e a STRING SEGMENT is specified by the address of the start of the STRING SEGMENT along with the length of the STRING SEGMENT. A STRING CONSTANT is also represented by a start address and a length on the stack, the difference being that it is used direct+e author's program and yet still allow applications written in Forth to be further distributed to others who have not purchased SuperPET SuperFORTH. It effectively removes all words in the dictionary below either that pointed to by FENCE or a word provid.is entered, the application will be started. fied, and then saves a bootable copy of the modified Forth with the application program on the selected device. A message will then be displayed that the application is saved. At this point the dictionary is n+ch software under these conditions: FENCE is not changed to point to any word lower in memory than ABORT and the user's application does not redefine the words, or the equivalent of words, under ABORT and There is no word : (colon), nor words +---------------- 1. SMART CMOVE vs " , or even a prompt that always leaves the cursor at a certain spot on the sc,finition so that when the definition is executed, the address and length of the string will be put on the stack. This method places no limit on the number of strings you can define within a definition and be accessible at the same time wi,usually created with 0" although they could have been returned by a system routine 4. THE OK PROMPT --- -- ------ As does any Forth system, SuperPET SuperFORTH prints the response prompt " OK " whenever it finishes executing a command in the execut,ults in a string consisting of a single space. STRING CONSTANTS created in this way function just as STRING SEGMENTS, both are represented by a string start address and a length on the stack. $@ - This word, when given the addr,d a STRING VARIABLE. It is used in the same manner as CONSTANT or VARIABLE except the number on the stack defines the maximum length of the string variable. When created, the string will initially be a null string of length 0. To h,specified for the STRING VARIABLE, then only the leftmost portion of the STRING SEGMENT that fits will be stored. For example if we define: 5 STRING TEXT$ and attempt to execute " ABCDEFG" TEXT$ $! then only,DDRESS and is not equal to the start address of a STRING SGEMENT. To illustrate, the execution of: 10 STRING NAME$ will create a string variable whose maximum length is 10 and initial length is zero. The dictionar, value of a STRING VARIABLE. It expects the address and length of a STRING SEGMENT along with the address of a STRING VARIABLE to which the string is to be appended. If the resultant composite STRING SEGMENT is too long, then truncatio, entered in the execution mode, the text following the first space after the quote up until and not including the next quote will be copied to a temporary area called PAD with the address and length of the copy put on the stack. Note that,sult in the STRING SEGMENT containing only the 10 characters "123A ELM S" to be stored into STREET$. 3. NULL TERMINATED STRINGS ---- ---------- ------- Because all of the SuperPET system ROM routines expect to get null terminated strings as th-reen waiting for input. Changing the response prompt is done by setting the user variable PROMPT to either 0, if you want only a carriage return as a prompt; or to the address of a byte count preceded string that is to be displayed. NOTE: Because the Su,thout over-writing previous strings. For example: : FOO " HI" " BYE" TYPE TYPE ; FOO would result in BYEHI being displayed as we intended. One other important thing to note is that " " (quotes separated by a , ion mode. Additionally, SuperPET SuperFORTH allows you added flexibility in that this prompt may be changed to anything that suits your needs. For example, in the case of the PSEUDO EDITOR, the prompt is turned off so that text on the screen is not over ,ess of a STRING VARIABLE will return the current start and length of the variable's STRING SEGMENT in the same format as returned by a STRING CONSTANT. This word is a synonym for COUNT and the two may be used interchangeably. ( "STRING-FE,elp identify string variables, it is a good practice to end their names with a dollar sign ($) such as NAME$ or MYSTRING$. When you invoke a string variable defined using STRING, the ADDRESS OF THE LENGTH BYTE preceding the string segment , ABCDE will be put into the STRING VARIABLE text with its length count set to 5. ( "STRING-STORE" ) MLEN - This word allows you to determine the maximum length of a STRING VARIABLE. This is useful because none of the string words issue ,y entry for NAME$ will look like: +--------------+----+---+----------------------------------+ ! FORTH HEADER ! 10 ! 0 ! 10 bytes reserved for the string ! +--------------+----+---+----------------------------------+ ,n will occur on the right. To illustrate: 6 STRING EXAMPLE$ " I'M " EXAMPLE$ $! " JOHN" EXAMPLE$ $+ would result in EXAMPLE$ containing only the 6 characters "I'M JO" to be stored into EXAMPLE$. +$ - This word p- SuperFORTH Index to manual8 1. BIT MANIPULATION WORDS 2. RANDOM NUMBER GENERATOR 3. SIN , COS , AND SQRT 4. CASE STATEMENT 5. DUMP 6. THE FORTH DECOMP- perPET takes whatever is on a line as its input, SuperFORTH will always output a carriage return after your prompt to keep your prompt from being taken as input. One default prompt, the OK prompt, is supplied with SuperPET SuperFORTH. If you change the - words are provided both for general use and for other words provided on the FORTH-DISK, including Sprite words, Joystick words, and Hi-Res Graphics. They can be loaded if desired or should be loaded to support the other word sets that use them. The wor- PROMPT$ $! ( string-stores > into MY-PROMPT$ MY-PROMPT$ PROMPT ! (stores the address of MY-PROMPT into PROMPT) Once you have set the prompt to the contents of a string variable, you can change the prompt be changing the contents of the string v- Odette, in the September, 1983, issue of Dr. Dobb's Journal. However, the RANDOM function as described there tends to both repeat after several thousand calls and to form a very definite pattern of distribution. To counter this, our word adds logic to s-lease diskette does take more space than some, but is preferred by the developers for its overall utility. It may be loaded from the release diskette if desired. There are three words defined in this CASE syntax: BEGIN-CASE , CASE and END-CASE. The Fort-sers will only use the word CHOOSE , which calls the other words. 3. SIN , COS , AND SQRT --- - --- - --- ---- Words are provided on the release diskette to provide the above math functions. Each takes one single precision value from the stack and r- 1 CASE ." ONE" ELSE 2 CASE ." TWO" ELSE -1 CASE ." MINUS ONE" ELSE 9 CASE ." NINE" ELSE ." NUMBER DID NOT MATCH" DROP END-CASE ; The above word EXAMPLE will print a string dependent o-ove. SQRT is calculated by successive approximation. As an integer answer will be given, some rounding error can be expected. The word COS is built by the defining word TABLE, also on the release diskette. This word may be useful to users to define oth-ions of Forth case statements.) NOTE: Each CASE does a DROP of the value on the stack if and only if it is a match to that CASE. If there is no match the number is retained on the stack, and can be used by the final ELSE routine. In th-ILER -------------------------------------------------------------------------------- 1. BIT MANIPULATION WORDS --- ------------ ----- Several words are provided on the release FORTH-DISK that allow bit manipulation: the ability to set, clear or test-prompt and wish to go back to the default prompt, you would do so by: OK-PROMPT PROMPT ! To turn off the prompt, so that only a carriage return is printed, you can enter: 0 PROMPT ! To define your own prompt, you must create a string variab-ds are as follows, where Addr is a byte address and Bit is a Bit number, 0 thru 7, with 0 being the least significant bit. BIT-SET ( Addr Bit --- ) BIT-CLEAR ( Addr Bit --- ) BIT-TEST ( Addr Bit --- Flag ) Tests if a bit is &ariable: " YES?" MY-PROMPT$ $! e into it the text that you want for a prompt. You then set PROMPT to the address of that string variable. To illustrate: 5 STRING MY-PROMPT$ ( reserves 5 bytes for a string named MY-PROMPT$ ) " READY" MY--um in the lower byte of the Commodore's real time clock counter to the seed during each call. This eliminates the repeat problems and reduces the tendency to generate the numbers in a pattern. The words provided are as follows: RND ( --- n ) A-h word ELSE is also used. BEGIN-CASE simply stores an indicator on the stack for later use by END-CASE. CASE compiles in the commands OVER = IF DROP . This causes a test of equality to be performed and the words after the case executed if the t-eplaces it with another single precision value. COS functions by table lookup. The absolute value of the number passed is looked up and replaced with a single precision integer value 10000 times the cosine of that angle ( in degrees ). The user is expec- n the value given to it on the top of the stack. Note that the numbers given in the case statement need follow no set order; the user is not restricted to setting up CASE statements in the range 1 to N (as in Basic computed GO TO statements and some vers-er tables as well. Defined tables return their Nth entry when called in the form: N Table-word. 4. CASE STATEMENT ---- --------- Many people have developed different forms of CASE statement for FORTH. The form of the CASE statement offered on the re-is case it was not used and the NUMBER DID NOT MATCH message was printed, so the DROP discards the value. 5. DUMP ---- The word DUMP is defined on the release FORTH-DISK to allow the user to display sections of memory. DUMP forces a hex output- the individual bits of a byte. As written, these words are intended for use with the various IO chips of the SuperPET, and thus only work with an 8 bit value, they are not written to allow the user to manipulate all 16 bits in a cell in SuperPET. These-le (see the section STRINGS) and store into it the text that you want for a prompt. You then set PROMPT to the address of that string variable. To illustrate: 5 STRING MY-PROMPT$ ( reserves 5 bytes for a string named MY-PROMPT$ ) " READY" MY--set BIT-FLIP ( Addr Bit --- ) XOR function on a single bit 2. RANDOM NUMBER GENERATOR ------ ------ --------- Random number words are provided on the release FORTH-DISK and may be loaded if desired. These words are based on words by. and also displays the ASCII value of memory on the right side of the display. DUMP is used in the form: addr len DUMP where addr is the start address and len is the number of bytes the user wishes DUMPed. 6. THE FORTH DECOMPILER --- ------ variable that holds the random seed RANDOM ( --- n ) Returns an unsigned random number between 0 and 65535 CHOOSE ( n --- n ) Replaces a number N on the stack with a random number between 0 and N-1 inclusive. Most u-est was true. END-CASE causes a number of END-IFs to be compiled into the dictionary to match the If statements compiled in by CASE. An example may best serve to explain the use of this version of CASE: : EXAMPLE ( n -- ) BEGIN-CASE -ted to scale this number for proper results. (This is, of course, necessary because of the integer nature of Forth.) Angles greater than 360 degrees are simply looked up mod 360. SIN is simply calculated by adding 90 degrees and taking the Cosin. See ab. SuperFORTH Index to manual9 1. SYS 2. MULTI SCREEN TRANSFER 3. SCREEN DUMP 4. STATUS 5. BUFFER DUMPER 6. EXECUTE$ 7. RECURSION WORDS --. BUFFER DUMPER ------ ------ Buffer dumper is a handy word to have around. by typing: BUFFERS? you get a list of all the screens that are currently in buffers, whether they have been modified or not, and the drive to which they belong. Modified bu. u would have had to do when writing in assembler. SYS expects at least two parameters: the address to SYS to on the top of the stack, and the value to be placed in the D register before calling the routine. Upon termination, the address of the routine . CUTE$ is designed to be used in any context where the words to be executed cannot be compiled into a definitions. Some cases of this are FORGET ( which normally takes the word it is to forget from the input stream ) and : ( colon ) and other defining wo.2drop r> ; The 2drop gets rid to the parameters while the >r ... r> saves the FCB address returned from the system OPENF_ routine. 2. MULTI SCREEN TRANSFER ----- ------ -------- This application was written by Mark Mostow under Fantastic Forth on th. ---------- A Forth decompiler is provided on the release FORTH-DISK which will decompile Forth words back to their source definitions. This may prove helpful in understanding the language itself as well as examining previously written words. The decomp.nt the screen numbers. When it has read them all it will prompt you for the name of the target drive. It will then prompt you for the target screen number. After it writes out the screens it will ask if you wish to continue or quit transfering. Press t.es is controlled by the variable INDENT-STEP and can be modified by changing this variable. Should the user wish to stop the decompiling process, the STOP key will terminate the word. The decompiler must be loaded from the sources on the release disket.e screen to that file PRINT-SCR ( -- ) Dumps the screen contents to the system printer device already opened by Forth. 4. STATUS ------ Status is a handy word for the beginner. It gives a quick summar.n which the most recent copy of a word would be found. For example+ : testit " setup main" execute$ ; would cause the most recent copies of SETUP and MAIN to be executed. This could be very handy if you are working on either or both SETUP and MAIN and .------------------------------------------------------------------------------ 1. SYS --- SYS is supplied to provide a ready interface from Forth to the System ROM routines without having to code in the Forth Assembler. Because both Forth and the 680.ffers have an asterisk ('*') by the screen number. 6. EXECUTE$ -------- EXECUTE$ (Pronounced "execute string" ) is a special feature of SuperPET SuperFORTH not found on many other Forth systems. Its purpose is to allow you to execute the contents.called is removed and final contents of the D register replaces the initial contents on the stack. As an example, the Floating Point routines are an excellent candidate for writing using SYS. FLOAD could be defined as: : fload ( addr -- ) a0?? sys d.rds. EXECUTE$ can also be used to allow forward referencing - defining words that call other words that are not yet in the dictionary. An example of using EXECUTE$ would be: : reload " forget myword" execute$ 20 load ; Calling RELOAD would cause the mo.e Commodore 64. It is designed for single drive 1541/2023 systems which only allow one relative file to be opened at a time. It dynamically allocates space to transfer as many screens at a time as possible. If insufficient space exists to transfer all.iler is sufficiently intelligent to recreate Forth structures such as DO .... LOOP and IF ..... ELSE .. .... THEN . It will also decompile words in an indented form ("pretty print") and for that reason it may be even more desirable to print a copy of a d.he C key if you wish to transfer any more screens. 3. SCREEN DUMP ------ ---- The screen dump routines allow you to make a copy of the current terminal screen contents to any file. In the process of dumping, all trailing spaces are removed. Thesete before it can be used. e a printed copy of the source of the word. The decompiler is invoked by the symbol % and decompiles the word following it, as in : % HEX The number of spaces used for each indentation on loops and conditional structur.y of the current environment. You may wish to modify it for your own tastes. When status is called, it prints out the vocabularies and lexicons loaded, the size of the dictionary, the current numeric base, and the number of disk buffers allocated. 5. /don't want to have to reload TESTIT every time you change them. Of course, Forth makes no distinction as to how the addr and len got on the stack, the string could just as well be constructed in the program, prompted from the user, or just input as a 's.9 are stack based in their parameter passing mechanism, passing parameters to a SYSed routine is that same as for calling another Forth word. The exception is that when you use SYS, you are responsible for cleaning up the stack afterwords (exactly as yo. of a string exactly as if it had been typed in at the keyboard. With EXECUTE$, words such as FORGET and ' ( TICK ) can now be incorporated into compiled definitions to refer to words which are not currently defined or to the latest copy of a word. EXE.rop ; The drop at the end is required because FLOAD_ (the ROM) does not return anything meaningful in the D register. An example passing more than 1 parameter and using the result would be a version of openf: : openf ( addr addr -- fcb ) b0?? sys >r . st recent occurance of MYWORD and everything after it to be forgotten, then screen 20 would be loaded. Presumably screen 20 would define MYWORD. This type use makes recompilation and testing much simpler. EXECUTE$ can be used for forward referencing, i. the screens then it will make several passes until all have been transfered. When you run transfer, it will prompt you for the source disk name, the first screen to transfer, and the number of screens to transfer. As it reads in the screens it will pri.ecompiled word than to have a printed copy of the source of the word. The decompiler is invoked by the symbol % and decompiles the word following it, as in : % HEX The number of spaces used for each indentation on loops and conditional structur. words are: OUT-SCR ( fcb --) Dumps the screen contents to the file given by FCB SCREEN-DUMP ( addr len -- ) Opens up the file named by addr and len for append and dumps th/ a word when used within a regular colon defined word. When used, it compiles in a call to the word being defined. As above, fact could be defined using self as: : fact -dup if dup 1- se/ tatic' string in the definition. Although SuperPET SuperFORTH was designed to support EXECUTE$, there are still some limitiations to it. When called, EXECUTE$ copies the string to be executed into PAD and adds two trailing null bytes. As a result, any/ any amount of code may exist here :body do-expr ... ; Note that :body is used exactly like : with the exception that the word defined must have been previously defined by forward. / diate mode directly ( a pointless waste of keystrokes anyway ) may produce unpredictable results. If a word evoked by EXECUTE$ calls EXECUTE$ itself, the result will be that the new EXECUTE$ will cause the remainder of the previous EXECUTE$ to be discar/ SuperFORTH: Index to manual10: 1. THINGS A FORTH DISKETTE SHOULD CONTAIN 2. GENERATING YOUR SuperPET SuperFORTH SYSTEM -------------------------------------------------------------------------------- 1. THINGS A /der APPLICATION if the headers for the searched word is removed by APPLICATION. One final note: The definition: : 50do 0 do i . loop " execute$ ; will cause an error when 50DO is run. The reason is that the string is interpreted at runtime as if /of FORTH with your own selection of words already compiled into the dictionary. One or more relative files to serve as FORTH-DISKS should be created by opening such a file with the OPEN-DISK command. The choice of using one or more than one lies with th/d Forth compiler does not provide you with the ability to call words recursively, although the environment itself supports it. SuperPET SuperFORTH gives you this capability with several words: :r and ;r are versions of : and ; that allow you to cal/ace. NOTE to 2031 users: While SuperPET SuperFORTH will support up to 4 FORTH-DISKS open at a time, the Commodore 2031 drive can have only 1 REL file open at a time (Due to memory limitations in the drive) and thus only one FORTH-DISK can be open at a t/ used: When FORTH first comes up the value of the variable WARNING is set to the value 0 . While warning is 0 , errors will simply cause an error message number to be printed. If the value of WARNING is set to 1 (by 1 WARNING !) then FORTH will look up t/lf * else 1 endif ; forward These words are used for defining mutually recursive words :body or words that must be used by other words that cannot be defined yet. An example of this would be a parser for a / word which chanded PAD in any way will cause unpredictable ( and sometimes fatal ) results if called through EXECUTE$. These words include $->0$, ." ( dot-quote ) and " ( quote ). [ The source of EXECUTE$ could simply be modified to use some other are/ If you attempt to execute a word defined by forward before defining the action of the word with :body, it will result in error message #24 - forward reference not resolved. At that point it will p/ded; however this causes no error and may be a useful technique. With all it gives you, it should be noted that EXECUTE$ has some drawbacks. Because of it's nature, the command is interpreted at runtime rather than compile time. Not only is this slow/FORTH DISKETTE SHOULD CONTAIN ------ - ----- -------- ------ ------- When building your own FORTH diskettes, the following guidelines are offered to help determine which files you may wish to place on the new disk. However, since FORTH files are com/it had been typed in from the keyboard, and a DO .. LOOP will not worked when typed in in immediate mode. However, by changing the definition to: : 50do " 50 0 do i . loop " execute$ ; immediate We can use it as sort of an inline compiling macro li/e user; having several smaller files allows the user to use the file name itself to keep track of the contents of that FORTH-DISK; having one large file may be the simplest technique and serve the average user best. The greatest storage space would be ob/l the word defined with them recursively from within itself. For example, a factorial word might be written as: :r fact -dup if dup 1- fact * else 1 endif ;r self Another method of calling/ ime on a 2031 Drive. Multiple FORTH-DISKS can be open at the same time if you have multiple drives. The only screen you need be concerned with on your new FORTH-DISK is screen 4. This screen is used by FORTH as an error message screen; here is how it is0he error for the user and display the line of screen 4 corresponding to the error message number. Typically screen 1 of a FORTH-DISK has a line that changes this value to 1 on it, and is loaded by the user after the FORTH-DISK is opened. Users who wish t/ compiler (such as Tiny Pascal in Forth) where the lowest level of an expression must also parse any other complete expression. These words are used in the form forward do-expr ... /a of memory other then PAD to avoid this, PAD is used because it is consistent with good Forth programming techniques. ] Also, QUERY sould not be invoked through EXECUTE$ doe to conflicts involving the interpretation pointers. Invoking EXECUTE$ in immerint out the name of the unresolved forward reference, followed by the normal forth error message which will print the word you invoked to cause the execution of the unresolved word. forward. /er thant strainght compiler code, but dependent upon the environment and the selected vocabulary. ( For example, changing the value of BASE may cause unexpected results if a number is in the string. ) Also, words dependent upon EXECUTE$ will not work un/pletely compatible with other Commodore files, the final choice is up to the user. Your disks can be arranged in any way you wish. One or more different copies of FORTH should be on the diskette. In another section we have detailed how to FREEZE a copy /ke : test ." start" 50do ." done" ; Which would be equivalent to : test ." start" 50 0 do i . loop ." done" ; The applications are limitless and the exercise of exploration is left up to you. 7. RECURSION WORDS --------- ----- The standar/tained by using a diskette solely to hold a FORTH-DISK, but seldom are this many blocks required in the file. It is recommended that a copy of FORTH also be kept on the diskette, which can later be moved to another diskette or simply deleted to regain sp0 N. The default device is "printer". 6) Unsing the fill screen editor (described elsewhere), edit screens 1 and 2 to select the tools that you wish to hace in your personal Forth environment. Comment out those you do not want by putting a left0 o avail themselves of this auto lookup feature should copy screen four to their new FORTH- DISKS, those who leave WARNING set to 0 may do as they wish with screen 4 . See the section on Error Control. In addition, other files may be saved on the diskett0 our own printer words. Screen 19 contains some generic printer words that will work without using any printer features until you modify them for your printer. If you are just learning Forth, load screen 19 instead of 20 for now. You can go 0 to. See the next section, GENERATE YOUR SuperPET SuperFORTH SYSTEM, for more information. 2. GENERATING YOUR SuperPET SuperFORTH SYSTEM ---------- ---- ------- ----------- ------ The following step by step technique is only a suggested way to bui0 the command 1 LOAD If you have selected many tools to load, it may take several minutes, so be patient. When it is finished it will respond with OK. Alternatively, you may decide to load the individual tools selectively. To do so, y0el comfortable with. On a 2 drive system with the backup diskette in drive 1 and the work diskette in drive 0 you can use the mED or bEDIT command: copy (f:128)disk/1.system:4,rel (f:128)system:4,rel or with PIP copy *,*=(f:128)disk0ical and must not be left out. Close the drive with the command: 1 release-disk dr0 2031 users: Since only one relative file can be opened at a time, you load the decompiler with: " decompiler:4" 0 open-disk 1 load " config:4" 0 ope0up diskette in the drive you normally work from and run the program INIT-FORTH from either the main meno or CLM. After it loads, it will print the start up banner. 4) At the prompt, enter the name of the drive containing the backup diskette an0 Your custom build SuperPET SuperFORTH diskette in now ready to use. Exit Forth with: flush bye and then load up the newly generated copy to test it. You may repeat these procedures whenever you feel like creating a different environment with differ0ABORT ( -- ) Interpreter This is the warm start word that is called to re-initialize FORTH when an error is encountered. It prints out the FORTH banner and selects the FORTH vocabulary. ABS ( n1 -- n20 parenthesis '(' at the start of the line. Terminate editing with the STOP key. 7) Using the editor, change whatever additional screens you feel appropriate. The startup screen and the printer words should be looked at as a minimum after you 0e as space permits, FORTH makes no restriction on these files. It is suggested, however, that programs that have nothing to do with FORTH and are not intended to be used with it be kept on a separate diskette, so as to leave space for FORTH. WARNING: If0back later and modify them for your printer after you feel confortable using Forth. Once you have finished editing, you are now ready to generate your own personal Forth environment. To do this: 1) Drop Forth to its bare bones minimum by typing:0ld your own SuperPET SuperFORTH diskette. It is offered as a suggestion of one the many ways you may wish to construct your own diskette. First, never write directly to the original release diskette. 1) Make a backup of the release diskette to work fro0ou can list screen 1 as a guide and load each of the tools screens individuallt. If you do this, you must type in the definition for CONLOAD exactly as it appears on screen 1. 3) If you wish to have the smart decompiler, enter the command: 0/1.system:4,rel On a single drive 2031 system, the mBASIC program copy_disk:b on the backup diskette may be used to copy the file. To use it, load up mBASIC from the main menu and run the program. It will prompt you for the file to copy. 0n-disk 4) If you wish to chanfe the prompt (OK) to your own prompt, follow the instructions in the section of this manual on THE OK PROMPT 5) At this time you are now ready to save your Forth environment. Ensure you are in decimal mode and that a0d press return. To use disk8/0 as the default, simply press RETURN without typing anything. 5) At the next prompt, enter the name of the device that you wish to use for your printer and press RETURN. If you have no printer, simply press RETUR1ent tools and freeze them with different names. 0 release-disk Take out the backup disk and insert the work diskette. Save the environment by typing: " forth" freeze or if the drive is other thant disk8/0, use the filly qualified name:1 ) Arithmetic Takes the absolute value of n1 leaving the result n2 = abs(n1). AGAIN ( addr n -- ) Structured Compilation Only Used in the form BEGIN ... AGAIN to form an infinite loop. The address addr a0aer familiar with FORTH. The startup definition should be correct if you use other than disk8/0 to hold the work diskette when you boot Forth. The Printer words for a HP Thinkjet are on screen 20 and may be used as referencing in creating y0 your diskette is ever completely full, or within a low number of sectors of being so, do not write to screens above the last screen created on your FORTH-DISK. You may find after a considerable amount of work that you do not have space to save your work0 FORGET TASK At this point, the full-screen editor is no longer available. If you find you have to make any changes to a screen, you have exit Forth with the BYE command and reload INIT-FORTH. 2) Load the utilities you have selected with0m. Put the release diskette away and use it only to create additional backup diskettes. 2) Format a second work diskette and copy the file "system:4" onto it. It is a (fixed:128) relative file that may be copied with whatever utility you fe0 " decompiler:4" 1 open-disk dr1 1 load Note: if the backup diskette is not in disk8/0 then you must put the device name in from of the filename. i.e. in disk9/1 enter: " disk9/1.decompiler:4" ... The space after the first quote is crit0Enter the name and follow the prompts to change disks. You may want to save this program onto the work diskette to allow you to copy files in the future, although there is a Forth utility TRANSFER that will do the same thing. 3) Place the back0ll files are closed by typing: decimal 0 release-disk Take out the backup disk and insert the work diskette. Save the environment by typing: " forth" freeze or if the drive is other thant disk8/0, use the filly qualified name:1 implement the branching necessary to perform the desired structured construct. BUFFER ( n -- addr ) Mass Storage Allocates a buffer for block n, returning the address of the buffer, and writing out the previous contents 1 nd value n are used at compilation to ensure proper pairing of constructs and to determine the extent of the loop. ALLOT ( n -- ) Dictionary Allocates n bytes from the top of the dictionary, advancing the dictionary1 Dictionary Appends the byte value c to the end of the dictionary. If c > 255 then the value mod(c,256) will be appended. C->S ( c -- s ) Numeric Expands the signed byte value c to its single precision equivalent.1 ned file into AUX-OUTPUT will cause the output to also go to that file. B/BUF ( -- 1024 ) Constant Returns the count of the number of bytes that make up a screen buffer. B/SCR ( -- 1 ) Consta1 Converts the parameter field address of a word to its corresponding code field address. CLIT ( -- c ) Numeric Execution Only The runtime routine compiled into a definition by LITERAL to cause the byte val1L, or BEGIN ... WHILE ... REPEAT to mark the start of a structured loop. The address addr and value n are used at compilation time to ensure proper pairing of constructs and to delimit the loop. BL ( -- 32 ) Cons1s the standard FIG-FORTH CMOVE and so that when1 ( addr n -- addr1 addr ) Utility Used to format an address addr and length n to the format that DO expects with addr1=addr+n. BRANCH ( -- ) Loops Execution Only Compiled by REPEAT, AGAIN, and ELSE to1 st for words. COUNT ( addr1 -- addr2 len ) Strings Returns the address addr2 and length len of the byte count preceded string at addr1. CR ( -- ) Output Emits a carriage return character defined by2 the PFA making the newly created entry look like a code word. The SMUDGE bit is left set in the header. CSP ( -- addr ) Error-check Variable used by !CSP and ?CSP for saving the current stack pointer to ensure that 1the loss of any changes that may have been made. C! ( c addr -- ) Memory Puts the byte value c into the memory location addr. If c > 255 then mod(c,256) will be stored at addr. C, ( c -- ) 1ll output is to be logged. Anything that is outputted through TYPE or EMIT can be echoed to an auxilliary device (such as a printer). If AUX-OUTPUT contains a 0 then all I/O will go only to the default device. Storing the FCB of any ope1eturning a flag true if both areas are identical, otherwise it returns a false flag. C@ ( addr -- c ) Memory Returns the contents of the byte at memory location addr. CFA ( pfa -- cfa ) Dictionary 1 Variable Variable that defines the base in which numbers are printed and are translated in input by (NUMBER). BEGIN ( -- addr n ) Compiling Compilation Only Used in the form BEGIN ... AGAIN, BEGIN ... UNTI1an FCB address or 0 may (and probably will) cause the SuperPET to crash. CMOVE ( addr1 addr2 u -- ) Memory Copies u bytes from addr1 to addr2 in such a way that destructive overlap will not occur. This word performs the same a1 ) Mass Storage Variable that contains the current loading source screen. If it is zero, then the interpreter takes its input from the terminal, otherwise it contains the current source block that the interpreter is getting 1 the defining word is executed, the CFA of is compiled into the definition of the defined word. CONSTANT ( n -- ) Defining Used in the form n CONSTANT to define as a constant whose action at 2 efining Used in a defining word in the form ... ; to delimit the runtime Forth code for any words defined using that defining word. When executed, it compiles the address of the code following the DOES> into the current2 a definition is completely defined. CURRENT ( -- addr ) Variable Contains the address of the Pseudo-LFA of the phantom vocabulary block which points to the vocabulary into which the compiler places newly defined words. 2 Storage Selects drive 0 as the current default drive. DR1 ( -- ) Mass Storage Selects drive 1 as the current default drive. DR2 ( -- ) Mass Storage Selects drive 2 as the current d2 ( d -- ) Numeric Output Outputs the double precision number d using the current base without leading zeros and followed by a single space. D.R ( d n -- ) Numeric Output Outputs the double prec2 item on the stack. ELSE ( addr n -- addr n ) Structured Compilation Only Used in the form IF .. ELSE ... ENDIF to indicate the alternate clause to be executed when the condition evaluated by the IF statement is false. Th2 DIGIT ( b c -- n True ) Numeric Output or ( b c -- False ) Attempts to convert character c according to base b leaving the result n and a true flag if c is a valid character for base b. Otherwise it leaves a fa2 the contents and any changes not yet written out to disk. ENCLOSE ( addr c -- addr n3 n2 n1 ) Parsing Finds the string starting at addr delimited by character c returning offset n3 to the first occurence of a non-deleimiter char2 Arithmetic Returns double precision negation of double precision number. DO ( -- addr n ) Loops Compilation Only Used in the form DO ... LOOP, DO ... +LOOP, and DO ... /LOOP to indicate where the start of 2 addr and n for error checking and to set the limits of the clauses. ERASE ( addr n -- ) Memory Fills n bytes of memory starting at addr with a null (0) value. ERROR ( n -- ) Error Handling Per2iven by MESSAGE. It then returns control to the terminal by executing QUIT. ERRORF ( fcb -- n ) File I/O Calls the system routine ERRORF_ for the file whose control block is given by fcb. ERRORMSG ( -- addr ) 2 definition and terminates execution of the defining word. DP ( -- addr ) Variable Holds the address of one byte past the last byte in the dictionary. DPL ( -- addr ) Variable Holds the loc2D+ ( d1 d2 -- d1+d2 ) Arithmetic Returns the double precision sum of two double precision numbers. D+- ( n d1 -- d2 ) Arithmetic Applies the sign of the single precision value n to the double precisio2efault drive. DR3 ( -- ) Mass Storage Selects drive 3 as the current default drive. DRN ( n -- ) Mass Storage Selects drive n as the current default drive. N must be in the range 0-2ision number d right justified in a field at least n spaces wide with leading spaces for fill. DABS ( d -- abs(d) ) Arithmetic Returns double precision absolute value of double precision number. DECIMAL ( -- ) 2e address addr and value n are used by the compiler to pair conditionals and to delimit the extent of the IF clause. EMIT ( c -- ) Output Outputs character c to the current output device. If c is a carriage re2lse flag. DISK-TABLE ( -- addr ) Mass storage Array of 4 words each of which point to the FCB for an open FORTH-DISK drive. If an entry contains 0 than that drive is not opened to any file. It is initialized to zero upon 2acter, offset n2 to the first occurence of the delimiter after n3 and offset n1 to the next location to scan. In no case will the search for a delimiter go past a null byte in the string to scan. END ( addr n -- ) Str2an iterated loop is. Address addr and value n are used by the compiler to ensure proper pairing of conditionals and to indicate the start of the loop. DO compiles (DO) into the current definition. DOES> ( -- ) D2 forms error handling and message issuing for error number n. If WARNING is set to -1, then (ABORT) is executed. Otherwise it prints the last token parsed by the interpreter followed by a question mark and the message for error number n as g3 File I/O Calls the system routine ERRORMSG_ and returns the address of the null terminated error message for the last I/O operation. EXECUTE ( cfa -- ) Execution Executes the word whose CFA is on top of the s2ation of any decimal point in the last word processed by NUMBER. If DPL=-1 then no decimal point was found, otherwise DPL indicates the number of digits found the the right of the decimal point. DR0 ( -- ) Mass 2n value d1 leaving the result d2. If n is negative then d2=-d1 otherwise d2=d1. D- ( d1 d2 -- d1-d2 ) Arithmetic Performs the subtraction of two double precision numbers and returns the double precision result. D. 23. ( No error is issued if it is not, but results are undefined. ) DROP ( n -- ) Stack Removes the top item from the stack and throws it away. DUP ( n -- n n ) Stack Makes a copy of the top2 Numeric Output Selects the current base to be base 10. DEFINITIONS ( -- ) Vocabulary Selects the CURRENT vocabulary to be the CONTEXT vocabulary so that all words will be compiled into the search vocabulary.2turn defined by NL, then OUT is set to zero, otherwise, OUT is incremented by one to keep track of the number of characters on an output line. EMPTY-BUFFERS ( -- ) Mass Storage Causes all buffers to be emptied out, losing2initial statrup. DLITERAL ( d -- ) Compilation Compilation ( d -- d ) Execution Compiles the value d into the current definition if the interpreter is in a compilation state. DNEGATE ( d -- -d ) 2uctured Compilation Only An obsolete synonym for UNTIL. ENDIF ( addr n -- ) Structured Compilation Only Used in the form IF ... ENDIF, or IF ... ELSE ... ENDIF to delimit the end of a conditional clause. It uses3 addr n ) Structured Compilation Only Used in the form IF ... ENDIF or IF ... ELSE ... ENDIF to indicate code to be conditionally executed. It compiles a 0BRANCH which takes the top value off the stack at runtime and if the val3 tack. EXPECT ( addr n -- ) Input Reads in up to n characters into the buffer at addr adding a trailing null to the input string when either a carriage return defined by NL is input or the limit of n characters is read in.3 nto a definition. IN ( -- addr ) Variable A variable used by the interpreter to determine the current place in the input string where it is tokenizing. INPUT-FCB ( -- addr ) Terminal I/O A variab3 - ) Mass Storage Causes all updated buffers to be written out to their respective drives. FORGET ( -- ) Dictionary Execution Only Causes the latest dictionary entry for the next word in the in3 Returns the loop index value of the second level of loop in the current word. K ( -- n ) Loops Returns the loop index value of the third level of loop in the current word. KEY ( -- c ) 3 HERE ( -- addr ) Dictionary Returns the address of the top of the dictionary which is one byte past the last byte in the dictionary. Here is defined as : HERE DP @ ; . HEX ( -- ) Numeric3 "-F44 42d :4"4 4@ .2f   forth S29" |8 $ oZ& JoZ&+~ ,$,v?,,3I ( -- n ) Loops Returns the current loop index value. If more than one loop is active, then it returns the most recently activated loop. I' ( -- n ) Loops Returns the limit of the 3BDD7~ -dup &~ execute  "7~ utrace ((;trace) ' C55  ntrace-on 5 ] ~ trace-off O un ~ monitor f 40 50~ banksw ~ 7 ~ (bye) ~>r 74~ r> 5~ r ~ pick X37A~ or7A~ xor7A~ 0=+'O_~ 0<#<,~ <4M7. >F]7- =Vm7' u<f}7" notu+c=4 70-4'2b5 ~/5.5 ~@lit~ clitO~ branch1~ 0br3ue is 0, the code following the ENDIF (or ELSE if present) will be executed, otherwise the code following the IF will be executed. The address addr and value n are used for error checking by the compiler and to delimit the extent of the3 FENCE ( -- addr ) Variable Points to the location in memory below which no words will be forgotten. FGETCHAR ( fcb c ) Input Reads a single character from the file whose file control block is 3le used by QUERY containg the fcb of the file from which all input is to be taken. Normally this file is opened to the terminal but may be pointed elsewhere. It is initialized to point to the standard input file by COLD. INTERPRET ( 3put stream to be deleted along with all other entries defined since it. FORTH ( -- ) Vocabularies Selects the base Forth vocabulary chain as the current search vocabulary. FPUTCHAR ( c fcb -- ) 3 Input Returns the next character input from the standard input device. If no charcter is present, then it returns a value 0. KEY-FCB ( -- addr ) Terminal I/O A variable used by KEY containing a pointer to the fil3 Output Selects base 16 (hexadecimal) as the current input and output base. HLD ( -- addr ) Numeric Output Variable that holds the location where the next formatted output character is to be placed in constructing a 3 user-const ( ,$,v?,,,v user-area (dup 6n4 4 3 ' 5 n3current loop index value. If more than one loop is active, then it returns the most recently activated loop. ID. ( nfa -- ) Dictionary Outputs the name of the dictionary entry whose NFA is given. IF ( -- 3 I~ sp@ 0~ rp@ 6@~ @~ c@,O~ !$;77~ c!4L77~ +!D]77~ cmoveUs4 DB%'B/  B/  3F5 ~ toggleh7~ fill4 77 /0&5 ~ and4anch'1"~ (loop) b-2d1"~ (+loop),m*b.2d1"~ (/loop)Om+b% b"|2d1"~ (do)Bx74~ in i'b~ jd~ k'h~ leaveb~ +7~ d+FBF4O_5YDD3D~3 conditional. IMMEDIATE ( -- ) Dictionary Toggles the immediate bit in the most recently defined entry. The immediate bit determines if the word will execute immediately when in compilation mode or will be compiled i3 given by fcb. FILL ( addr n c -- ) Memory Fills n bytes of memory starting at addr with the byte value c. FIRST ( -- addr ) Constant Returns the start of the mass storage buffers. FLUSH ( -3-- ) Interpreter Part of the outer interpreter which parses and executes a single input string that is either pointed to by TIB or on a screen indicated by BLK. Called by QUIT. J ( -- n ) Loops3 File I/O Output character c to the file controlled by the file control block given by fcb. GET-CURS ( -- c l ) Input/Output Returns the current cursor position of line l column c of the video screen. Home is 1 1. ?e control block from which key is to read its character. in the current word. K ( -- n ) Loops Returns the loop index value of the third level of loop in the current word. KEY ( -- c ) 3numeric string. HOLD ( c -- ) Numeric Output Places character c into the current formatted output string. It is typically used in the form <# ... 46 HOLD ... #> to insert a decimal point in the formatted number. 3 kD4B44044 i2j@46 7Z&0?045J& 42b' 55 n %h%h %d %d %d2dup 766~ drop z 3B~ 2drop 3D~ swap 76~ 2swap ĮDDBFFB~ over B~ rot 4 al 4 5 'O~ space(9 (!spaces(9Ly  Lv (!erase(9L(!blanks(9 (!enclose0O4 3\E4F'&0 FD''0 FD&Bm'5 ~ expectB(9  vLJL2J  (k 4 -B~ d-FBFVDD3D~ negate'O_~ dnegate=O_BBV~ s->d0X~ c->sNj~ max`{7/~ minr7,~ +-(9:%(!d+-(9:;(!abs(9 (!dabs(9 (!u/hE4 (!hld(6dpl(8numeral .0 W~ hold(9C[J(!sign (9 :-(!<#"(99(!#>;(9  (!#K(9 (!#sa(9f )(!d.rv(9 A|*Q w(!d.(9L(!.r(9 V 4 + %' % _$~@_~ decimal(9 9(!hex(99(!octal(99(!-1)(0=(1G(2P(3Y(4b(s0k(r0t(sp!~|~ rp!~ disk-table (Juse( update-flag (prev(4(!?stack!(9z[U!K!(!?exec!(9!(!cfa!(9e(!pfa" (9 *?(!lfa"(9p(!nfa"1(9 *(![compile] "@(9)L! "(!compile"V(9! C (!literal"u(9  ""(!dl4 oL 9 (! open-disk (9   q$(f:128) q,rel quO )w 9(!+buff(9p k  (!buffera(9 j9 : C LD 9 9 C(!update(94k*2 kw(!(")$(9   (!"$(9""$k*2k  q(!""$(9L(!string%((9(Uy L(2(!mlen%6(9T*(!$@%](9(!$!%m(9 %e J 2 q(!$+%y(9   %e  *4stdink~ stdoutm~ key(9(!emit(92Uw (!set-curs 24 AC3D5 ~ get-curs $P4 4O6565 ~ crB(9L9+Uw(!queryc4 P4E 4V 싽2dE o0o oo5 ~ 0len{Ѯm&049kC(!vlist'(9 *?M[i """8 ) i(!;s'(#5 ~ ށ:((9!!y'#'s4 1~ ށ;(((9!"(!P(!;trace(@(9!" AP(!constant (S(9'P's~ variable (k(9(w's06~ user((9(w's ~ 0$(9  qL J(!0"(9"""k 2 * qL k(!type2(9  f'x '(! (! (!counto(9 2 *(!(.")(9  2  w(! ?termin4 s((9L(w(!does>((9 "9's4 06~ uabort(((abort)((9( ok-prompt ((ok 0prompt) ()lowdp)(Hthaw),(-->)9(97)!L9!7 7[(!)E(97&U7[L97!T)! (! (!(number) )q(925K "" !k*2" "!(!quit*(9!L798C9*))( w(!load*(97  L9!j79* 9 79(!bye+6(9!Lv T o of 4urrent(Fcontext(Dstate(Blatest(9(![(9L9(!](9π9(! immediate (9π(!smudge.(9@(!(find)Fg4 7@&%?&Z,00O65 ~@?:&˯5 ~ -find[(9 ke ) ke4*/mod(9 x (!m/mod(9 L   (!*/(9 (!1+40~ 2+,E0~ 1-=V0~ 2-Ng0~ >>_x/ DV0&~ <<p/ XI0&~ 2/GV~ 2*XI~ base(digit3BO04ssage (9 T p! d: Uk  stack empty message#  9i(!error (9 :)kw?  7+csp!2(>!csp!f(9!m9(!?error!q(9 !; (!?comp!(9)!(!?csp!(9!m!46_\&ZO5 ~ sysread4 770402d5 ~ syswrite )4 77040 2d5 ~ r/wF4 BTTTTO ']BXIXIXIB4B'oADo1?&2b44D4BmA& 2dB, DDj&2a3F5 ~ release-disk =(9  4U^p"Gk#'#'9(g9(!forget#(9""G #D{! #7 {$*] #79 #' {$*] #'9 ""8 { e9 ) _9(!forth#(#,v($(9)(!."$(9""4(9U(!dr2(9^(!dr3(9g(!bl( in(0out (2nl( termbuff "(Rtib,(4 input-fcb <(( output-fcb G($ aux-output X(&key-fcbj(* printer-fcb |(, printer-name (%Y(printer4+loop&(9g&)"*(!/loop&(9g&)"M(!begin&(9!kU(!until&(9U&)"(!end'(9' (!while'(9&:C(!again'$(9U&)"(!repeat'5(9 '> e&S(!(;code)'L(9 ""9(!create'h(9 "G"p k *#C *2kTJ @5 5 o xoo cold+j(9 $qL 9L97L9 $$9T oT9f of9xoLx9okeyboardrO9owO9)A abort+(9 ;SuperPET SuperFORTH - V 5.0 - Copyright 15 5 error 28 error 29 error 30 error 31 5 5 disk error! Error 9 Assembler conditional Pair Error error 11 5 5 definition not finished in protected dictionary use only when loading error 23 5 5( profile screen )  decimal 2 warning ! : ok ; : cls 12 emit ; : home 1 emit ; : conload -find if 2drop drop else load endif ; 3 load ( assorted handy words - must be loaded ) 95 55 55555555555 55555555!985 John A. Toebesi$*]+k*2" "!(!quit*(9!L798C9*))( w(!load*(97  L9!j79* 9 79(!bye+6(9!Lv T o of 5 5 ( error messages - 1 of 2 ) stack empty dictionary full has incorrect address mode 5 5 Lexicons not allowed within lexicons Context and current vocabularies cannot both be Lexicons error 14 error 15 5 5 forward reference not resolved error 25 error 26 error 27 5 : 5: ?D5 56666 66666666 66666 66666 66 677 77777 77777 77777777 7777 788 88888 88888 88888888 8888 899 99999 99999 99999999 9999 9:: ::::: ::::: ::::::6 62 load ( sys - to call system rom routines ) 6 load ( dump ) 7 load ( case ) 50 load ( assembler ) 5 5 not unique Buffers not flushed! Use (bye) to exit anyway Disk range ? full stack 5 5 ( error messages - 2 of 2 ) compilation only execution only conditionals not paired 5 6 ) -->( loader screen continued ) ( 27 load ( status ) ( 29 load ( random numbers ) ( 30 load ( sin, cos, and sqrt 6 definition not finished in protected dictionary use only when loading error 23 6 ( error messages - 1 of 2 ) stack empty dictionary full has incorrect address mode 6 ?terminal if leave endif 16 +loop r> base ! ; 6 ) ( 33 load ( 64list, 64load for Fantastic Forth screens ) 35 load ( startup word ) 6 ( 14 load ( mulit-screen transfer ) 12 load ( index, findex ) 16 load ( wedge, directory ) 40 load ( full screen editor 6 Lexicons not allowed within lexicons Context and current vocabularies cannot both be Lexicons error 14 error 15 6 ( dump ) ." ." decimal : dump base @ >r hex bounds do i 0 <# # # # # #> type space i 16 0 do i over6 : hex. base @ swap hex 0 d. base ! ; : rvstype -dup if bounds do i c@ 128 or emit loop ;s endif drop ; 6 : case compile over compile = [compile] if compile drop ; immediate : end-case b6 ) ( 26 load ( visual stack - do not use with pseudo editor ) ( 36 load ( recursion words ) ( 37 load ( doer, make words from "Thinking Forth" ) ( 9 load ( pseudo editor 6 forward reference not resolved error 25 error 26 error 27 6 not unique Buffers not flushed! Use (bye) to exit anyway Disk range ? full stack 6 6 ( utility words ) ." ." decimal : \ ( skip rest of line ) in @ 64 / 1+ 64 * in ! ; immediate 6) ( 28 load ( bit manipulation words ) 20 load ( printer words - thinkjet ) 22 load ( mprint, wprint screen printers ) ( 23 load ( screen dumper 6 ( error messages - 2 of 2 ) compilation only execution only conditionals not paired 6 + c@ 0 <# # # #> type space loop ." | *" 16 0 do i over + c@ 14 max 127 over = if drop 14 endif emit loop ." *" cr drop 6 7egin dup 5 - while [compile] endif repeat drop ; immediate 6 ) 8 load ( execute$ ) 24 load ( freeze ) 10 load ( application ) 32 load ( buffer dumper 6 error 28 error 29 error 30 error 31 6 disk error! Error 9 Assembler conditional Pair Error error 11 6 ( case ) ." ." decimal 5 constant begin-case immediate 6 : chr bl word here 1+ c@ [compile] literal ; immediate : base? base @ decimal dup . base ! ; 7 fence @ [compile] ' max latest begin 2dup - 0< while pfa lfa @ repeat begin dup dup 1+ c@ if c@ 63 and 7 ( pseudo full screen editor ) ." ." decimal : __ ( n -- ) \ replace a line on the current screen dup scr @ (line) blanks 7 : (idx) ( n -- addr len ) dup 12 >> disk-table + @ -dup if \ drive is open swap 8191 and 1- 3 << over fseek_7 7 ( expansion for application ) 7 scr ! cls 0 prompt ! scr ? ." pedit" cr __list ." endedit" home ; : endedit ( -- ) \ terminate editor and restore prompt ok-prompt prompt ! ; 7e cr else 2drop endif ?terminal if leave endif loop ; ( index continued ) 7ermbuff tib ! \ restore real input buffer r> blk ! r> in ! ; \ and input pointers 7 7 7 0 do dup 1+ i + rot 1- dup c@ 2swap rot swap c! loop pfa lfa dup @ (nul) rot ! else drop pfa lfa dup @ 0 rot ! endif -dup not until drop freeze 7 0 word here @ 256 = if drop else \ input is blank here c@ 64 > if ." truncated" 64 here c! endif scr @ (line) drop here count rot swap cmove endif update ; 7 sys 2drop 64 pad rot fget_ sys 2drop drop else pad 64 blanks endif pad 64 ; : indexline dup 2 .r space (idx) -trailing type cr ; 7 ( execute$ ) ." ." : execute$ in 7 7 ( application ) 24 conload freeze ." ." ' (number) lfa @ constant (nul) : application [compile] forth definitions 0 lex-link !7 7 7 ( index ) ." ." hex b0b4 constant fseek_ b0d5 constant fget_ decimal : reorder 2dup < if 1+ swap endif ; 8 7 cr ." application saved" cr cr ." press return to start application, stop to exit" begin ?terminal if (bye) endif key nl = if cold endif again ; 7 : __list ( -- ) \ list the lines on screen for editing 16 0 do i 2 .r ." __ " i scr @ .line cr loop ; : pedit ( n -- ) \ format the screen for pseudo editor 7 : index reorder do i indexline ?terminal if leave endif loop ; : findex reorder do i (idx) over c@ chr ( = if i 2 .r space -trailing typ7@ >r blk @ >r \ save input pointers 0 in ! 0 blk ! \ and pretend it is the terminal $->0$ tib ! \ make it a null terminated string interpret \ and execute it t7 8 5 here 10 + c! TO_ @ here 7 + ! ; : cmd ( addr len unit -- ) 0 st c! !fcb $->0$ FN_ ! here P_N sys drop ; 8 ver i swap - b/buf * sc @ + b/buf cmove i . loop drop 2cr 0 release-disk ." insert destination disk, hit any key." get drop 2cr 2dup open-disk ." first d8 : ~ ( wedge command ) 0 word here count over c@ chr $ = if dir else swap over pad swap cmove pad swap 8 ( multi-transfer - part 1 ) ." ." : 2over 4 pick 4 pick ; : 2cr cr cr ; : get begin key -dup u8 : @@ dup c@ swap 1+ c@ 8 << or ; : dir ( addr len -- ) swap over pad 8 + swap cmove 8 + pad + 0 swap ! " ieee?-0." pad swap cmove 8 ( wedge interface ) ." ." hex 006a constant st 0368 constant TO_ bc8 : &cmd 27 &emit &type ; \ useful for commands : &bs 8 &emit ; \ only if your printer does overstrike : &normal ; \ to return to normal 80 char/line : &wide ; \ to select ~40 char8uffers are avaiable" cr begin 2cr get drop 2over open-disk ." first source screen # ?" cr #i/p cr ." last source screen # ?" cr #i/p cr 1+ over - #tr8 repeat r> 129 over 10 + c! closef ; -->( wedge - user interface ) ." ." : fixcmd ( addr len -- ) 8 for tight lines : &6lpi ; \ 6 lines per inch for loose lines : &perf ; \ to allow skip over perforation : &-perf ; \ to disable skip over perforation 8 : ds$ ( unit -- addr len ) 0 st c! !fcb here DS_R sys drop iobuf_ dup 0len -dup if swap over pad 8estination screen # ?" cr #i/p cr dup r> bounds ." screens written" do i buffer over i swap - b/buf * sc @ + swap b/buf cmove update i . loop drop flush 0 8 2dup fixcmd ~unit @ cmd ~unit @ ds$ type cr endif ; 8ntil ; : $i/p query 0 word here count ; : #i/p query 0 word here number drop ; 0 variable #trb 0 variable sc : transfer flush 0 r8 ~unit @ chr 0 + pad 4 + c! pad 0" l" openf >r ( fcb -- ) pad 7 r sysread drop pad 4 + @@ . space pad 25 r sysread pad swap 1- type cr 8d0 constant P_N bfef constant DS_R 0300 constant iobuf_ 0068 constant FN_ decimal : !fcb ( unit -- fcb ) here 9 + c! 0 here c! 18 /line : &dense ; \ to select >132 char/line : &bold ; \ emphaized or doublestrike : &-bold ; \ reset from bold : &8lpi ; \ 8 lines per inch8b @ min 2dup >r swap bounds -->( multi-transfer - part 2 ) ." ." 2cr ." screens read : " do i block o8 bounds do i c@ dup chr : = if drop leave else dup chr a < over chr z > or not if 95 and i c! else drop endif endif loop ; 9 ( print definitions - thinkjet ) 21 load ." ." decimal : &page 12 &emit ; : &cmd8 swap cmove pad swap else drop " 00, OK,00,00" endif ; -->( dir command ) ." ." 8 variable ~unit 8release-disk 2cr ." conitnue (c) or quit (q)?" get chr c = not until 2drop 2drop r> dp ! r> ' first ! empty-buffers ; 8 ( print definitions - generic ) 21 load ." ." decimal : &page 12 &emit ; \ do a page eject 8elease-disk first >r here >r limit b/buf 4 + - ' first ! 2cr ." source disk? " cr $i/p dup 1+ allot here sc ! first pad - 20 - b/buf / dup #trb ! dup b/buf * allot . ." transfer b8 begin pad 2 r sysread drop pad @ while pad 2 r sysread drop pad @@ . begin pad 1 r sysread drop pad c@ -dup while emit repeat cr key if begin key until endif 9 drop ; ' prt-list cfa constant #prt 3 constant #cnt : mprint &-perf base @ >r decimal reorder #cnt rot rot do -dup 0= if &page #cnt endif 1- i #prt execute ?terminal if leave endi9 rop ; : &spaces bl swap &rpt ; : &.r >r dup abs 0 <# #s sign #> r> over - &spaces &type ; : prt-on printer-fcb @ aux-output ! ; : prt-off 0 aux-output ! ;9 >r 9000 over 3 + @ over - r> 2+ c@ dup banksw 0100 or r writeblk @ dup 0= until 9 27 &emit &type ; : &bs 8 &emit ; : &hlf " =" &cmd ; : &normal " &k0S" &cmd ; : &wide " &k1S" &cmd ; : &dense " &k2S" &cmd ; : &widense " &k3S" &cmd ; : &bold " (s1B" &cmd ; : &-9 : screen-dump ( addr len -- ) swap over pad swap cmove pad + 0 swap ! pad 0" a" openf -dup if dup out-scr closef endif ; 9+ &emit chr - 64 &rpt chr + &emit ; : n-lin over 5 &.r chr | &emit (line) &type chr | &emit ; : pr-scr &bold 4 &spaces " Screen #" &type 3 &.r &-bold ; : prt-list &wide dup pr-scr &normal &cr h-lin &cr 16 0 do i over n-9er dup rot pad rot cmove \ ** move to pad 0" ,prg" swap pad + 5 cmove \ ** append the mode pad 0" s" openf -dup if output-fcb dup pad 6 + 10 cmove 10 erase 9k hold chr & hold #> &cmd ; : &init 1 &lmode &-perf &-wrap &normal &bi &6lpi ; ( generic printer definitions ) ." ." decimal 9ariable e-mod 0000 , 0200 , : writeblk ( addr len type fcb -- ) >r \ save the FCB pad 4 + ! over pad ! dup pad 2+ ! \ create header pad 6 r syswrite r> syswrite ; \ write it and code : wr9 else errormsg 0type endif ; ( visual stack routine ) 9f #cnt 2 - +loop drop r> base ! &perf ; : wprint &8lpi ' 2prt-list cfa ' #prt ! 4 ' #cnt ! mprint &6lpi ' prt-list cfa ' #prt ! 3 ' #cnt ! ; ( screen dumper ) ." ." 9 9 endif e-mod 6 r syswrite r> closef ; -->( freeze - main routine ) ." ." decima9bold " (s0B" &cmd ; : &uline " &dD" &cmd ; : &-uline " &d@" &cmd ; : &8lpi " &l8D" &cmd ; : &6lpi " &l6D" &cmd ; : &perf " &l1L" &cmd ; : &-perf " &l0L" &cmd ; : &wrap " &s0C" &cmd ; : 9 : print-scr printer-fcb @ out-scr ; 9lin &cr loop h-lin &cr drop ; : 2prt-list &wide dup pr-scr 5 &spaces dup 1+ pr-scr &cr &dense h-lin h-lin &cr 16 0 do i over n-lin i over 1+ n-lin &cr loop h-lin h-lin &cr9 disk-table dup pad 16 + 4 cmove 4 erase writef pad 6 + output-fcb 10 cmove pad 16 + disk-table 4 cmove 9 : &emit printer-fcb @ fputchar ; : &type printer-fcb @ syswrite ; : &cr nl &emit ; : &rpt 0 do dup &emit loop d9itef ( fcb -- ) >r 0a00 here over - 0 r writeblk lex-link @ -dup if begin dup : ." ." : pstack get-curs s0 @ sp@ - 2/ 3 - 8 0 do 70 i 1+ set-curs dup i 1+ < if i 0 = if " empty " rvstype else 6 emit endif else 4 i + pick 9 : out-scr ( fcb -- ) 32768 25 0 do 2dup 80 -trailing rot syswrite over nl swap fputchar 80 + loop 2drop ; 9 ( mprint, wprint screen listers ) ." ." decimal : h-lin 5 &spaces chr 9l ( addr n -- ) : freeze user-area user-const 36 cmove \ ** setup constant area [compile] forth definitions latest user-const 36 + ! \ ** save forth point9&-wrap " &s1C" &cmd ; : &uni " &k0W" &cmd ; : &bi " &k1W" &cmd ; : &reset " z" &cmd ; : &test " E" &cmd ; : &hires " *r1280S" &cmd ; : &lores " *r640S" &cmd ; : &lmode 0 <# chr G hold # chr 9 ( freezer - ) ." ." hex 0000 v: ( random numbers ) : : status cr base @ >r decimal voc-list cr ." Top of dictionary is at $" here hex. cr first here - . ." bytes available for dictionary" cr limit first - dup 1028 / :45 , 872 , 698 , 523 , 349 , 175 , 0 , --> ( additional t: dup abs 0 <# #s sign bl hold #> swap over rvstype 9 swap - 0 do 160 emit loop endif loop drop set-curs ; : stackview rp! ?stack 0 blk ! [compile] [ termbuff tib ! begin query interpret state @ 0= : :swap - and swap c! ; : bit-test @ swap 1 swap << and ; : bit-flip 1 rot << swap toggle ; :od dup 180 > if 360 swap - endif dup 90 > if 180 swap - cosin negate else cosin endif ; : ." ." ( informs the user of avaiable space ) : vocs ( addr -- ) begin -dup while dup 2+ nfa cfa nfa id. c: 9744 , 9703 , 9659 , 9613 , 9563 , 9511 , 9455 , 9397 , 9336 , 9272 , 9205 , 9135 , 9063 , 8988 , 8910 , 8829 , 8746 , 8660 , 8572 , 8480 , 8387 , 8290 , 8191 , 8090 , 7986 , 7880 , 7771 , 7660 , 7547 , 7431 , 7313 , 7193 , 7071 , 6947 , 6820 , 6691:/ over + 2/ swap over > not until swap drop ; ( buff: ." ." here variable rnd : random rnd @ 31421 * 6927 + dup rnd ! ; : . ." disk buffers in system (" . ." bytes)" cr ." Current base is base " r . cr cr r> base ! ; ( bit manipulation ) ?5: ?D::::: :;;;; ;;;;;;;; ;;;;; ;;;;; ;; ;<< <<<<< <<<<< <<<<<<<< <<<< <== ===== ===== ======== ==== =>> >>>>> >>>>> >>>>>>>> >>>> >?? ????? ????? ??: if prompt @ -dup if count type endif endif pstack again ; : traces pstack ;trace : tracer get-curs 55 1 set-curs 6 emit r 2+ nfa : ( sin table defined ) : :rig logic ) ." ." ( cosin table 0-90 predefined ) : cos ( returns 10000 times cosine of an angle in degrees ) abs 360 m:r @ repeat ; : voc-list " Vocabularies:" rvstype cr voc-link @ vocs " Lexicons:" rvstype cr lex-link @ vocs ; : , 6561 , 6428 , 6293 , 6157 , 6018 , 5878 , 5736 , 5592 , 5446 , 5299 , 5150 , 5000 , 4848 , 4695 , 4540 , 4384 , 4226 , 4067 , 3907 , 3746 , 3584 , 3420 , 3256 , 3090 , 2924 , 2756 , 2588 , 2419 , 2250 , 2079 , 1908 , 1736 , 1564 , 1392 , 1219 , 10: : sin 90 - cos ; : sqrt 250 begin 2dup : : choose random u* swap drop ; : ." ." : bit-set dup @ rot 1 swap << or swap c! ; : bit-clear dup @ rot 1 swap << 255 ;er dumper ) ." ." hex : buffers? base @ >r decimal prev @ begin dup hex. space dup @ -dup if dup 0< if chr * else bl endif emit :count 31 and rvstype set-curs pstack begin key until ;trace ' tracer cfa utrace ! : trace [compile] ' cfa trace-on execute trace-off ; stackview ( status word ) : ." ." decimal : table over + + @ ; table cosin 10000 9998 , 9994 , 9986 , 9976 , 9962 , 9945 , 9926 , 9903 , 9887 , 9848 , 9816 , 9718 ,; ; ( recursion words ) ." ." ( use these words instead of : ; to call the defined word ) ( like :r foo ... foo ... ;r ) : :r [compile] : smudge ; immediate ; ; : (make) r> dup 2+ dup 2+ swap @ 4 + ! @ -dup if >r endif ; : make state @ if ( compiling ) compile (make) here mar; : -- swap dr2 block swap over 1- c! 32 swap 2- c! update ; ;o like: ) ( :body foo ... ; ) : forward 2- nfa id. 24 error ; : :body ?exec !csp here [compile] ' ! ] compile drop smudge; 1fff and ." Screen" 5 .r ." -- DR" dup c@ 5 >> 3 and . else ." " endif cr +buff 0= until drop r> base ! ; ; ; dup chr A < chr Z rot < or not if i c@ 32 + i c! ; ; ( 64 output ) : 64list ." 64 screen number " dup . cr ." ( 0) " 0 over .line cr ; : ;r [compile] ; smudge ; immediate ( use this to call the defined word like ) ( : foo ... self ... ; This does same as above example ) : self latest pfa cfa , ; immediat; ( startup ) hex : startup " system:fo" 0 open-disk 1 warning ! ;ker ! 0 , else here [compile] ' 2+ ! smudge [compile] ] endif ; immediate : ;and compile ;s here marker @ ! ; immediate : undo ' zip [compile] ; ; ; immediate ( doer / make ) ." ." : zip ; : doer @ >r ; 0 variable marker ; decimal ; ; endif loop ; < ; block 24 + 25 1 do ." (" i 2 .r ." ) " dup i 40 * + 40 -trailing type cr loop drop ; ;e ( use to define the action of a word later on like ) ( forward foo .... ) ( then use foo in any definition like : test foo ; ) ( then define actual code for fo; abort ; ' startup cfa thaw ! decimal ; ' 2+ ! ; ;s the code in this screen is in the public domain Taken from page 280 in Leo Brodie's "Thinking Forth" ; -->( lower case converter ) ( addr len -- addr len ) : lowcase 2dup bounds do i c@ < cr cr ." BUFFER:" home border ; -->( full screen editor - screen functions ) ( c c -- ) : setdisp e880 c! e881 c! ; < < ( full screen editor - character replacement ) : cdel ( n -- n ) homeit dup c/l /mod 80 * screen + over + dup 1+ swap rot 63 swap - 2dup + >< < ( -- ) : homeit 1 1 set-curs ; < [ editbuff 51 - ] literal 5 over c! 1+ dup 40 2 fill 40 + 6 over c! 0f + 1 over c! 41 + 1 over c! 0f + 4 over c! 1+ dup 40 2 fill 40 + 3 swap c! ; <op if cdel else crub endif ; --> < < : ctab ( n -- n+8? ) 8 / 1+ 8 * 1- cright ; --> <* screen + 64 cmove ; : lcopy 80 * screen + swap 80 * screen + swap 64 cmove ; : ldel ldown dup c/l / dup 15 - if 15 swap do i 1+ i lcopy loop endif [ 15 64 * ] literal cerase drop ; : lins [ 15 64 * ] literal ldown d< ( -- ) : tight 28 04 setdisp 05 05 setdisp 21 07 setdisp 07 09 setdisp ; ( -- ) < ( Full screen editor - screen setup ) 10 lexicon editor hex immediate editor definitions 80f8 constant screen 8698 constant editbuff : bo<r cmove bl r> c! ; : cins ( n -- n ) homeit dup c/l /mod 80 * screen + over + dup >r dup 1+ rot 63 swap - cmove bl r> c! ; : cerase ( n -- n ) homeit dup c/l /mod 80 * screen + over + swap 64 swap - blanks ; < < -->( full screen editor - cursor movements ) decimal : cright ( n -- n+1 ) 1+ b/buf mod ; : cleft ( n -- n-1 ) 1- b/buf + b/buf mod ; <( -- ) : setup-scr cls ." SuperPET SuperFORTH " 1f emit ." EDITOR" cr ." Screen #" cr cr ." LINE 0" cr 10 1 do i 7 .r cr loop < ( full screen editor - part four ) decimal : ldown homeit dup c/l / 80 * screen + editbuff 64 cmove ; : lup homeit editbuff over c/l / 80 < < =rop dup c/l / dup 15 - if 15 do i 1- i lcopy -1 +loop endif dup dup c/l mod - cerase drop ; < : loose 20 04 setdisp 03 05 setdisp 1d 07 setdisp 09 09 setdisp ; ( n -- ) : pos-curs 40 /mod swap 9 + swap 4 + set-curs ; <rder [ screen 51 - ] literal 5 over c! 1+ dup 40 2 fill 40 + 6 over c! 0f + 10 0 do 1 over c! 41 + 1 over c! 0f + loop 4 over c! 1+ dup 40 2 fill 40 + 3 swap c! < : crub ( n -- n ) cleft dup pos-curs bl emit ; : cdel? ( n -- n ) homeit 0 over c/l /mod 80 * screen + dup c/l + rot rot + do i c@ bl - if drop 1 leave endif lo< < : cdown ( n -- n+64 ) 64 + b/buf mod ; : cup ( n -- n-64 ) 64 - b/buf + b/buf mod ; : chome ( n -- 0 ) drop 0 ; : cnl ( n -- n+64? ) 64 / 64 * cdown ; = scr @ copyto swap 0= swap ; ( -- ) : runit endfsedit cls >r >r scr @ load r> r> ; = 16 0 do dup 64 blanks 80 + loop drop ; -->( full screen editor - command functions ) ( c -- c f ) : ?done 10 over = = : fsedit ( l n -- ) cls tight base @ >r decimal dup scr ! setup-scr copyfrom doedit cls r> base ! loose ; = --> = -->( full screen editor - keyboard monitor ) : doedit dup pos-curs begin 0 swap key -dup if d= : docmd 1 24 set-curs 6 emit getinput dup 13 = if drop 136 endif 1 24 set-curs 6 emit ; = ( assembler - basic definitions ) 11 lexicon assembler hex immediate assembler =+ swap 80 + swap loop 2drop update ; ( -- ) : recover scr @ copyfrom ; ( -- ) : +scr scr @ copyto 1 sc= 138 case lins else 139 case +scr else 129 case ( 1 ) else 130 case ldel else 131 case ldown else 137 case -scr else 134 case lup else 136 case ( eatkey ) else = 0610 variable stklook 20 c, 40 c, 40 c, 80 c, 0 c, 0 c, 02 c, 04 c, 01 c, 08 c, = = over 132 = or over 11 = or over 135 = or over 1 = or over 13 = or over 2 = or over 255 = or over 12 = or over 129 > over 139 < and or over 133 = 0= and ; ( -- c ) = forth definitions : edit ( n -- ) 0 swap editor [compile] editor fsedit ; : where ( -- ) 2dup editor [compile] editor fsedit ; = ( full screen editor - update functions ) ( n -- ) : copyfrom 9 2 set-curs 6 em=up 133 = if drop docmd endif begin-case 10 over = over 132 = or if drop cdown else 11 over = over 135 = or if drop cup else 8 case cleft else 1 case chome else = -->( full screen editor - exiting ) ( -- ) : endfsedit = definitions 00 constant d 01 constant x 02 constant y 03 constant u 04 constant s 05 constant pc 08 constant a 09 constant b 0a constant cc 0b constant dpr =r +! scr @ copyfrom ; ( -- ) : -scr scr @ 1- -dup if scr @ copyto dup scr ! copyfrom endif ; ( -- ) : clear homeit screen = 3 case endfsedit else 9 case ctab else emit cright end-case dup pos-curs endif swap until drop ; -->( full screen editor - forth interface ) \ invoke the full screen editor > ' dup 2+ constant push push 2+ constant next next 2+ constant jump = = : getinput begin 0 key -dup if ?done if swap 0= else dup 133 - if emit else drop endif endif get-curs drop 24 set-curs endif until ; ( -- c ) = forth =it dup . block screen 16 0 do 2dup 64 cmove 80 + swap 64 + swap loop 2drop ; ( n -- ) : copyto homeit screen swap block 16 0 do 2dup 64 cmove 64 = 13 case cnl else 6 case cerase else 5 case cins else 4 case cdel? else 2 case runit else 255 case recover else 127 case crub else 12 case clear else > 85 s ,* b,s 8b s ,* d,s 80 s ,* ,s+ 96 s ,* [a,s] 95 s ,* [b,s] 9b s ,* [d,s] ( u register indexed instructions ) > x n,r n,x 84 x ,* ,x 82 x ,* ,--x 81 x ,* ,x++ x [n,r] [n,x] 94 x ,* [,x] 91 x ,* [,--x] 91 x ,* [,x++] 82 x ,* ,-x 86 x ,* a,x 85 x> 3 case 60 + c, , else 4 case c, c, else drop 70 + c, , end-case 0 mode ! ; : rr 0 variable mode -->( assembler - indexed mode instructions ) ( reg -- index ) > : ,rel dp @ 1+ - ; : ,pc ,rel dup abs 100 < if 8c 2 else 8d 3 endif mode ! ; >95 y ,* [b,y] 9b y ,* [d,y] -->( assembler - indexed instruction definitions - s, u ) ( s register indexed instruc>riable imod -2 allot 30 c, 20 c, 20 c, 20 c, 10 c, 0 c, : imod, mode @ imod + c@ + c, ; : idi2 c@ imod, > does> c@ over abs 100 < if 98 2 else 99 3 endif mode ! or ; : ,*  -->( assembler - opcode definitions ) : die : idi, mode @ if c, mode @ dup 2 = if drop c, else 3 = if , endif endif else , endif 0 mode ! ; > u n,r n,u 84 u ,* ,u 82 u ,* ,--u 81 u ,* ,u++ u [n,r] [n,u] 94 u ,* [,u] 91 u ,* [,--u] 91 u ,* [,u++] 82 u ,* ,-u 86 u ,* a,u 85 u ,* b,u 8b u ,* d,u 80 u ,* ,u+ 96 u ,* > ,* b,x 8b x ,* d,x 80 x ,* ,x+ 96 x ,* [a,x] 95 x ,* [b,x] 9b x ,* [d,x] ( y register indexed instructions ) >uilds c, does> c@ c, swap 4 << or c, ; : inh c@ c, ; : stk > : idxreg 1- 5 << ; : n,r c@ over abs 20 < if swap 1f a> : [,pc] ,rel dup abs 100 < if 9c 2 else 9d 3 endif mode ! ; : [n] 3 mode ! 9f ; >tions ) s n,r n,s 84 s ,* ,s 82 s ,* ,--s 81 s ,* ,s++ s [n,r] [n,s] 94 s ,* [,s] 91 s ,* [,--s] 91 s ,* [,s++] 82 s ,* ,-s 86 s ,* a,s > mode @ dup 0= swap 4 > or if , else c, mode @ dup 2 = if drop c, else 3 = if , endif endif endif 0 mode ! ; > does> c@ 1 mode ! ; -->( assembler - indexed instruction definitions - x, y ) ( x register indexed instructions ) >s c, does> c@ mode @ begin-case 1 case 60 + c, c, else 2 case 60 + c, c, c, else ? : idi1 c@ imod, idi, ; : idil dup c@ c, 1+ c@ imod, idi, ; -->( assembler - opcode definitions ) >[a,u] 95 u ,* [b,u] 9b u ,* [d,u] -->( assembler - relative mode definitions ) > y n,r n,y 84 y ,* ,y 82 y ,* ,--y 81 y ,* ,y++ y [n,r] [n,y] 94 y ,* [,y] 91 y ,* [,--y] 91 y ,* [,y++] 82 y ,* ,-y 86 y ,* a,y 85 y ,* b,y 8b y ,* d,y 80 y ,* ,y+ 96 y ,* [a,y] > c@ c, 0 swap 0 do swap stklook + c@ or loop c, ; -->( assembler - idi1, idi2, idil definitions ) 0 va>nd or 1 mode ! else over abs 100 < if 88 2 else 89 3 endif mode ! or endif ; : [n,r]  : ,dp 4 mode ! ; : # 5 mode ! ; ? rror swap c! ; : bra, 20 c, here 0 c, rel! ; : brn, 20 c, here 0 c, rel! ; ? cb idi1 addb, 0cc idi2 ldd, cd idi2 std, ce idi2 ldu, cf idi2 stu, 12 inh nop, 13 inh sync, 19 inh daa, 1d inh sex, 39 inh rts, 3a inh abx, 3b inh rti, 3c inh cwai, 3d inh mul, 3f inh swi, 1c idi1 andcc,? -->( assembler - forth interfac? 00 die neg, 03 die com, 04 die lsr, 06 die ror, 07 die asr, 08 die asl, 09 die rol, 0a die dec, 0c die inc, 0d die tst, 0e die jmp, 0f die cl? : else, here bra, endif, here 1- 3 ; : begin, here 1 ; : until, 4 ?apairs >r 1 ?apairs r> c, here 0 c, rel! ; : end, until, ; ? : ccod c@ 4 ; 24 ccod -cc 25 ccod cs 22 ccod hi 23 ccod ls 24 ccod hs 25 ccod lo 26 ccod ne 27 ccod eq 28 ccod vc 29 ccod vs 2a ccod pl 2b ccod mi 2c ccod ge 2d ccod lt 2e ccod gt 2f ? : ;code ?comp assembler [compile] assembler 0 mode ! hex compile (;code) [compile] [ ; immediate forth definitions deci?1 sta, 88 idi1 eora, 89 idi1 adca, 8a idi1 ora, 8b idi1 adda, 8c idi2 cmpx, 8d idi2 jsr, 8e idi2 ldx, 8f idi2 stx, -->( assembler - opcode definitions ) ? ." ." hex create sys ( y x 2 pshs, ) 3430 , ( u s exg, ) 1e34 , ( x 1 puls, ) 3510 , ( d 1 p?h jmp, ) 7e c, ' dup 2+ , ( end-code ) smudge decimal ? -->( assembler - structured constructs ? 1a idi1 orcc 30 idi1 leax, 31 idi1 leay, 32 idi1 leas, 33 idi1 leau, 34 stk pshs, 35 stk puls, 36 stk pshu, 37 stk pulu, 1183 idil cmpu, 118c idil cmps, 10ce idil lds, 10cf idil sts, 1083 idil cmpd, 108c idil cmpy, 108e idil ldy,?e words ) forth definitions : code ?exec !csp create assembler [compile] assembler 0 mode ! hex ; immediate ?r, 40 inh nega, 43 inh coma, 44 inh lsra, 46 inh rora, 47 inh asra, 48 inh asla, 49 inh rola, 4a inh deca, 4c inh inca, 4d inh tsta, 4e inh jmpa, 4f inh clra, 50 inh negb, 53 inh comb, 54 inh lsrb, 56 inh ? : while, if, 2+ ; : again, 1 ?apairs bra, ; : repeat, >r >r again, r> r> 2- endif, ; : label here [compile] ' ! ; ?ccod le : not 4 ?pairs 1 xor 4 ; : rel! ( target origin -- ) dup rot - dup 7f > over -80 < or 9 ?e?mal ( sys word ) ? c0 idi1 subb, c1 idi1 cmpb, c2 idi1 sbcb, c3 idi1 addd, c4 idi1 andb, c5 idi1 bitb, c6 idi1 ldb, c7 idi1 stb, c8 idi1 eorb, c9 idi1 adcb, ca idi1 orb, ? uls, ) 3506 , ( ,x jsr, ) ad84 , ( u s exg, ) 1e34 , ( y x 2 puls, ) 3530 , ( pus@ ?) : ?apairs - 0a ?error ; : if, 4 ?apairs c, 0 c, here 2 ; : endif, dup 3 = swap 2 = or 0a ?error here swap rel! ; : then, endif, ; ? 108f idil sty, 1e rr exg, 1f rr tfr, : swi2, 103f , ; : swi3, 113f , ; -->( assembler - structured constructs ) ? : end-code ?exec ?csp [compile] forth smudge decimal ; immediate ?rorb, 57 inh asrb, 58 inh aslb, 59 inh rolb, 5a inh decb, 5c inh incb, 5d inh tstb, 5e inh jmpb, 5f inh clrb, 80 idi1 suba, 81 idi1 cmpa, 82 idi1 sbca, 83 idi1 subd, 84 idi1 anda, 85 idi1 bita, 86 idi1 lda, 87 idiD5: ?D??? ?????? ?@@ @@@@@ @@@@@ @@@@@@@@ @@@@ @AAAA AAAAA AA AAAAA AAAAAA ABBBB BBBBB BB BBBBB BBBBBB BCCCC CCCCC CC CCCCC CCCCCC CDDDD DDDDD DD DDDDD @ ." Where n is the screen number to edit" cr cr ok-prompt count type cr quit ; ' init cfa thaw ! @ ." Enter drive containing backup disk" cr ." Press return to accept 'DISK8/0' as default" cr get$ -dup if swap over pad swap cmove chr . over pad + c! chr . over pad + c! 1+ else drop 0 endif @ @ @ @ -->( initializer ) : init sp! rp! 12 emit ." SuperPET SuperFORTH Initializer V5.0" cr ." Copyright 1985 John A. Toebes, VIII" cr cr @ @ ( in@ @ @ @ dup pad + " config:fo" rot swap cmove 9 + pad swap 0 open-disk ; : get-printer @ @ @ @ get-drive cr cr get-printer cr cr ." Edit screens by typing" cr ." n edit" cr @ @itializer ) : get$ query 0 word here count over c@ 0= if drop 0 endif ; : get-drive @ A @ @ ." Enter printer device" cr ." Press return to accept 'PRINTER' as default" cr get$ -dup if printer-name $! else drop endif ; @ @ @ A A A A A A A A A A A A A A A A A A A B A A A B B B B B B B B B B B B B B B B B B B C B B B C C C C C C C C C C C C C C C C C C C D C C C D D D D D D D D o5: ?DDD DDDDEEEE EEEEE EEEEEEE EEEEE E EFFFF FFFFF FF FFFFF FFFD D D D D D D D D E D D D D E E E E E E E E E E E E E E E E E E E F E E E F F F F F F F F F F F F F F F F F F