1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
6 <!-- 2023-09-19 Tue 18:07 -->
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8 <meta name="viewport" content="width=device-width, initial-scale=1" />
9 <title>Fifth - language</title>
10 <meta name="author" content="Svjatoslav Agejenko" />
11 <meta name="generator" content="Org Mode" />
13 #content { max-width: 60em; margin: auto; }
14 .title { text-align: center;
15 margin-bottom: .2em; }
16 .subtitle { text-align: center;
20 .todo { font-family: monospace; color: red; }
21 .done { font-family: monospace; color: green; }
22 .priority { font-family: monospace; color: orange; }
23 .tag { background-color: #eee; font-family: monospace;
24 padding: 2px; font-size: 80%; font-weight: normal; }
25 .timestamp { color: #bebebe; }
26 .timestamp-kwd { color: #5f9ea0; }
27 .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
28 .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
29 .org-center { margin-left: auto; margin-right: auto; text-align: center; }
30 .underline { text-decoration: underline; }
31 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
32 p.verse { margin-left: 3%; }
34 border: 1px solid #e6e6e6;
36 background-color: #f2f2f2;
38 font-family: monospace;
53 background-color: #f2f2f299;
55 pre.src:hover:before { display: inline; margin-top: 14px;}
56 /* Languages per Org manual */
57 pre.src-asymptote:before { content: 'Asymptote'; }
58 pre.src-awk:before { content: 'Awk'; }
59 pre.src-authinfo::before { content: 'Authinfo'; }
60 pre.src-C:before { content: 'C'; }
61 /* pre.src-C++ doesn't work in CSS */
62 pre.src-clojure:before { content: 'Clojure'; }
63 pre.src-css:before { content: 'CSS'; }
64 pre.src-D:before { content: 'D'; }
65 pre.src-ditaa:before { content: 'ditaa'; }
66 pre.src-dot:before { content: 'Graphviz'; }
67 pre.src-calc:before { content: 'Emacs Calc'; }
68 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
69 pre.src-fortran:before { content: 'Fortran'; }
70 pre.src-gnuplot:before { content: 'gnuplot'; }
71 pre.src-haskell:before { content: 'Haskell'; }
72 pre.src-hledger:before { content: 'hledger'; }
73 pre.src-java:before { content: 'Java'; }
74 pre.src-js:before { content: 'Javascript'; }
75 pre.src-latex:before { content: 'LaTeX'; }
76 pre.src-ledger:before { content: 'Ledger'; }
77 pre.src-lisp:before { content: 'Lisp'; }
78 pre.src-lilypond:before { content: 'Lilypond'; }
79 pre.src-lua:before { content: 'Lua'; }
80 pre.src-matlab:before { content: 'MATLAB'; }
81 pre.src-mscgen:before { content: 'Mscgen'; }
82 pre.src-ocaml:before { content: 'Objective Caml'; }
83 pre.src-octave:before { content: 'Octave'; }
84 pre.src-org:before { content: 'Org mode'; }
85 pre.src-oz:before { content: 'OZ'; }
86 pre.src-plantuml:before { content: 'Plantuml'; }
87 pre.src-processing:before { content: 'Processing.js'; }
88 pre.src-python:before { content: 'Python'; }
89 pre.src-R:before { content: 'R'; }
90 pre.src-ruby:before { content: 'Ruby'; }
91 pre.src-sass:before { content: 'Sass'; }
92 pre.src-scheme:before { content: 'Scheme'; }
93 pre.src-screen:before { content: 'Gnu Screen'; }
94 pre.src-sed:before { content: 'Sed'; }
95 pre.src-sh:before { content: 'shell'; }
96 pre.src-sql:before { content: 'SQL'; }
97 pre.src-sqlite:before { content: 'SQLite'; }
98 /* additional languages in org.el's org-babel-load-languages alist */
99 pre.src-forth:before { content: 'Forth'; }
100 pre.src-io:before { content: 'IO'; }
101 pre.src-J:before { content: 'J'; }
102 pre.src-makefile:before { content: 'Makefile'; }
103 pre.src-maxima:before { content: 'Maxima'; }
104 pre.src-perl:before { content: 'Perl'; }
105 pre.src-picolisp:before { content: 'Pico Lisp'; }
106 pre.src-scala:before { content: 'Scala'; }
107 pre.src-shell:before { content: 'Shell Script'; }
108 pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
109 /* additional language identifiers per "defun org-babel-execute"
111 pre.src-cpp:before { content: 'C++'; }
112 pre.src-abc:before { content: 'ABC'; }
113 pre.src-coq:before { content: 'Coq'; }
114 pre.src-groovy:before { content: 'Groovy'; }
115 /* additional language identifiers from org-babel-shell-names in
116 ob-shell.el: ob-shell is the only babel language using a lambda to put
117 the execution function name together. */
118 pre.src-bash:before { content: 'bash'; }
119 pre.src-csh:before { content: 'csh'; }
120 pre.src-ash:before { content: 'ash'; }
121 pre.src-dash:before { content: 'dash'; }
122 pre.src-ksh:before { content: 'ksh'; }
123 pre.src-mksh:before { content: 'mksh'; }
124 pre.src-posh:before { content: 'posh'; }
125 /* Additional Emacs modes also supported by the LaTeX listings package */
126 pre.src-ada:before { content: 'Ada'; }
127 pre.src-asm:before { content: 'Assembler'; }
128 pre.src-caml:before { content: 'Caml'; }
129 pre.src-delphi:before { content: 'Delphi'; }
130 pre.src-html:before { content: 'HTML'; }
131 pre.src-idl:before { content: 'IDL'; }
132 pre.src-mercury:before { content: 'Mercury'; }
133 pre.src-metapost:before { content: 'MetaPost'; }
134 pre.src-modula-2:before { content: 'Modula-2'; }
135 pre.src-pascal:before { content: 'Pascal'; }
136 pre.src-ps:before { content: 'PostScript'; }
137 pre.src-prolog:before { content: 'Prolog'; }
138 pre.src-simula:before { content: 'Simula'; }
139 pre.src-tcl:before { content: 'tcl'; }
140 pre.src-tex:before { content: 'TeX'; }
141 pre.src-plain-tex:before { content: 'Plain TeX'; }
142 pre.src-verilog:before { content: 'Verilog'; }
143 pre.src-vhdl:before { content: 'VHDL'; }
144 pre.src-xml:before { content: 'XML'; }
145 pre.src-nxml:before { content: 'XML'; }
146 /* add a generic configuration mode; LaTeX export needs an additional
147 (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
148 pre.src-conf:before { content: 'Configuration File'; }
150 table { border-collapse:collapse; }
151 caption.t-above { caption-side: top; }
152 caption.t-bottom { caption-side: bottom; }
153 td, th { vertical-align:top; }
154 th.org-right { text-align: center; }
155 th.org-left { text-align: center; }
156 th.org-center { text-align: center; }
157 td.org-right { text-align: right; }
158 td.org-left { text-align: left; }
159 td.org-center { text-align: center; }
160 dt { font-weight: bold; }
161 .footpara { display: inline; }
162 .footdef { margin-bottom: 1em; }
163 .figure { padding: 1em; }
164 .figure p { text-align: center; }
165 .equation-container {
171 vertical-align: middle;
176 vertical-align: middle;
180 border: 2px solid gray;
185 { text-align: right; font-size: 70%; white-space: nowrap; }
186 textarea { overflow-x: auto; }
187 .linenr { font-size: smaller }
188 .code-highlighted { background-color: #ffff00; }
189 .org-info-js_info-navigation { border-style: none; }
190 #org-info-js_console-label
191 { font-size: 10px; font-weight: bold; white-space: nowrap; }
192 .org-info-js_search-highlight
193 { background-color: #ffff00; color: #000000; font-weight: bold; }
196 <link rel="stylesheet" type="text/css" href="https://thomasf.github.io/solarized-css/solarized-dark.min.css" />
197 <script type="text/x-mathjax-config">
199 displayAlign: "center",
200 displayIndent: "0em",
202 "HTML-CSS": { scale: 100,
203 linebreaks: { automatic: "false" },
207 linebreaks: { automatic: "false" },
209 NativeMML: {scale: 100},
210 TeX: { equationNumbers: {autoNumber: "AMS"},
211 MultLineWidth: "85%",
217 <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
220 <div id="content" class="content">
221 <h1 class="title">Fifth - language</h1>
222 <div id="table-of-contents" role="doc-toc">
223 <h2>Table of Contents</h2>
224 <div id="text-table-of-contents" role="doc-toc">
226 <li><a href="#orgfe5302c">1. Fifth source format</a>
228 <li><a href="#orge4e9f7d">1.1. FSCII</a></li>
231 <li><a href="#orge63cf49">2. Fifth commands</a>
233 <li><a href="#org25bc695">2.1. Compilation & miscellaneous</a></li>
234 <li><a href="#orgc47a7bb">2.2. Conditionals & control flow</a></li>
235 <li><a href="#org572f33f">2.3. Disk & file access</a></li>
236 <li><a href="#org89deb72">2.4. Dynamic memory</a></li>
237 <li><a href="#orgea457a7">2.5. Graphics and text</a></li>
238 <li><a href="#orge721086">2.6. Math, memory & stack manipulation</a></li>
239 <li><a href="#orgf17027f">2.7. Dynamic & static strings</a></li>
246 <li><a href="5TH_ET.txt">Example Fifth source file - text editor</a></li>
249 <div id="outline-container-orgfe5302c" class="outline-2">
250 <h2 id="orgfe5302c"><span class="section-number-2">1.</span> Fifth source format</h2>
251 <div class="outline-text-2" id="text-1">
253 Fifth uses a different character table and codes than ASCII (still
254 almost similar). I call it FSCII (Fifth Standard Code for Information
255 Interchange) for example space character is not 32 but 255 instead. I
256 plan to use mainly HEX numbers, and create new characters to represent
257 numeric values. So typical nemric characters "0123…" is treated
258 like ordinary letters.
261 <div id="outline-container-orge4e9f7d" class="outline-3">
262 <h3 id="orge4e9f7d"><span class="section-number-3">1.1.</span> FSCII</h3>
263 <div class="outline-text-3" id="text-1-1">
264 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
268 <col class="org-right" />
270 <col class="org-left" />
272 <col class="org-left" />
276 <th scope="col" class="org-right">DEC</th>
277 <th scope="col" class="org-left">HEX</th>
278 <th scope="col" class="org-left">function</th>
283 <td class="org-right">0 - 15</td>
284 <td class="org-left">0 - F</td>
285 <td class="org-left">HEX numbers</td>
289 <td class="org-right">252</td>
290 <td class="org-left">FC</td>
291 <td class="org-left">backspace</td>
295 <td class="org-right">253</td>
296 <td class="org-left">FD</td>
297 <td class="org-left">tabulator (TAB)</td>
301 <td class="org-right">254</td>
302 <td class="org-left">FE</td>
303 <td class="org-left">carriage return (CR)</td>
307 <td class="org-right">255</td>
308 <td class="org-left">FF</td>
309 <td class="org-left">space</td>
313 <td class="org-right">else</td>
314 <td class="org-left"> </td>
315 <td class="org-left">ordinary characters, same as in ASCII.</td>
322 <div id="outline-container-orge63cf49" class="outline-2">
323 <h2 id="orge63cf49"><span class="section-number-2">2.</span> Fifth commands</h2>
324 <div class="outline-text-2" id="text-2">
326 <div id="outline-container-org25bc695" class="outline-3">
327 <h3 id="org25bc695"><span class="section-number-3">2.1.</span> Compilation & miscellaneous</h3>
328 <div class="outline-text-3" id="text-2-1">
330 init module ( – )<br />
331                 First module, control is passed to on startup. Contains<br />
332                 initialization routines. Also it is the last core module.<br />
333                 All new modules on top of it comes as result of executing<br />
334                 external source files.<br />
336 head <name> ( – ) compiles new dictionary entry without specifying<br />
337                 new module type.<br />
338                 ex: head myentry<br />
340 : <name> ( – ) creates new code module<br />
341 ; ( – ) ends module (immideate)<br />
342                 ex: : hello ." hi there" ;<br />
344 const <name> ( n – ) defines new constant.<br />
345                 ex: 2147483647 const max<br />
347 :i <name> ( – ) same as ":" but this module will be executed<br />
348                 immideately even in compile mode.<br />
349                 ex: :i ( 41 scan ;<br />
351 create <name> ( – ) same as "head" , but specify module type as data.<br />
352                 ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,<br />
354 allot ( n – ) allocate n bytes in dictionary.<br />
355                 ex: create MyArray 100 allot<br />
357 " <string>" ( – ) compile string and its size into core.<br />
358                 ex: create Mystring " This is it's contects"<br />
360 str <name> <string>" ( – ) just shorter way for defining strings.<br />
361                 ex: str Mystring This is it's contenc"<br />
363 var <name> ( – ) define new 32 bit variable.<br />
364                 ex: var result<br />
366 ' <module> ( – n ) return memory address of given entry.<br />
367                 ex: ' init<br />
369 forget <name> ( – ) erases from RAM given entry and all entries what was<br />
370                 defined after it.<br />
371                 ex: forget myprog<br />
373 [ ( – ) set interpret mode (immideate)<br />
374 ] ( n – ) set compile mode and compile top stack element<br />
375                 in as literal. Together [ …. ] cobination provides good<br />
376                 way to compute some values only once, at compile time,<br />
377                 rather than every time while program is running.<br />
378                 ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;<br />
380 defer <name> ( – ) creates new module, with jump instruction.<br />
381                 Later address where to jump can be modified by "is" command.<br />
382                 This provides method of foward referencing. So you can use<br />
383                 modules what not jet exist.<br />
384 is ( address1 address2 – ) address1 - where to jump, address2 -<br />
385                 address of module created by defer command.<br />
386                 ex: defer dispver<br />
387                         : run dispver ." running …" ;<br />
388                                … whatever …<br />
389                         : (dispver ." Version 9.99 " ;<br />
390                         ' (dispver ' dispver is<br />
392                 Now if I type "run" on the screen appears:<br />
393                         Version 9.99 running …<br />
395 asc <char> ( – ) reads char ascii code and treats it as literal.<br />
396                 (immideate)<br />
397                 ex: : BreakLine 30 do asc - emit loop ;<br />
398                                  same as:<br />
399                     : BreakLine 30 do 45 emit loop ;<br />
401 dyninc ( handle – ) execute code in dynamic memory handle.<br />
402                 automatically deallocates it when done.<br />
404 include ( filenumber – ) execute code in specified file.<br />
406 words ( – ) display existing blocks in core.<br />
408 bye ( – ) exit from Fifth<br />
410 fkey ( – c )<br />
411                 Read one byte from input stream.<br />
413 sadd ( c addr – )<br />
414                 Add one byte "c" to string located at "addr" and updates<br />
415                 string length.<br />
417 scan ( c – )<br />
418                 Read input stream and store it to pad until it finds c .<br />
419                 It ignores all "c" bytes until it finds any non "c" byte.<br />
420                 in other words:<br />
421                                 c is: "<br />
422                          input stream: """"This is test !"aoeu idh<br />
423                                result: This is test !<br />
425                 Is useful for breaking text lines into words.<br />
427 skey ( – c )<br />
428                 So called safe "fkey". Reads data from input stream<br />
429                 but converts characters with ASCII codes: 9 13 10<br />
430                 to spaces.<br />
432 str=str? ( adr1 adr2 – result )<br />
433                 Compares string at "adr1" with string at "adr2", returns<br />
434                 true flag if they are equal or false if they are not.<br />
435                 true = -1<br />
436                 false = 0<br />
438 find ( – addr )<br />
439                 Searches whole dictionary for word in "pad". If found,<br />
440                 returns it address, if not, returns 0.<br />
442 execute ( – )<br />
443                 Execute word located in "pad". Depending on "mode".<br />
445 dta ( addr – DataAddr )<br />
446                 Calculates address of dictionary entry data area, from<br />
447                 entry point.<br />
449 2num ( – num result )<br />
450                 Attempt to convert string located in "pad" into numeric<br />
451                 value. If succeed returns number and true as result.<br />
452                 If not, returns whatever and false as result.<br />
454 dadd ( addr length – )<br />
455                 Add to dictionary data located at "addr", with specified<br />
456                 length.<br />
458 lit ( n – )<br />
459                 Act with number depending on "mode". When interpreting,<br />
460                 leaves it in stack.<br />
463 incmod ( addr – )<br />
464                 Add to dictionary data located at "addr"+1 , length is taken<br />
465                 from "addr".<br />
467 here ( – n )<br />
468                 return "h" contents.<br />
471                 Holds input stream parser operation mode.<br />
472                 0 = interpreting<br />
473                 1 = compiling<br />
475 pad var 128 bytes<br />
476                 Holds temprorary strings.<br />
479                 Pointer to free byte in memory, always at the end of the<br />
480                 dictionary. Each time when something is stored<br />
481                 by "c," command, pointer is incareased.<br />
484                 Pointer to last dictionary word. Each time when new word is<br />
485                 compiled or erased by "forget", this pointer is updated.<br />
487 modulechk ( Dstr<filename> – ) check if module is loaded, if not<br />
488                 immideately load it.<br />
490 ne ( entrydata entrytype – ) Compile new dictionary entry.<br />
491                 It's name must be in "pad".<br />
495 <div id="outline-container-orgc47a7bb" class="outline-3">
496 <h3 id="orgc47a7bb"><span class="section-number-3">2.2.</span> Conditionals & control flow</h3>
497 <div class="outline-text-3" id="text-2-2">
499 if ( flag – ) (immideate)<br />
500                 "if 1.. else 2.. then" or<br />
501                 "if 1.. then" construction. Conditional execution.<br />
502                 Performs "1.." if "flag" was true,<br />
503                 elseway performs "2.." if exist. Execution continues after<br />
504                 word "then".<br />
505                 ex: 1 if ." nonzero" else ." zero" then<br />
507 >= ( n1 n2 – result ) true if (n1 = n2) or (n1 > n2)<br />
508                 ex: 5 3 >= if ." first number is greater or equal" then<br />
510 <= ( n1 n2 – result ) true if (n1 = n2) or (n1 < n2)<br />
511 = ( n1 n2 – result ) true if n1 = n2<br />
513 do ( count – ) (immideate)<br />
514                 "do .. loop" construction. Performs ".." "count" times.<br />
515                 In every step "count" is decareased until it is 0.<br />
516                 ex: : test 5 do i .d loop ;<br />
517                 result: 4 3 2 1 0<br />
519 doexit ( – ) exit from "do .. loop"<br />
521 for ( count top – ) (immideate)<br />
522                 "for .. loop" construction. Performs ".." (top - count) times.<br />
523                 In every step "count" is incareased until it reaches "top" .<br />
524                 ex: : test 4 10 for i .d loop ;<br />
525                 result: 4 5 6 7 8 9<br />
527 forexit ( – ) exit from "for .. loop"<br />
529 until ( – ) (immideate)<br />
530                 "until .. loop" construction. Performs ".." until flag become<br />
531                 true. False by default. Top of return stack holds flag.<br />
533 done ( – ) exit from "until .. loop"<br />
538 <div id="outline-container-org572f33f" class="outline-3">
539 <h3 id="org572f33f"><span class="section-number-3">2.3.</span> Disk & file access</h3>
540 <div class="outline-text-3" id="text-2-3">
542 diskload ( FromDisk ToMem amount – )<br />
543                 Load specified abount of bytes from disk into memory.<br />
545 disksave ( FromMem ToDisk amount – )<br />
546                 save specified abount of bytes from memory into disk.<br />
548 format ( – ) Erase all files.<br />
550 fsDfilesize@ ( handle – size )<br />
551                 Return size of opened file.<br />
553 fsDcurloc@ ( handle – location )<br />
554                 Return current location in file.<br />
556 fsDupdated@ ( handle – updated? )<br />
557                 Return true if file was updated,<br />
558                 ie. write operations occured.<br />
560 fssave ( FromMem DestFileHandle amount – )<br />
561                 Save data to file.<br />
563 fsload ( SrcFileHandle ToMem amount – )<br />
564                 Load data from file.<br />
566 fseof ( handle – bytesLeft )<br />
567                 Return amount of bytes left till end of file.<br />
568                 Useful before read operation.<br />
570 fsls ( – ) List all files and lists (directories,folders)<br />
571                 in current path.<br />
573 fslsr ( – ) Same as "fsls" but recursively scans also sub lists.<br />
575 fscl ( DynStrHand – )<br />
576                 Change list (path)<br />
578 fscreate ( DynStrHand – DescPnt )<br />
579                 Create new file or list. Can create multiple lists at once.<br />
580                 ex: when creating:<br />
581                     "\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"<br />
582                 and only "\listGAMES\" already exist, then<br />
583                 "listSTRATEGY" and "listSIMWORLD" lists will be created,<br />
584                 and empty file "5th-runme" placed in there.<br />
586 fsDsave ( DynHand<data> DynStrHand<filename> – )<br />
587                 Create new file and save all data from dynamic memory<br />
588                 block to it.<br />
590 fsDload ( DynStr<SrcFileName> DynHand<DataDest> – )<br />
591                 Load whole file into dynamic memory block.<br />
593 fsDloadnew ( DynStr<SrcFileName> – DynHand<DataDest> )<br />
594                 Load whole file into new dynamic memory block.<br />
598 <div id="outline-container-org89deb72" class="outline-3">
599 <h3 id="org89deb72"><span class="section-number-3">2.4.</span> Dynamic memory</h3>
600 <div class="outline-text-3" id="text-2-4">
602 dynal ( size – handle )<br />
603                 Allocate dynamic memory block and return it's handle.<br />
605 dynde ( handle – )<br />
606                 Deallocate dynamic memory block.<br />
608 dynp ( handle – addr )<br />
609                 Returns pointer to memory where dynamic block<br />
610                 data begins.<br />
612 dyns ( handle – size )<br />
613                 Returns size of dynamic block.<br />
615 dynresize ( NewSize handle – )<br />
616                 Nondestructively resize dynamic block.<br />
618 dync@ ( addr handle )<br />
619                 Read one byte from dynamic block.<br />
621 dync! ( byte addr dynhandle )<br />
622                 Write one byte to dynamic block.<br />
624 dyn@ ( addr handle )<br />
625                 Read 32 bit number from dynamic block.<br />
626                 Address will spacify, whitch number, not byte.<br />
628 dyn! ( 32BitNum addr dynhandle )<br />
629                 Write 32 bit number to dynamic block.<br />
630                 Address will spacify, whitch number, not byte.<br />
632 dyncon ( size "name" – )<br />
633                 Allocate dynamic block with specified size, and<br />
634                 create constant honding its handle.<br />
635                 ex: 100 dyncon MyNewBlock<br />
637 dyn. ( handle – )<br />
638                 Write contenc of dynamic memory block to screen.<br />
642 <div id="outline-container-orgea457a7" class="outline-3">
643 <h3 id="orgea457a7"><span class="section-number-3">2.5.</span> Graphics and text</h3>
644 <div class="outline-text-3" id="text-2-5">
646 . ( n – ) print number on screen<br />
648 d. ( n – ) print number on screen in decimal<br />
650 ? ( addr – ) print 32 bit value located at addr.<br />
652 ." <string>" ( – ) print string into screen. Immideately<br />
653                 compiles.<br />
654                 ex: : greeting ." Hello, World" ;<br />
656 tab. ( – ) print tabulator<br />
658 calccol ( b g r – c ) calculate color what best matches given<br />
659                 Blue Green & Red values. Values must be in range 0 - 255.<br />
661 imgalloc ( xsize ysize – imgbuf ) allocate image buffer for<br />
662                 specified size.<br />
664 imgsize ( imgbuf – ) print on the screen X & Y size of image<br />
665                 buffer.<br />
667 point ( x y imgbuf – addr ) returns memory address for specified<br />
668                 pixel.<br />
670 pset ( color x y imgbuf – ) set graphic point<br />
672 boxf ( x1 x2 y1 y2 imgbuf color – ) draw filled box<br />
674 cls ( imgbuf – ) clear image buffer<br />
676 setpal ( b g r color – ) set palette value for specified color.<br />
677                 values bust be in size 0 - 63.<br />
679 putchar ( char color x y imgbuf – ) put graphic character in<br />
680                 imagebuffer to specified (x & y) location.<br />
682 scroll ( x y imgbuf – ) scroll in imgbuf.<br />
684 scrollf ( color x y screen – ) scroll and fill empty space with<br />
685                 given color.<br />
687 at! ( x y – ) set cursor location<br />
688 curc! ( color – ) set text color<br />
689 curb! ( solor – ) set backround color<br />
691 colnorm ( – ) set text color to normal<br />
692 colneg ( – ) set text color to negative (selected)<br />
694 dyntype ( dynhandle – ) display contenc of dynamic memory on screen<br />
695 fsdisp ( file – ) clear screen, display file, and wait for key<br />
697 type ( addr length – )<br />
698                 Types on the screen string, from memory at addr and<br />
699                 specified length.<br />
701 write ( addr – )<br />
702                 Types on the screen string, from memory at "addr"+1<br />
703                 length is taken from "addr" .<br />
705 screen const 32 bit<br />
706                 Holds handle of screen buffer.<br />
708 copyscreen ( SrcImgHandle DestImgHandle – ) copy contenc of source<br />
709                 image to destination image. Source and destination images<br />
710                 must have same size.<br />
714 <div id="outline-container-orge721086" class="outline-3">
715 <h3 id="orge721086"><span class="section-number-3">2.6.</span> Math, memory & stack manipulation</h3>
716 <div class="outline-text-3" id="text-2-6">
718 off ( n – ) writes 0 to given address, good for zeroing variable.<br />
719                 ex: MyVariable off<br />
720 on ( n – ) writes -1 (true flag) to given address.<br />
721                 ex: MyVariable on<br />
723 2dup ( n1 n2 – n1 n2 n1 n2 )<br />
724 2drop ( n1 n2 – )<br />
725 nip ( n1 n2 – n2 )<br />
726 neg ( n1 – -n1 ) negotiate<br />
727 bit@ ( n bit – result ) return specified bit from n.<br />
728                 ex: 38 2 bit@ (result will be 1)<br />
729 to32bit ( n1 n2 n3 n4 – n32 ) treat 4 last stack elements as bytes<br />
730                 and unite them into 32 bit dword. Most significant byte<br />
731                 on top.<br />
732                 ex: 12 76 23 11 to32bit result: 186076172<br />
734 to8bit ( n32 – n1 n2 n3 n4 ) break 32 bit number into 4 bytes.<br />
735                 Useful if you need to send 32 bit numbers thru 8 bit COM<br />
736                 port.<br />
737                 ex: 186076172 to8bit result: 12 76 23 11<br />
739 mod ( n1 n2 – reminder ) divide n1 by n2 and returns reminder.<br />
740                 ex: 12 5 mod result: 2<br />
742 bound ( low n high – n ) check if n is in given bounds,<br />
743                 if not then incarease/decarease it to match bounds.<br />
744                 ex: 5 80 15 bound result: 15<br />
745                     5 10 15 bound result: 10<br />
746                     5 -10 15 bound result: 5<br />
748 bound? ( low n high – result ) returns true if n is in the<br />
749                 given bounds.<br />
751 tab ( col – spaces) calculate amount of spaces to add<br />
752                 ta reach next tabulation from given column.<br />
754 count ( addr – addr+1 n )<br />
755                 Useful for returning bytes from constantly incareasing<br />
756                 address. Module "type" is nice example.<br />
758 c, ( n – )<br />
759                 store one byte at memory specified by "h". And incarease<br />
760                 "h" by 1.<br />
762 , ( n – )<br />
763                 store 32 bit number at memory specified by "h". And<br />
764                 incarease "h" by 4.<br />
766 cmove ( addr1 addr2 n – )<br />
767                 copy "n" amount of bytes from memory at "addr1" to memory<br />
768                 at "addr2".<br />
770 rnd ( limit – result )<br />
771                 generates random number in range 0 to "limit"-1.<br />
773 abs ( n – |n| )<br />
774                 returns absolute value of "n"<br />
778 <div id="outline-container-orgf17027f" class="outline-3">
779 <h3 id="orgf17027f"><span class="section-number-3">2.7.</span> Dynamic & static strings</h3>
780 <div class="outline-text-3" id="text-2-7">
782 Fifth supports both static and dynamic strings. Static strings must
783 have predefined space reserved, and string mustn't exceed this
784 length. They manipulation is faster. But they use more memory. Static
785 string memory address is used to refer to the string.
789 Dynamic strings can have at any time length form 0 to 0FFh, They take
790 up only memory they currently need. They are held in dynamic memory
791 blocks, so dynamic block handle is used to refer to this string.
795 Both types of strings are stored in the way, where first (0th) byte
796 holds current string length, following bytes are string itself.
803 Dstral ( – handle )<br />
804                 Allocate new string.<br />
806 Dstrlen ( handle – length )<br />
807                 Return string length.<br />
809 c+Dstr ( chr handle – )<br />
810                 Add one byte to end of the string.<br />
812 c+lDstr ( chr handle – )<br />
813                 Add one byte to left side (beginning) of the string.<br />
815 Dstr. ( handle – )<br />
816                 Write contec of string into screen.<br />
818 Dstrsure ( size Dstr – )<br />
819                 Makes sure that at least rquested<br />
820                 "size" (amount of characters) is allocated for given<br />
821                 dynamic string.<br />
823 Dstr2str ( handle address – )<br />
824                 Copy dyamic string into static memory space.<br />
826 str2Dstr ( address handle – )<br />
827                 Copy static string into dyamic string.<br />
829 Dstr+str ( Dstr addr – )<br />
830                 Add contenc of dynamic string to static string.<br />
832 D" any string" ( – Dstr )<br />
833                 Moves specified string into dynamic string called "defDstr".<br />
835 D> any_string ( – Dstr )<br />
836                 Moves specified string into dynamic string called "defDstr".<br />
837                 Space marks end of string!<br />
839 D>2 any_string ( – Dstr )<br />
840                 Moves specified string into dynamic string called "defDstr2".<br />
841                 Space marks end of string!<br />
843 Dstr+Dstr ( Dstr1 Dstr2 – )<br />
844                 Adds "Dstr1" to "Dstr2" and places result into "Dstr2".<br />
846 Dstrclear ( Dstr – )<br />
847                 Clears contenc of dynamic string.<br />
849 Dstr2Dstr ( Dstr1 Dstr2 – )<br />
850                 Moves "Dstr1" to "Dstr2".<br />
851 Dstr ( data" name – )<br />
852                 Creates new dynamic string and moves specified data into it.<br />
853                 Then creates new constant with given "name" holding created<br />
854                 dynamic string handle.<br />
856                 ex: Dstr Hello, my name is Sven!" message \ creates it<br />
857                     message Dstr. \ tests it<br />
859 Dstrlscan ( char Dstr – loc )<br />
860                 Searches dynamic string for "char", from left to right,<br />
861                 returns first found "char" location in string, or 0,<br />
862                 if not found.<br />
864 Dstrrscan ( char Dstr – loc )<br />
865                 Searches dynamic string for "char", from right to left,<br />
866                 returns first found "char" location in string, or 0,<br />
867                 if not found.<br />
869 Dstrlscane ( char Dstr – loc )<br />
870                 Same as "Dstrlscan" buf returns string length+1 as location.<br />
872 Dstrleft ( amo Dstr – )<br />
873                 Only specified amount of characters from left remains<br />
874                 in dynamic string. ie. cut right part out.<br />
876 Dstrright ( amo Dstr – )<br />
877                 Only specified amount of characters from right remains<br />
878                 in dynamic string. ie. cut left part out.<br />
880 Dstrcutl ( amo Dstr – )<br />
881                 Cut specified amount of characters from left of dynamic<br />
882                 string out.<br />
884 Dstrsp ( char Dstr1 Dstr2 – )<br />
885                 Separate dynamic string in Dstr1 into two parts,<br />
886                 using "char" as separator. First part will be stored in<br />
887                 "Dstr2", second part in "Dstr1".<br />
888                 ex: asc \ \ ..separator<br />
889                     D> listF\listLIB\5TH_DRVMOUSE \ ..separate from<br />
890                     defDstr2 \ ..place result in<br />
891                     Dstrsp \ separation command<br />
892                     defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE<br />
893                     defDstr2 Dstr. \ will be: listF<br />
895 Dv ( addr – )<br />
896                 Allocates empty dynamic string, and places it's handle<br />
897                 into given address.<br />
899 Df ( addr – )<br />
900                 Reads dynamic string handle from given address and<br />
901                 deallocates (frees) it.<br />
903 ex: var mystring1<br />
904         : testmodule<br />
905         mystring1 Dv \ allocates string<br />
907                 <whatever><br />
909         mystring1 Df ; \ deallocates it again when no longer needed.<br />
915 <div id="postamble" class="status">
916 <p class="author">Author: Svjatoslav Agejenko</p>
917 <p class="date">Created: 2023-09-19 Tue 18:07</p>
918 <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>