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-18 Mon 01:47 -->
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="#orgb91833d">1. Fifth source format</a>
228 <li><a href="#orgceb2541">1.1. FSCII</a></li>
231 <li><a href="#org8270664">2. Fifth commands</a>
233 <li><a href="#org6885ec7">2.1. Compilation & miscellaneous</a></li>
234 <li><a href="#orge400336">2.2. Conditionals & control flow</a></li>
235 <li><a href="#org69bc847">2.3. Disk & file access</a></li>
236 <li><a href="#orgee300f5">2.4. Dynamic memory</a></li>
237 <li><a href="#org1784744">2.5. Graphics and text</a></li>
238 <li><a href="#org4c1d973">2.6. Math, memory & stack manipulation</a></li>
239 <li><a href="#org0c4a738">2.7. Dynamic & static strings</a></li>
247 <div id="outline-container-orgb91833d" class="outline-2">
248 <h2 id="orgb91833d"><span class="section-number-2">1.</span> Fifth source format</h2>
249 <div class="outline-text-2" id="text-1">
251 Fifth uses a different character table and codes than ASCII (still
252 almost similar). I call it FSCII (Fifth Standard Code for Information
253 Interchange) for example space character is not 32 but 255 instead. I
254 plan to use mainly HEX numbers, and create new characters to represent
255 numeric values. So typical nemric characters "0123…" is treated
256 like ordinary letters.
259 <div id="outline-container-orgceb2541" class="outline-3">
260 <h3 id="orgceb2541"><span class="section-number-3">1.1.</span> FSCII</h3>
261 <div class="outline-text-3" id="text-1-1">
262 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
266 <col class="org-right" />
268 <col class="org-left" />
270 <col class="org-left" />
274 <th scope="col" class="org-right">DEC</th>
275 <th scope="col" class="org-left">HEX</th>
276 <th scope="col" class="org-left">function</th>
281 <td class="org-right">0 - 15</td>
282 <td class="org-left">0 - F</td>
283 <td class="org-left">HEX numbers</td>
287 <td class="org-right">252</td>
288 <td class="org-left">FC</td>
289 <td class="org-left">backspace</td>
293 <td class="org-right">253</td>
294 <td class="org-left">FD</td>
295 <td class="org-left">tabulator (TAB)</td>
299 <td class="org-right">254</td>
300 <td class="org-left">FE</td>
301 <td class="org-left">carriage return (CR)</td>
305 <td class="org-right">255</td>
306 <td class="org-left">FF</td>
307 <td class="org-left">space</td>
311 <td class="org-right">else</td>
312 <td class="org-left"> </td>
313 <td class="org-left">ordinary characters, same as in ASCII.</td>
320 <div id="outline-container-org8270664" class="outline-2">
321 <h2 id="org8270664"><span class="section-number-2">2.</span> Fifth commands</h2>
322 <div class="outline-text-2" id="text-2">
324 <div id="outline-container-org6885ec7" class="outline-3">
325 <h3 id="org6885ec7"><span class="section-number-3">2.1.</span> Compilation & miscellaneous</h3>
326 <div class="outline-text-3" id="text-2-1">
328 init module ( – )<br />
329                 First module, control is passed to on startup. Contains<br />
330                 initialization routines. Also it is the last core module.<br />
331                 All new modules on top of it comes as result of executing<br />
332                 external source files.<br />
334 head <name> ( – ) compiles new dictionary entry without specifying<br />
335                 new module type.<br />
336                 ex: head myentry<br />
338 : <name> ( – ) creates new code module<br />
339 ; ( – ) ends module (immideate)<br />
340                 ex: : hello ." hi there" ;<br />
342 const <name> ( n – ) defines new constant.<br />
343                 ex: 2147483647 const max<br />
345 :i <name> ( – ) same as ":" but this module will be executed<br />
346                 immideately even in compile mode.<br />
347                 ex: :i ( 41 scan ;<br />
349 create <name> ( – ) same as "head" , but specify module type as data.<br />
350                 ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,<br />
352 allot ( n – ) allocate n bytes in dictionary.<br />
353                 ex: create MyArray 100 allot<br />
355 " <string>" ( – ) compile string and its size into core.<br />
356                 ex: create Mystring " This is it's contects"<br />
358 str <name> <string>" ( – ) just shorter way for defining strings.<br />
359                 ex: str Mystring This is it's contenc"<br />
361 var <name> ( – ) define new 32 bit variable.<br />
362                 ex: var result<br />
364 ' <module> ( – n ) return memory address of given entry.<br />
365                 ex: ' init<br />
367 forget <name> ( – ) erases from RAM given entry and all entries what was<br />
368                 defined after it.<br />
369                 ex: forget myprog<br />
371 [ ( – ) set interpret mode (immideate)<br />
372 ] ( n – ) set compile mode and compile top stack element<br />
373                 in as literal. Together [ …. ] cobination provides good<br />
374                 way to compute some values only once, at compile time,<br />
375                 rather than every time while program is running.<br />
376                 ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;<br />
378 defer <name> ( – ) creates new module, with jump instruction.<br />
379                 Later address where to jump can be modified by "is" command.<br />
380                 This provides method of foward referencing. So you can use<br />
381                 modules what not jet exist.<br />
382 is ( address1 address2 – ) address1 - where to jump, address2 -<br />
383                 address of module created by defer command.<br />
384                 ex: defer dispver<br />
385                         : run dispver ." running …" ;<br />
386                                … whatever …<br />
387                         : (dispver ." Version 9.99 " ;<br />
388                         ' (dispver ' dispver is<br />
390                 Now if I type "run" on the screen appears:<br />
391                         Version 9.99 running …<br />
393 asc <char> ( – ) reads char ascii code and treats it as literal.<br />
394                 (immideate)<br />
395                 ex: : BreakLine 30 do asc - emit loop ;<br />
396                                  same as:<br />
397                     : BreakLine 30 do 45 emit loop ;<br />
399 dyninc ( handle – ) execute code in dynamic memory handle.<br />
400                 automatically deallocates it when done.<br />
402 include ( filenumber – ) execute code in specified file.<br />
404 words ( – ) display existing blocks in core.<br />
406 bye ( – ) exit from Fifth<br />
408 fkey ( – c )<br />
409                 Read one byte from input stream.<br />
411 sadd ( c addr – )<br />
412                 Add one byte "c" to string located at "addr" and updates<br />
413                 string length.<br />
415 scan ( c – )<br />
416                 Read input stream and store it to pad until it finds c .<br />
417                 It ignores all "c" bytes until it finds any non "c" byte.<br />
418                 in other words:<br />
419                                 c is: "<br />
420                          input stream: """"This is test !"aoeu idh<br />
421                                result: This is test !<br />
423                 Is useful for breaking text lines into words.<br />
425 skey ( – c )<br />
426                 So called safe "fkey". Reads data from input stream<br />
427                 but converts characters with ASCII codes: 9 13 10<br />
428                 to spaces.<br />
430 str=str? ( adr1 adr2 – result )<br />
431                 Compares string at "adr1" with string at "adr2", returns<br />
432                 true flag if they are equal or false if they are not.<br />
433                 true = -1<br />
434                 false = 0<br />
436 find ( – addr )<br />
437                 Searches whole dictionary for word in "pad". If found,<br />
438                 returns it address, if not, returns 0.<br />
440 execute ( – )<br />
441                 Execute word located in "pad". Depending on "mode".<br />
443 dta ( addr – DataAddr )<br />
444                 Calculates address of dictionary entry data area, from<br />
445                 entry point.<br />
447 2num ( – num result )<br />
448                 Attempt to convert string located in "pad" into numeric<br />
449                 value. If succeed returns number and true as result.<br />
450                 If not, returns whatever and false as result.<br />
452 dadd ( addr length – )<br />
453                 Add to dictionary data located at "addr", with specified<br />
454                 length.<br />
456 lit ( n – )<br />
457                 Act with number depending on "mode". When interpreting,<br />
458                 leaves it in stack.<br />
461 incmod ( addr – )<br />
462                 Add to dictionary data located at "addr"+1 , length is taken<br />
463                 from "addr".<br />
465 here ( – n )<br />
466                 return "h" contents.<br />
469                 Holds input stream parser operation mode.<br />
470                 0 = interpreting<br />
471                 1 = compiling<br />
473 pad var 128 bytes<br />
474                 Holds temprorary strings.<br />
477                 Pointer to free byte in memory, always at the end of the<br />
478                 dictionary. Each time when something is stored<br />
479                 by "c," command, pointer is incareased.<br />
482                 Pointer to last dictionary word. Each time when new word is<br />
483                 compiled or erased by "forget", this pointer is updated.<br />
485 modulechk ( Dstr<filename> – ) check if module is loaded, if not<br />
486                 immideately load it.<br />
488 ne ( entrydata entrytype – ) Compile new dictionary entry.<br />
489                 It's name must be in "pad".<br />
493 <div id="outline-container-orge400336" class="outline-3">
494 <h3 id="orge400336"><span class="section-number-3">2.2.</span> Conditionals & control flow</h3>
495 <div class="outline-text-3" id="text-2-2">
497 if ( flag – ) (immideate)<br />
498                 "if 1.. else 2.. then" or<br />
499                 "if 1.. then" construction. Conditional execution.<br />
500                 Performs "1.." if "flag" was true,<br />
501                 elseway performs "2.." if exist. Execution continues after<br />
502                 word "then".<br />
503                 ex: 1 if ." nonzero" else ." zero" then<br />
505 >= ( n1 n2 – result ) true if (n1 = n2) or (n1 > n2)<br />
506                 ex: 5 3 >= if ." first number is greater or equal" then<br />
508 <= ( n1 n2 – result ) true if (n1 = n2) or (n1 < n2)<br />
509 = ( n1 n2 – result ) true if n1 = n2<br />
511 do ( count – ) (immideate)<br />
512                 "do .. loop" construction. Performs ".." "count" times.<br />
513                 In every step "count" is decareased until it is 0.<br />
514                 ex: : test 5 do i .d loop ;<br />
515                 result: 4 3 2 1 0<br />
517 doexit ( – ) exit from "do .. loop"<br />
519 for ( count top – ) (immideate)<br />
520                 "for .. loop" construction. Performs ".." (top - count) times.<br />
521                 In every step "count" is incareased until it reaches "top" .<br />
522                 ex: : test 4 10 for i .d loop ;<br />
523                 result: 4 5 6 7 8 9<br />
525 forexit ( – ) exit from "for .. loop"<br />
527 until ( – ) (immideate)<br />
528                 "until .. loop" construction. Performs ".." until flag become<br />
529                 true. False by default. Top of return stack holds flag.<br />
531 done ( – ) exit from "until .. loop"<br />
536 <div id="outline-container-org69bc847" class="outline-3">
537 <h3 id="org69bc847"><span class="section-number-3">2.3.</span> Disk & file access</h3>
538 <div class="outline-text-3" id="text-2-3">
540 diskload ( FromDisk ToMem amount – )<br />
541                 Load specified abount of bytes from disk into memory.<br />
543 disksave ( FromMem ToDisk amount – )<br />
544                 save specified abount of bytes from memory into disk.<br />
546 format ( – ) Erase all files.<br />
548 fsDfilesize@ ( handle – size )<br />
549                 Return size of opened file.<br />
551 fsDcurloc@ ( handle – location )<br />
552                 Return current location in file.<br />
554 fsDupdated@ ( handle – updated? )<br />
555                 Return true if file was updated,<br />
556                 ie. write operations occured.<br />
558 fssave ( FromMem DestFileHandle amount – )<br />
559                 Save data to file.<br />
561 fsload ( SrcFileHandle ToMem amount – )<br />
562                 Load data from file.<br />
564 fseof ( handle – bytesLeft )<br />
565                 Return amount of bytes left till end of file.<br />
566                 Useful before read operation.<br />
568 fsls ( – ) List all files and lists (directories,folders)<br />
569                 in current path.<br />
571 fslsr ( – ) Same as "fsls" but recursively scans also sub lists.<br />
573 fscl ( DynStrHand – )<br />
574                 Change list (path)<br />
576 fscreate ( DynStrHand – DescPnt )<br />
577                 Create new file or list. Can create multiple lists at once.<br />
578                 ex: when creating:<br />
579                     "\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"<br />
580                 and only "\listGAMES\" already exist, then<br />
581                 "listSTRATEGY" and "listSIMWORLD" lists will be created,<br />
582                 and empty file "5th-runme" placed in there.<br />
584 fsDsave ( DynHand<data> DynStrHand<filename> – )<br />
585                 Create new file and save all data from dynamic memory<br />
586                 block to it.<br />
588 fsDload ( DynStr<SrcFileName> DynHand<DataDest> – )<br />
589                 Load whole file into dynamic memory block.<br />
591 fsDloadnew ( DynStr<SrcFileName> – DynHand<DataDest> )<br />
592                 Load whole file into new dynamic memory block.<br />
596 <div id="outline-container-orgee300f5" class="outline-3">
597 <h3 id="orgee300f5"><span class="section-number-3">2.4.</span> Dynamic memory</h3>
598 <div class="outline-text-3" id="text-2-4">
600 dynal ( size – handle )<br />
601                 Allocate dynamic memory block and return it's handle.<br />
603 dynde ( handle – )<br />
604                 Deallocate dynamic memory block.<br />
606 dynp ( handle – addr )<br />
607                 Returns pointer to memory where dynamic block<br />
608                 data begins.<br />
610 dyns ( handle – size )<br />
611                 Returns size of dynamic block.<br />
613 dynresize ( NewSize handle – )<br />
614                 Nondestructively resize dynamic block.<br />
616 dync@ ( addr handle )<br />
617                 Read one byte from dynamic block.<br />
619 dync! ( byte addr dynhandle )<br />
620                 Write one byte to dynamic block.<br />
622 dyn@ ( addr handle )<br />
623                 Read 32 bit number from dynamic block.<br />
624                 Address will spacify, whitch number, not byte.<br />
626 dyn! ( 32BitNum addr dynhandle )<br />
627                 Write 32 bit number to dynamic block.<br />
628                 Address will spacify, whitch number, not byte.<br />
630 dyncon ( size "name" – )<br />
631                 Allocate dynamic block with specified size, and<br />
632                 create constant honding its handle.<br />
633                 ex: 100 dyncon MyNewBlock<br />
635 dyn. ( handle – )<br />
636                 Write contenc of dynamic memory block to screen.<br />
640 <div id="outline-container-org1784744" class="outline-3">
641 <h3 id="org1784744"><span class="section-number-3">2.5.</span> Graphics and text</h3>
642 <div class="outline-text-3" id="text-2-5">
644 . ( n – ) print number on screen<br />
646 d. ( n – ) print number on screen in decimal<br />
648 ? ( addr – ) print 32 bit value located at addr.<br />
650 ." <string>" ( – ) print string into screen. Immideately<br />
651                 compiles.<br />
652                 ex: : greeting ." Hello, World" ;<br />
654 tab. ( – ) print tabulator<br />
656 calccol ( b g r – c ) calculate color what best matches given<br />
657                 Blue Green & Red values. Values must be in range 0 - 255.<br />
659 imgalloc ( xsize ysize – imgbuf ) allocate image buffer for<br />
660                 specified size.<br />
662 imgsize ( imgbuf – ) print on the screen X & Y size of image<br />
663                 buffer.<br />
665 point ( x y imgbuf – addr ) returns memory address for specified<br />
666                 pixel.<br />
668 pset ( color x y imgbuf – ) set graphic point<br />
670 boxf ( x1 x2 y1 y2 imgbuf color – ) draw filled box<br />
672 cls ( imgbuf – ) clear image buffer<br />
674 setpal ( b g r color – ) set palette value for specified color.<br />
675                 values bust be in size 0 - 63.<br />
677 putchar ( char color x y imgbuf – ) put graphic character in<br />
678                 imagebuffer to specified (x & y) location.<br />
680 scroll ( x y imgbuf – ) scroll in imgbuf.<br />
682 scrollf ( color x y screen – ) scroll and fill empty space with<br />
683                 given color.<br />
685 at! ( x y – ) set cursor location<br />
686 curc! ( color – ) set text color<br />
687 curb! ( solor – ) set backround color<br />
689 colnorm ( – ) set text color to normal<br />
690 colneg ( – ) set text color to negative (selected)<br />
692 dyntype ( dynhandle – ) display contenc of dynamic memory on screen<br />
693 fsdisp ( file – ) clear screen, display file, and wait for key<br />
695 type ( addr length – )<br />
696                 Types on the screen string, from memory at addr and<br />
697                 specified length.<br />
699 write ( addr – )<br />
700                 Types on the screen string, from memory at "addr"+1<br />
701                 length is taken from "addr" .<br />
703 screen const 32 bit<br />
704                 Holds handle of screen buffer.<br />
706 copyscreen ( SrcImgHandle DestImgHandle – ) copy contenc of source<br />
707                 image to destination image. Source and destination images<br />
708                 must have same size.<br />
712 <div id="outline-container-org4c1d973" class="outline-3">
713 <h3 id="org4c1d973"><span class="section-number-3">2.6.</span> Math, memory & stack manipulation</h3>
714 <div class="outline-text-3" id="text-2-6">
716 off ( n – ) writes 0 to given address, good for zeroing variable.<br />
717                 ex: MyVariable off<br />
718 on ( n – ) writes -1 (true flag) to given address.<br />
719                 ex: MyVariable on<br />
721 2dup ( n1 n2 – n1 n2 n1 n2 )<br />
722 2drop ( n1 n2 – )<br />
723 nip ( n1 n2 – n2 )<br />
724 neg ( n1 – -n1 ) negotiate<br />
725 bit@ ( n bit – result ) return specified bit from n.<br />
726                 ex: 38 2 bit@ (result will be 1)<br />
727 to32bit ( n1 n2 n3 n4 – n32 ) treat 4 last stack elements as bytes<br />
728                 and unite them into 32 bit dword. Most significant byte<br />
729                 on top.<br />
730                 ex: 12 76 23 11 to32bit result: 186076172<br />
732 to8bit ( n32 – n1 n2 n3 n4 ) break 32 bit number into 4 bytes.<br />
733                 Useful if you need to send 32 bit numbers thru 8 bit COM<br />
734                 port.<br />
735                 ex: 186076172 to8bit result: 12 76 23 11<br />
737 mod ( n1 n2 – reminder ) divide n1 by n2 and returns reminder.<br />
738                 ex: 12 5 mod result: 2<br />
740 bound ( low n high – n ) check if n is in given bounds,<br />
741                 if not then incarease/decarease it to match bounds.<br />
742                 ex: 5 80 15 bound result: 15<br />
743                     5 10 15 bound result: 10<br />
744                     5 -10 15 bound result: 5<br />
746 bound? ( low n high – result ) returns true if n is in the<br />
747                 given bounds.<br />
749 tab ( col – spaces) calculate amount of spaces to add<br />
750                 ta reach next tabulation from given column.<br />
752 count ( addr – addr+1 n )<br />
753                 Useful for returning bytes from constantly incareasing<br />
754                 address. Module "type" is nice example.<br />
756 c, ( n – )<br />
757                 store one byte at memory specified by "h". And incarease<br />
758                 "h" by 1.<br />
760 , ( n – )<br />
761                 store 32 bit number at memory specified by "h". And<br />
762                 incarease "h" by 4.<br />
764 cmove ( addr1 addr2 n – )<br />
765                 copy "n" amount of bytes from memory at "addr1" to memory<br />
766                 at "addr2".<br />
768 rnd ( limit – result )<br />
769                 generates random number in range 0 to "limit"-1.<br />
771 abs ( n – |n| )<br />
772                 returns absolute value of "n"<br />
776 <div id="outline-container-org0c4a738" class="outline-3">
777 <h3 id="org0c4a738"><span class="section-number-3">2.7.</span> Dynamic & static strings</h3>
778 <div class="outline-text-3" id="text-2-7">
780 Fifth supports both static and dynamic strings. Static strings must
781 have predefined space reserved, and string mustn't exceed this
782 length. They manipulation is faster. But they use more memory. Static
783 string memory address is used to refer to the string.
787 Dynamic strings can have at any time length form 0 to 0FFh, They take
788 up only memory they currently need. They are held in dynamic memory
789 blocks, so dynamic block handle is used to refer to this string.
793 Both types of strings are stored in the way, where first (0th) byte
794 holds current string length, following bytes are string itself.
801 Dstral ( – handle )<br />
802                 Allocate new string.<br />
804 Dstrlen ( handle – length )<br />
805                 Return string length.<br />
807 c+Dstr ( chr handle – )<br />
808                 Add one byte to end of the string.<br />
810 c+lDstr ( chr handle – )<br />
811                 Add one byte to left side (beginning) of the string.<br />
813 Dstr. ( handle – )<br />
814                 Write contec of string into screen.<br />
816 Dstrsure ( size Dstr – )<br />
817                 Makes sure that at least rquested<br />
818                 "size" (amount of characters) is allocated for given<br />
819                 dynamic string.<br />
821 Dstr2str ( handle address – )<br />
822                 Copy dyamic string into static memory space.<br />
824 str2Dstr ( address handle – )<br />
825                 Copy static string into dyamic string.<br />
827 Dstr+str ( Dstr addr – )<br />
828                 Add contenc of dynamic string to static string.<br />
830 D" any string" ( – Dstr )<br />
831                 Moves specified string into dynamic string called "defDstr".<br />
833 D> any_string ( – Dstr )<br />
834                 Moves specified string into dynamic string called "defDstr".<br />
835                 Space marks end of string!<br />
837 D>2 any_string ( – Dstr )<br />
838                 Moves specified string into dynamic string called "defDstr2".<br />
839                 Space marks end of string!<br />
841 Dstr+Dstr ( Dstr1 Dstr2 – )<br />
842                 Adds "Dstr1" to "Dstr2" and places result into "Dstr2".<br />
844 Dstrclear ( Dstr – )<br />
845                 Clears contenc of dynamic string.<br />
847 Dstr2Dstr ( Dstr1 Dstr2 – )<br />
848                 Moves "Dstr1" to "Dstr2".<br />
849 Dstr ( data" name – )<br />
850                 Creates new dynamic string and moves specified data into it.<br />
851                 Then creates new constant with given "name" holding created<br />
852                 dynamic string handle.<br />
854                 ex: Dstr Hello, my name is Sven!" message \ creates it<br />
855                     message Dstr. \ tests it<br />
857 Dstrlscan ( char Dstr – loc )<br />
858                 Searches dynamic string for "char", from left to right,<br />
859                 returns first found "char" location in string, or 0,<br />
860                 if not found.<br />
862 Dstrrscan ( char Dstr – loc )<br />
863                 Searches dynamic string for "char", from right to left,<br />
864                 returns first found "char" location in string, or 0,<br />
865                 if not found.<br />
867 Dstrlscane ( char Dstr – loc )<br />
868                 Same as "Dstrlscan" buf returns string length+1 as location.<br />
870 Dstrleft ( amo Dstr – )<br />
871                 Only specified amount of characters from left remains<br />
872                 in dynamic string. ie. cut right part out.<br />
874 Dstrright ( amo Dstr – )<br />
875                 Only specified amount of characters from right remains<br />
876                 in dynamic string. ie. cut left part out.<br />
878 Dstrcutl ( amo Dstr – )<br />
879                 Cut specified amount of characters from left of dynamic<br />
880                 string out.<br />
882 Dstrsp ( char Dstr1 Dstr2 – )<br />
883                 Separate dynamic string in Dstr1 into two parts,<br />
884                 using "char" as separator. First part will be stored in<br />
885                 "Dstr2", second part in "Dstr1".<br />
886                 ex: asc \ \ ..separator<br />
887                     D> listF\listLIB\5TH_DRVMOUSE \ ..separate from<br />
888                     defDstr2 \ ..place result in<br />
889                     Dstrsp \ separation command<br />
890                     defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE<br />
891                     defDstr2 Dstr. \ will be: listF<br />
893 Dv ( addr – )<br />
894                 Allocates empty dynamic string, and places it's handle<br />
895                 into given address.<br />
897 Df ( addr – )<br />
898                 Reads dynamic string handle from given address and<br />
899                 deallocates (frees) it.<br />
901 ex: var mystring1<br />
902         : testmodule<br />
903         mystring1 Dv \ allocates string<br />
905                 <whatever><br />
907         mystring1 Df ; \ deallocates it again when no longer needed.<br />
913 <div id="postamble" class="status">
914 <p class="author">Author: Svjatoslav Agejenko</p>
915 <p class="date">Created: 2023-09-18 Mon 01:47</p>
916 <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>