Rephrased documentation for better readability
[fifth.git] / doc / index.html
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <title>Fifth - virtual machine, operating system, programming language</title>
5 <!-- 2020-05-02 Sat 00:04 -->
6 <meta charset="utf-8">
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <meta name="generator" content="Org-mode">
9 <meta name="author" content="Svjatoslav Agejenko">
10 <link href="https://bootswatch.com/3/darkly/bootstrap.min.css" rel="stylesheet">
11 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
12 <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
13 <style type="text/css">
14 footer {background-color: #111 !important;}
15 pre {background-color: #111; color: #ccc;}
16 </style>
17 <style type="text/css">
18 /* org mode styles on top of twbs */
19
20 html {
21     position: relative;
22     min-height: 100%;
23 }
24
25 body {
26     font-size: 18px;
27     margin-bottom: 105px;
28 }
29
30 footer {
31     position: absolute;
32     bottom: 0;
33     width: 100%;
34     height: 101px;
35     background-color: #f5f5f5;
36 }
37
38 footer > div {
39     padding: 10px;
40 }
41
42 footer p {
43     margin: 0 0 5px;
44     text-align: center;
45     font-size: 16px;
46 }
47
48 #table-of-contents {
49     margin-top: 20px;
50     margin-bottom: 20px;
51 }
52
53 blockquote p {
54     font-size: 18px;
55 }
56
57 pre {
58     font-size: 16px;
59 }
60
61 .footpara {
62     display: inline-block;
63 }
64
65 figcaption {
66   font-size: 16px;
67   color: #666;
68   font-style: italic;
69   padding-bottom: 15px;
70 }
71
72 /* from twbs docs */
73
74 .bs-docs-sidebar.affix {
75     position: static;
76 }
77 @media (min-width: 768px) {
78     .bs-docs-sidebar {
79         padding-left: 20px;
80     }
81 }
82
83 /* All levels of nav */
84 .bs-docs-sidebar .nav > li > a {
85     display: block;
86     padding: 4px 20px;
87     font-size: 14px;
88     font-weight: 500;
89     color: #999;
90 }
91 .bs-docs-sidebar .nav > li > a:hover,
92 .bs-docs-sidebar .nav > li > a:focus {
93     padding-left: 19px;
94     color: #A1283B;
95     text-decoration: none;
96     background-color: transparent;
97     border-left: 1px solid #A1283B;
98 }
99 .bs-docs-sidebar .nav > .active > a,
100 .bs-docs-sidebar .nav > .active:hover > a,
101 .bs-docs-sidebar .nav > .active:focus > a {
102     padding-left: 18px;
103     font-weight: bold;
104     color: #A1283B;
105     background-color: transparent;
106     border-left: 2px solid #A1283B;
107 }
108
109 /* Nav: second level (shown on .active) */
110 .bs-docs-sidebar .nav .nav {
111     display: none; /* Hide by default, but at >768px, show it */
112     padding-bottom: 10px;
113 }
114 .bs-docs-sidebar .nav .nav > li > a {
115     padding-top: 1px;
116     padding-bottom: 1px;
117     padding-left: 30px;
118     font-size: 12px;
119     font-weight: normal;
120 }
121 .bs-docs-sidebar .nav .nav > li > a:hover,
122 .bs-docs-sidebar .nav .nav > li > a:focus {
123     padding-left: 29px;
124 }
125 .bs-docs-sidebar .nav .nav > .active > a,
126 .bs-docs-sidebar .nav .nav > .active:hover > a,
127 .bs-docs-sidebar .nav .nav > .active:focus > a {
128     padding-left: 28px;
129     font-weight: 500;
130 }
131
132 /* Nav: third level (shown on .active) */
133 .bs-docs-sidebar .nav .nav .nav {
134     padding-bottom: 10px;
135 }
136 .bs-docs-sidebar .nav .nav .nav > li > a {
137     padding-top: 1px;
138     padding-bottom: 1px;
139     padding-left: 40px;
140     font-size: 12px;
141     font-weight: normal;
142 }
143 .bs-docs-sidebar .nav .nav .nav > li > a:hover,
144 .bs-docs-sidebar .nav .nav .nav > li > a:focus {
145     padding-left: 39px;
146 }
147 .bs-docs-sidebar .nav .nav .nav > .active > a,
148 .bs-docs-sidebar .nav .nav .nav > .active:hover > a,
149 .bs-docs-sidebar .nav .nav .nav > .active:focus > a {
150     padding-left: 38px;
151     font-weight: 500;
152 }
153
154 /* Show and affix the side nav when space allows it */
155 @media (min-width: 992px) {
156     .bs-docs-sidebar .nav > .active > ul {
157         display: block;
158     }
159     /* Widen the fixed sidebar */
160     .bs-docs-sidebar.affix,
161     .bs-docs-sidebar.affix-bottom {
162         width: 213px;
163     }
164     .bs-docs-sidebar.affix {
165         position: fixed; /* Undo the static from mobile first approach */
166         top: 20px;
167     }
168     .bs-docs-sidebar.affix-bottom {
169         position: absolute; /* Undo the static from mobile first approach */
170     }
171     .bs-docs-sidebar.affix .bs-docs-sidenav,.bs-docs-sidebar.affix-bottom .bs-docs-sidenav {
172         margin-top: 0;
173         margin-bottom: 0
174     }
175 }
176 @media (min-width: 1200px) {
177     /* Widen the fixed sidebar again */
178     .bs-docs-sidebar.affix-bottom,
179     .bs-docs-sidebar.affix {
180         width: 263px;
181     }
182 }
183 </style>
184 <script type="text/javascript">
185 $(function() {
186     'use strict';
187
188     $('.bs-docs-sidebar li').first().addClass('active');
189
190     $(document.body).scrollspy({target: '.bs-docs-sidebar'});
191
192     $('.bs-docs-sidebar').affix();
193 });
194 </script>
195
196 <script type="text/x-mathjax-config">
197 MathJax.Hub.Config({
198   displayAlign: "center",
199   displayIndent: "2em",
200   messageStyle: "none",
201   "HTML-CSS": {
202     scale: 100,
203     styles: {
204       ".MathJax_Display": {
205         "font-size": "100%"
206       }
207     }
208   },
209   "SVG": {
210     scale: 100,
211     styles: {
212       ".MathJax_SVG_Display": {
213         "font-size": "100%",
214         "margin-left": "-2.281em"
215       }
216     }
217   }
218 });
219 </script>
220 <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_SVG"></script>
221 </head>
222 <body>
223 <div id="content" class="container">
224 <div class="row"><div class="col-md-9"><h1 class="title">Fifth - virtual machine, operating system, programming language</h1>
225
226 <div id="outline-container-sec-1" class="outline-2">
227 <h2 id="sec-1"><span class="section-number-2">1</span> General</h2>
228 <div class="outline-text-2" id="text-1">
229 <ul class="org-ul">
230 <li>This program is free software: released under Creative Commons Zero
231 (CC0) license
232 </li>
233
234 <li>Program author:
235 <ul class="org-ul">
236 <li>Svjatoslav Agejenko
237 </li>
238 <li>Homepage: <a href="https://svjatoslav.eu">https://svjatoslav.eu</a>
239 </li>
240 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a>
241 </li>
242 </ul>
243 </li>
244
245 <li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a>
246 </li>
247 </ul>
248 </div>
249 <div id="outline-container-sec-1-1" class="outline-3">
250 <h3 id="sec-1-1"><span class="section-number-3">1.1</span> Source code</h3>
251 <div class="outline-text-3" id="text-1-1">
252 <ul class="org-ul">
253 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=snapshot;h=HEAD;sf=tgz">Download latest snapshot in TAR GZ format</a>
254 </li>
255
256 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=summary">Browse Git repository online</a>
257 </li>
258
259 <li>Clone Git repository using command:
260 <pre class="example">
261 git clone https://www2.svjatoslav.eu/git/fifth.git
262
263 </pre>
264 </li>
265 </ul>
266 </div>
267 </div>
268 </div>
269
270 <div id="outline-container-sec-2" class="outline-2">
271 <h2 id="sec-2"><span class="section-number-2">2</span> !Project deprecated!</h2>
272 <div class="outline-text-2" id="text-2">
273 <p>
274 Current implementation does not support object oriented
275 programming. While working on Fifth I got lots of cool new ideas that
276 require reimplementation of everything.
277 </p>
278
279 <p>
280 Currently I try to implement those new ideas in the project called
281 <a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
282 </p>
283
284 <p>
285 System is built many years ago when I was still using DOS as a primary
286 operating system.
287 </p>
288 </div>
289 </div>
290 <div id="outline-container-sec-3" class="outline-2">
291 <h2 id="sec-3"><span class="section-number-2">3</span> Introduction</h2>
292 <div class="outline-text-2" id="text-3">
293 <p>
294 Fifth is programming lanquage &amp; operating system, running on <a href="#sec-10">virtual
295 machine</a>, with custom instruction set. It is much like Charles Chunk
296 Moore's Forth, it also uses stack architecture, and many commands are
297 similar. Basically I got familiar with concepts of Forth, and being
298 inspired created my own system.
299 </p>
300
301 <ul class="org-ul">
302 <li><a href="5TH_ET.txt">Example Fifth source file - text editor</a>
303 </li>
304 </ul>
305 </div>
306 <div id="outline-container-sec-3-1" class="outline-3">
307 <h3 id="sec-3-1"><span class="section-number-3">3.1</span> screenshots</h3>
308 <div class="outline-text-3" id="text-3-1">
309 <ul class="org-ul">
310 <li><img src="screenshots/start.png" class="img-responsive" alt="start.png">
311 <ul class="org-ul">
312 <li>Startup screen diplaying Fifth logo and full file list.
313 </li>
314 </ul>
315 </li>
316
317 <li><img src="screenshots/dictionary.png" class="img-responsive" alt="dictionary.png">
318 <ul class="org-ul">
319 <li>Sample words defined. Most of the words are commands that can be
320 executed interactively from command line or from file. When
321 executed they can be selectively compiled or interpreted.
322 </li>
323 </ul>
324 </li>
325
326 <li><img src="screenshots/text editor.png" class="img-responsive" alt="text editor.png">
327 <ul class="org-ul">
328 <li>Built in text editor.
329 </li>
330 </ul>
331 </li>
332 </ul>
333 </div>
334 </div>
335 </div>
336
337 <div id="outline-container-sec-4" class="outline-2">
338 <h2 id="sec-4"><span class="section-number-2">4</span> Installation</h2>
339 <div class="outline-text-2" id="text-4">
340 <p>
341 Just unpack all files, witout altering original directory structure,
342 somewhere in your hard disk. For example: C:\MISC\FIFTH\&#x2026;.  To run
343 fifth you need minimally just 2 files.  emulator itself ( EMULATOR.EXE
344 or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
345 </p>
346
347 <p>
348 Read more about <a href="#sec-5">Fifth distribution directory tree description</a>.
349 </p>
350 </div>
351 </div>
352
353 <div id="outline-container-sec-5" class="outline-2">
354 <h2 id="sec-5"><a id="ID-0759f3e0-28bb-4901-9e4f-09ef41732173" name="ID-0759f3e0-28bb-4901-9e4f-09ef41732173"></a><span class="section-number-2">5</span> Fifth distribution directory tree description</h2>
355 <div class="outline-text-2" id="text-5">
356 <p>
357 After downloading and unpacking the ZIP file you shoud get directory
358 tree similar to this:
359 </p>
360
361 <p class="verse">
362 [DOC]                   - Fifth documentation<br >
363 &#xa0;&#xa0;[commands]            - documentation on Fifth built-in commands<br >
364 &#xa0;&#xa0;[modules]             - documentation on additional commands, realized as loadable modules<br >
365 &#xa0;&#xa0;[shots]               - Fifth screenshots<br >
366 <br >
367 [imageFile]             - files contained within 'disk.raw', just an extracted form.<br >
368 <br >
369 [source]                - source files<br >
370 &#xa0;&#xa0;[emulator]            - emulator source<br >
371 &#xa0;&#xa0;[util]                - utilites<br >
372 <br >
373 disk.raw                - Virtual disk file, has filesystem inside.<br >
374 emulator.com            - main executable.<br >
375 </p>
376 </div>
377 </div>
378
379 <div id="outline-container-sec-6" class="outline-2">
380 <h2 id="sec-6"><span class="section-number-2">6</span> Software/Hardware/Human requirements</h2>
381 <div class="outline-text-2" id="text-6">
382 </div><div id="outline-container-sec-6-1" class="outline-3">
383 <h3 id="sec-6-1"><span class="section-number-3">6.1</span> Software</h3>
384 <div class="outline-text-3" id="text-6-1">
385 <ul class="org-ul">
386 <li>MS-DOS 6.22, with HIMEM.SYS loaded.
387 </li>
388 <li>Mouse driver if you have a mouse.
389 </li>
390 <li>Does work only when CPU is in real mode.
391 </li>
392 <li>To recompile ASM sources I used FASM (Flat Assembler).
393 </li>
394 <li>I ran QBasic utilities on QB 4.5 .
395 </li>
396 <li>VESA support by BIOS, or external driver (UNIVBE).
397 </li>
398 </ul>
399 </div>
400 </div>
401 <div id="outline-container-sec-6-2" class="outline-3">
402 <h3 id="sec-6-2"><span class="section-number-3">6.2</span> Hardware</h3>
403 <div class="outline-text-3" id="text-6-2">
404 <ul class="org-ul">
405 <li>Minimum CPU 386.
406 </li>
407 <li>64 KB free RAM below 640KB,
408 </li>
409 <li>2 MB of free XMS.
410 </li>
411 <li>VESA compatible video card.
412 </li>
413 </ul>
414 </div>
415 </div>
416 <div id="outline-container-sec-6-3" class="outline-3">
417 <h3 id="sec-6-3"><span class="section-number-3">6.3</span> Human</h3>
418 <div class="outline-text-3" id="text-6-3">
419 <ul class="org-ul">
420 <li>Beginner level Forth knowledge is recommended.
421 </li>
422 <li>Lots of enthusiasm.
423 </li>
424 </ul>
425 </div>
426 </div>
427 </div>
428 <div id="outline-container-sec-7" class="outline-2">
429 <h2 id="sec-7"><span class="section-number-2">7</span> Numbers representation within Fifth</h2>
430 <div class="outline-text-2" id="text-7">
431 <p>
432 <a href="numbers.png">file:numbers.png</a>
433 </p>
434
435 <p>
436 Because I can define everything, starting from CPU, why not try also
437 alternative and unique number representation ?
438 </p>
439
440 <p>
441 Fifth uses its hexdecimal number representation as primary. Numbers
442 shape is formed by dividing a square into four parts. And manipulating
443 their color (black or white).
444 </p>
445 </div>
446 </div>
447 <div id="outline-container-sec-8" class="outline-2">
448 <h2 id="sec-8"><span class="section-number-2">8</span> Disk file map, and it's data structures</h2>
449 <div class="outline-text-2" id="text-8">
450 <p>
451 Core and high-level boot code is stored outside of the filesystem to
452 allow easy access to it, at early booting time, when filesystem is not
453 yet initialized.
454 </p>
455 </div>
456 <div id="outline-container-sec-8-1" class="outline-3">
457 <h3 id="sec-8-1"><span class="section-number-3">8.1</span> disk allocation</h3>
458 <div class="outline-text-3" id="text-8-1">
459 <table class="table table-striped table-bordered table-hover table-condensed">
460
461
462 <colgroup>
463 <col  class="left">
464
465 <col  class="left">
466
467 <col  class="left">
468 </colgroup>
469 <thead>
470 <tr>
471 <th scope="col" class="text-left">offset</th>
472 <th scope="col" class="text-left">length</th>
473 <th scope="col" class="text-left">description</th>
474 </tr>
475 </thead>
476 <tbody>
477 <tr>
478 <td class="text-left">0</td>
479 <td class="text-left">~4 Kb</td>
480 <td class="text-left">Fifth core</td>
481 </tr>
482
483 <tr>
484 <td class="text-left">4 Kb</td>
485 <td class="text-left">~32Kb</td>
486 <td class="text-left">high-level boot code</td>
487 </tr>
488
489 <tr>
490 <td class="text-left">37 Kb</td>
491 <td class="text-left">~65Kb</td>
492 <td class="text-left">FAT</td>
493 </tr>
494
495 <tr>
496 <td class="text-left">101Kb</td>
497 <td class="text-left">~16MB</td>
498 <td class="text-left">filesystem data area</td>
499 </tr>
500 </tbody>
501 </table>
502 </div>
503 </div>
504 <div id="outline-container-sec-8-2" class="outline-3">
505 <h3 id="sec-8-2"><span class="section-number-3">8.2</span> FAT entry format:</h3>
506 <div class="outline-text-3" id="text-8-2">
507 <table class="table table-striped table-bordered table-hover table-condensed">
508
509
510 <colgroup>
511 <col  class="right">
512
513 <col  class="left">
514 </colgroup>
515 <thead>
516 <tr>
517 <th scope="col" class="text-right">code</th>
518 <th scope="col" class="text-left">meaning</th>
519 </tr>
520 </thead>
521 <tbody>
522 <tr>
523 <td class="text-right">-2</td>
524 <td class="text-left">last sector</td>
525 </tr>
526
527 <tr>
528 <td class="text-right">-1</td>
529 <td class="text-left">empty sector</td>
530 </tr>
531
532 <tr>
533 <td class="text-right">0 --</td>
534 <td class="text-left">.. pointer to next block</td>
535 </tr>
536 </tbody>
537 </table>
538 </div>
539 </div>
540 <div id="outline-container-sec-8-3" class="outline-3">
541 <h3 id="sec-8-3"><span class="section-number-3">8.3</span> file entry format</h3>
542 <div class="outline-text-3" id="text-8-3">
543 <table class="table table-striped table-bordered table-hover table-condensed">
544
545
546 <colgroup>
547 <col  class="right">
548
549 <col  class="right">
550
551 <col  class="left">
552 </colgroup>
553 <thead>
554 <tr>
555 <th scope="col" class="text-right">offset</th>
556 <th scope="col" class="text-right">length</th>
557 <th scope="col" class="text-left">description</th>
558 </tr>
559 </thead>
560 <tbody>
561 <tr>
562 <td class="text-right">0</td>
563 <td class="text-right">4</td>
564 <td class="text-left">extension</td>
565 </tr>
566
567 <tr>
568 <td class="text-right">4</td>
569 <td class="text-right">16</td>
570 <td class="text-left">name</td>
571 </tr>
572
573 <tr>
574 <td class="text-right">20</td>
575 <td class="text-right">4</td>
576 <td class="text-left">entry point</td>
577 </tr>
578
579 <tr>
580 <td class="text-right">24</td>
581 <td class="text-right">4</td>
582 <td class="text-left">size</td>
583 </tr>
584
585 <tr>
586 <td class="text-right">28</td>
587 <td class="text-right">4</td>
588 <td class="text-left">last modification time</td>
589 </tr>
590 </tbody>
591 </table>
592 </div>
593 </div>
594 </div>
595 <div id="outline-container-sec-9" class="outline-2">
596 <h2 id="sec-9"><span class="section-number-2">9</span> Core architecture</h2>
597 <div class="outline-text-2" id="text-9">
598 <p>
599 Fifth core is simply some amount of already compiled into machine code
600 and linked together modules (entries in other words). In compilation
601 process modules is compiled one by one and simply stored on top of
602 already existing and growing core. Separately from core is kept
603 dictionary, this is special list that contain names of compiled
604 modules, variables etc. and they locations in core. Constants use
605 dictionary space only. Random word can be removed from dictionary at
606 any time. Currently dictionary can contain at most 1000 entries.
607 </p>
608 </div>
609 <div id="outline-container-sec-9-1" class="outline-3">
610 <h3 id="sec-9-1"><span class="section-number-3">9.1</span> Dictionary entry format</h3>
611 <div class="outline-text-3" id="text-9-1">
612 <table class="table table-striped table-bordered table-hover table-condensed">
613
614
615 <colgroup>
616 <col  class="right">
617
618 <col  class="right">
619
620 <col  class="left">
621 </colgroup>
622 <thead>
623 <tr>
624 <th scope="col" class="text-right">offset</th>
625 <th scope="col" class="text-right">length</th>
626 <th scope="col" class="text-left">description</th>
627 </tr>
628 </thead>
629 <tbody>
630 <tr>
631 <td class="text-right">0</td>
632 <td class="text-right">4</td>
633 <td class="text-left">0 &amp;lt; previous entry</td>
634 </tr>
635
636 <tr>
637 <td class="text-right">&#xa0;</td>
638 <td class="text-right">&#xa0;</td>
639 <td class="text-left">0 = last</td>
640 </tr>
641
642 <tr>
643 <td class="text-right">&#xa0;</td>
644 <td class="text-right">&#xa0;</td>
645 <td class="text-left">-1 = empty</td>
646 </tr>
647 </tbody>
648 <tbody>
649 <tr>
650 <td class="text-right">4</td>
651 <td class="text-right">15</td>
652 <td class="text-left">module name string</td>
653 </tr>
654 </tbody>
655 <tbody>
656 <tr>
657 <td class="text-right">19</td>
658 <td class="text-right">1</td>
659 <td class="text-left">entry type</td>
660 </tr>
661 </tbody>
662 <tbody>
663 <tr>
664 <td class="text-right">20</td>
665 <td class="text-right">4</td>
666 <td class="text-left">entry data</td>
667 </tr>
668 </tbody>
669 </table>
670
671 <p>
672 Core headers as linked list of module names make up something like
673 dictionary.  When some entry address is needed compiler can quickly
674 run through headers backwards and find needed entry.
675 </p>
676 </div>
677 </div>
678 <div id="outline-container-sec-9-2" class="outline-3">
679 <h3 id="sec-9-2"><span class="section-number-3">9.2</span> Possible module types</h3>
680 <div class="outline-text-3" id="text-9-2">
681 <table class="table table-striped table-bordered table-hover table-condensed">
682
683
684 <colgroup>
685 <col  class="right">
686
687 <col  class="left">
688
689 <col  class="left">
690 </colgroup>
691 <thead>
692 <tr>
693 <th scope="col" class="text-right">type</th>
694 <th scope="col" class="text-left">description</th>
695 <th scope="col" class="text-left">"execute" action</th>
696 </tr>
697 </thead>
698 <tbody>
699 <tr>
700 <td class="text-right">0</td>
701 <td class="text-left">data</td>
702 <td class="text-left">compile "num" instruction</td>
703 </tr>
704
705 <tr>
706 <td class="text-right">&#xa0;</td>
707 <td class="text-left">&#xa0;</td>
708 <td class="text-left">with address to module</td>
709 </tr>
710 </tbody>
711 <tbody>
712 <tr>
713 <td class="text-right">1</td>
714 <td class="text-left">submodule</td>
715 <td class="text-left">compile "call" instruction</td>
716 </tr>
717
718 <tr>
719 <td class="text-right">&#xa0;</td>
720 <td class="text-left">&#xa0;</td>
721 <td class="text-left">with address to module</td>
722 </tr>
723 </tbody>
724 <tbody>
725 <tr>
726 <td class="text-right">2</td>
727 <td class="text-left">imm. submodule</td>
728 <td class="text-left">immediately call to module</td>
729 </tr>
730 </tbody>
731 </table>
732 </div>
733 </div>
734 <div id="outline-container-sec-9-3" class="outline-3">
735 <h3 id="sec-9-3"><span class="section-number-3">9.3</span> Memory map (average)</h3>
736 <div class="outline-text-3" id="text-9-3">
737 <table class="table table-striped table-bordered table-hover table-condensed">
738
739
740 <colgroup>
741 <col  class="right">
742
743 <col  class="left">
744
745 <col  class="left">
746 </colgroup>
747 <thead>
748 <tr>
749 <th scope="col" class="text-right">&lt;loc&gt;</th>
750 <th scope="col" class="text-left">&lt;size&gt;</th>
751 <th scope="col" class="text-left">&lt;desc&gt;</th>
752 </tr>
753 </thead>
754 <tbody>
755 <tr>
756 <td class="text-right">0</td>
757 <td class="text-left">~4096</td>
758 <td class="text-left">core</td>
759 </tr>
760
761 <tr>
762 <td class="text-right">1500000</td>
763 <td class="text-left">~32000</td>
764 <td class="text-left">highlevel Fifth boot code</td>
765 </tr>
766
767 <tr>
768 <td class="text-right">200000h</td>
769 <td class="text-left">&#xa0;</td>
770 <td class="text-left">core startup messages area</td>
771 </tr>
772
773 <tr>
774 <td class="text-right">5200000</td>
775 <td class="text-left">&#xa0;</td>
776 <td class="text-left">end of dynamic memory space</td>
777 </tr>
778 </tbody>
779 </table>
780 </div>
781 </div>
782 </div>
783 <div id="outline-container-sec-10" class="outline-2">
784 <h2 id="sec-10"><a id="ID-9b251eb9-aff6-4025-94bf-25e89e26d54a" name="ID-9b251eb9-aff6-4025-94bf-25e89e26d54a"></a><span class="section-number-2">10</span> Virtual machine</h2>
785 <div class="outline-text-2" id="text-10">
786 <p>
787 Using CPU emulator slows it down but I shouldn't now think too mutch
788 about, and waste my time on batteling with problems whitch results on
789 complex design of PC hardware. Also it allows me to use existing DOS
790 and resident drivers services in real mode. So I don't need to deal
791 with hardware too mutch. It also allows me to use all free XMS for
792 flat code &amp; data storage.
793 </p>
794
795 <p>
796 Current emulator emulates 1 CPU. It has 2 stacks, ~50 instructions,
797 and 4GB flat address space (theoretically).  I'm not sure that DOS
798 6.22 that I currently prefer can handle more than 64 MB of RAM. While
799 I tried to keep instructionset simple, I was forced to put in lot of
800 complex instructions to make it's performance acceptable on
801 emulator. On actual silicon ~20 instructions is enaugh (I think).
802 </p>
803
804 <p>
805 Maybe one day similar system will run directly on custom silicon chip :)
806 </p>
807
808
809 <p>
810 CPU has following registers:
811 </p>
812 <table class="table table-striped table-bordered table-hover table-condensed">
813
814
815 <colgroup>
816 <col  class="left">
817
818 <col  class="left">
819 </colgroup>
820 <tbody>
821 <tr>
822 <td class="text-left">IP</td>
823 <td class="text-left">instruction pointer</td>
824 </tr>
825
826 <tr>
827 <td class="text-left">DSP</td>
828 <td class="text-left">data stack pointer</td>
829 </tr>
830
831 <tr>
832 <td class="text-left">RSP</td>
833 <td class="text-left">return stack pointer</td>
834 </tr>
835 </tbody>
836 </table>
837
838 <p>
839 Virtual CPU, commands (most of them are avaiable as ordinary commands
840 in programming lanquage):
841 </p>
842
843 <p class="verse">
844 <br >
845 code    mnemonic        description<br >
846 <br >
847 0       nop                     does notheing<br >
848 1       halt            halt CPU ( return to DOS on emulator )<br >
849 <br >
850 2       kbd@            ( &#x2013; c ) read scancode of pressed or released key.<br >
851 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Returns 0, if no data avaiable.<br >
852 3       num &lt;dword&gt;     ( &#x2013; n ) put immidiate number into datastack<br >
853 <br >
854 4       jmp &lt;dword&gt;     jump to specified code<br >
855 5       call &lt;dword&gt;jump to specified code, save return address to<br >
856 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;return stack.<br >
857 <br >
858 6       1+                      ( n &#x2013; n+1 )<br >
859 7       1-                      ( n &#x2013; n-1 )<br >
860 <br >
861 8       dup                     ( n &#x2013; n n ) duplicate top of data stack<br >
862 9       drop            ( n &#x2013; ) drop last element in data stack<br >
863 <br >
864 10      if &lt;dword&gt;      ( n &#x2013; ) jump to addr if top element was 0<br >
865 11      ret                     jump to code, specified in return stack.<br >
866 <br >
867 12      c@                      ( addr &#x2013; n ) read byte from memory at specified address<br >
868 13      c!                      ( n addr &#x2013; ) store byte to specified memory<br >
869 <br >
870 14      push            ( DSTK -&gt; RSTK ) move top of datastack to returnstack<br >
871 15      pop                     ( RSTK -&gt; DSTK ) move top of returnstack to datastack<br >
872 <br >
873 16      &lt;unused&gt;<br >
874 17      rot                     ( n1 n2 n3 &#x2013; n2 n3 n1) rotate stack elements<br >
875 <br >
876 18      disk@           ( FromDiskSect ToMem &#x2013; ) read 1KB from disk into RAM<br >
877 19      disk!           ( FromMem ToDiskSect &#x2013; ) write 1KB to disk<br >
878 <br >
879 20      @                       ( addr &#x2013; n ) read 32 bit number from memory<br >
880 21      !                       ( n addr &#x2013; ) store 32 bit number to memory<br >
881 <br >
882 22      over            ( n1 n2 &#x2013; n1 n2 n1 ) self explaining &#x2026;<br >
883 23      swap            ( n1 n2 &#x2013; n2 n1 ) -,,-<br >
884 <br >
885 24      +                       ( n1 n2 &#x2013; n1+n2 ) -,,-<br >
886 25      -                       ( n1 n2 &#x2013; n1-n2 ) -,,-<br >
887 <br >
888 26      *                       ( n1 n2 &#x2013; n1*n2 ) -,,-<br >
889 27      /                       ( n1 n2 &#x2013; n1/n2 ) -,,-<br >
890 <br >
891 28      &gt;                       ( n1 n2 &#x2013; result ) is true when n1 &gt; n2<br >
892 29      &lt;                       ( n1 n2 &#x2013; result ) is true when n1 &lt; n2<br >
893 <br >
894 30      not                     ( n1 &#x2013; not_n1 ) logical not<br >
895 31      i                       ( &#x2013; n ) copies top of return stack into datastack<br >
896 <br >
897 32      cprt@           ( addr &#x2013; n ) read one byte from hardware port<br >
898 33      cprt!           ( n addr &#x2013; ) store one byte to hardware port<br >
899 <br >
900 34      i2                      ( &#x2013; n ) like "i" but takes socond top stack element.<br >
901 35      i3                      ( &#x2013; n ) like "i" but takes third top stack element.<br >
902 <br >
903 36      shl                     ( n amount &#x2013; n ) left bit shift<br >
904 37      shr                     ( n amount &#x2013; n ) right bit shift<br >
905 <br >
906 38      or                      ( n1 n2 &#x2013; n ) logical or<br >
907 39      xor                     ( n1 n2 &#x2013; n ) exclusive logical or<br >
908 <br >
909 40      vidmap          ( addr &#x2013; ) copy memory from "addr" to video memory.<br >
910 <br >
911 41      mouse@          ( &#x2013; x y button ) read mouse coordinates &amp; buttons<br >
912 <br >
913 42      vidput          ( addr1 addr2 x y &#x2013; ) put image1 into image2, at<br >
914 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;location x, y. Does clipping, so part of a big image<br >
915 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;can be mapped into smaller one.<br >
916 <br >
917 43      cmove           ( addr1 addr2 amount ) move memory from addr1 to addr2<br >
918 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if addr1 is greater than addr2 then count address<br >
919 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;foward while moving, elseway starts from end and<br >
920 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;counts backwards, so no data loss will occure on<br >
921 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;overlapping.<br >
922 <br >
923 44      cfill           ( c addr amount &#x2013; ) fill memory starting at "addr"<br >
924 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;with "c" bytes.<br >
925 <br >
926 45      tvidput         ( addr1 addr2 x y &#x2013; ) same as "vidput" but treats<br >
927 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;color 255 in source image as transparent.<br >
928 <br >
929 46      depth           ( &#x2013; depth ) returns current depth of data stack.<br >
930 <br >
931 47      charput         ( colorfg colorbg addrsrc addrdest x y )<br >
932 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;draw character to image buffer located at "addrdest"<br >
933 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;to specified x &amp; y location. Decodes 8 bytes from<br >
934 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;source to bits, used to draw character.<br >
935 </p>
936 </div>
937 </div>
938
939 <div id="outline-container-sec-11" class="outline-2">
940 <h2 id="sec-11"><span class="section-number-2">11</span> Fifth source format</h2>
941 <div class="outline-text-2" id="text-11">
942 <p>
943 Fifth uses a different character table and codes than ASCII (still
944 almost similar). I call it FSCII (Fifth Standard Code for Information
945 Interchange) for example space character is not 32 but 255 instead.  I
946 plan to use mainly HEX numbers, and create new characters to represent
947 numeric values. So typical nemric characters "0123&#x2026;"  is treated
948 like ordinary letters.
949 </p>
950 </div>
951 <div id="outline-container-sec-11-1" class="outline-3">
952 <h3 id="sec-11-1"><span class="section-number-3">11.1</span> FSCII</h3>
953 <div class="outline-text-3" id="text-11-1">
954 <table class="table table-striped table-bordered table-hover table-condensed">
955
956
957 <colgroup>
958 <col  class="right">
959
960 <col  class="left">
961
962 <col  class="left">
963 </colgroup>
964 <thead>
965 <tr>
966 <th scope="col" class="text-right">DEC</th>
967 <th scope="col" class="text-left">HEX</th>
968 <th scope="col" class="text-left">function</th>
969 </tr>
970 </thead>
971 <tbody>
972 <tr>
973 <td class="text-right">0 - 15</td>
974 <td class="text-left">0 - F</td>
975 <td class="text-left">HEX numbers</td>
976 </tr>
977
978 <tr>
979 <td class="text-right">252</td>
980 <td class="text-left">FC</td>
981 <td class="text-left">backspace</td>
982 </tr>
983
984 <tr>
985 <td class="text-right">253</td>
986 <td class="text-left">FD</td>
987 <td class="text-left">tabulator (TAB)</td>
988 </tr>
989
990 <tr>
991 <td class="text-right">254</td>
992 <td class="text-left">FE</td>
993 <td class="text-left">carriage return (CR)</td>
994 </tr>
995
996 <tr>
997 <td class="text-right">255</td>
998 <td class="text-left">FF</td>
999 <td class="text-left">space</td>
1000 </tr>
1001
1002 <tr>
1003 <td class="text-right">else</td>
1004 <td class="text-left">&#xa0;</td>
1005 <td class="text-left">ordinary characters, same as in ASCII.</td>
1006 </tr>
1007 </tbody>
1008 </table>
1009 </div>
1010 </div>
1011 </div>
1012 <div id="outline-container-sec-12" class="outline-2">
1013 <h2 id="sec-12"><span class="section-number-2">12</span> Fifth commands</h2>
1014 <div class="outline-text-2" id="text-12">
1015 </div><div id="outline-container-sec-12-1" class="outline-3">
1016 <h3 id="sec-12-1"><span class="section-number-3">12.1</span> Compilation &amp; miscellaneous</h3>
1017 <div class="outline-text-3" id="text-12-1">
1018 <p class="verse">
1019 init    module  ( &#x2013; )<br >
1020 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;First module, control is passed to on startup. Contains<br >
1021 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;initialization routines. Also it is the last core module.<br >
1022 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;All new modules on top of it comes as result of executing<br >
1023 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;external source files.<br >
1024 <br >
1025 head &lt;name&gt;     ( &#x2013; )  compiles new dictionary entry without specifying<br >
1026 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;new module type.<br >
1027 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: head myentry<br >
1028 <br >
1029 : &lt;name&gt;        ( &#x2013; )  creates new code module<br >
1030 ;               ( &#x2013; )  ends module (immideate)<br >
1031 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: : hello ." hi there" ;<br >
1032 <br >
1033 const &lt;name&gt;    ( n &#x2013; ) defines new constant.<br >
1034 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 2147483647 const max<br >
1035 <br >
1036 :i &lt;name&gt;       ( &#x2013; ) same as ":" but this module will be executed<br >
1037 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;immideately even in compile mode.<br >
1038 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: :i ( 41 scan ;<br >
1039 <br >
1040 create &lt;name&gt;   ( &#x2013; ) same as "head" , but specify module type as data.<br >
1041 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,<br >
1042 <br >
1043 allot           ( n &#x2013; ) allocate n bytes in dictionary.<br >
1044 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: create MyArray 100 allot<br >
1045 <br >
1046 " &lt;string&gt;"     ( &#x2013; ) compile string and its size into core.<br >
1047 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: create Mystring " This is it's contects"<br >
1048 <br >
1049 str &lt;name&gt; &lt;string&gt;" ( &#x2013; ) just shorter way for defining strings.<br >
1050 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: str Mystring This is it's contenc"<br >
1051 <br >
1052 var &lt;name&gt;      ( &#x2013; ) define new 32 bit variable.<br >
1053 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: var result<br >
1054 <br >
1055 ' &lt;module&gt;      ( &#x2013; n ) return memory address of given entry.<br >
1056 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: ' init<br >
1057 <br >
1058 forget &lt;name&gt;   ( &#x2013; ) erases from RAM given entry and all entries what was<br >
1059 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;defined after it.<br >
1060 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: forget myprog<br >
1061 <br >
1062 [               ( &#x2013; )  set interpret mode (immideate)<br >
1063 ]               ( n &#x2013; ) set compile mode and compile top stack element<br >
1064 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;in as literal. Together [ &#x2026;. ] cobination provides good<br >
1065 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;way to compute some values only once, at compile time,<br >
1066 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;rather than every time while program is running.<br >
1067 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;<br >
1068 <br >
1069 defer &lt;name&gt;    ( &#x2013; ) creates new module, with jump instruction.<br >
1070 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Later address where to jump can be modified by "is" command.<br >
1071 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;This provides method of foward referencing. So you can use<br >
1072 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;modules what not jet exist.<br >
1073 is              ( address1 address2 &#x2013; ) address1 - where to jump, address2 -<br >
1074 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;address of module created by defer command.<br >
1075 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex:     defer dispver<br >
1076 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;: run dispver ." running &#x2026;" ;<br >
1077 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#x2026; whatever &#x2026;<br >
1078 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;: (dispver ." Version 9.99 " ;<br >
1079 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;' (dispver ' dispver is<br >
1080 <br >
1081 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Now if I type "run" on the screen appears:<br >
1082 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Version 9.99 running &#x2026;<br >
1083 <br >
1084 asc &lt;char&gt;      ( &#x2013; ) reads char ascii code and treats it as literal.<br >
1085 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;(immideate)<br >
1086 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: : BreakLine 30 do asc - emit loop ;<br >
1087 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;same as:<br >
1088 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;: BreakLine 30 do    45 emit loop ;<br >
1089 <br >
1090 dyninc          ( handle &#x2013; ) execute code in dynamic memory handle.<br >
1091 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;automatically deallocates it when done.<br >
1092 <br >
1093 include         ( filenumber &#x2013; ) execute code in specified file.<br >
1094 <br >
1095 words           ( &#x2013; ) display existing blocks in core.<br >
1096 <br >
1097 bye             ( &#x2013; ) exit from Fifth<br >
1098 <br >
1099 fkey            ( &#x2013; c )<br >
1100 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Read one byte from input stream.<br >
1101 <br >
1102 sadd            ( c addr &#x2013; )<br >
1103 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Add one byte "c" to string located at "addr" and updates<br >
1104 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;string length.<br >
1105 <br >
1106 scan            ( c &#x2013; )<br >
1107 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Read input stream and store it to  pad   until it finds  c  .<br >
1108 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;It ignores all "c" bytes until it finds any non "c" byte.<br >
1109 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;in other words:<br >
1110 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;c  is:  "<br >
1111 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;input stream:  """"This is test !"aoeu idh<br >
1112 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;result:  This is test !<br >
1113 <br >
1114 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Is useful for breaking text lines into words.<br >
1115 <br >
1116 skey            ( &#x2013; c )<br >
1117 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;So called safe "fkey". Reads data from input stream<br >
1118 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;but converts characters with ASCII codes: 9 13 10<br >
1119 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;to spaces.<br >
1120 <br >
1121 str=str?        ( adr1 adr2 &#x2013; result )<br >
1122 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Compares string at "adr1" with string at "adr2", returns<br >
1123 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;true flag if they are equal or false if they are not.<br >
1124 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;true = -1<br >
1125 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;false = 0<br >
1126 <br >
1127 find            ( &#x2013; addr )<br >
1128 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Searches whole dictionary for word in "pad". If found,<br >
1129 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;returns it address, if not, returns 0.<br >
1130 <br >
1131 execute         ( &#x2013; )<br >
1132 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Execute word located in "pad". Depending on "mode".<br >
1133 <br >
1134 dta             ( addr &#x2013; DataAddr )<br >
1135 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Calculates address of dictionary entry data area, from<br >
1136 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;entry point.<br >
1137 <br >
1138 2num            ( &#x2013; num result )<br >
1139 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Attempt to convert string located in "pad" into numeric<br >
1140 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;value. If succeed returns number and true as result.<br >
1141 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;If not, returns whatever and false as result.<br >
1142 <br >
1143 dadd            ( addr length &#x2013; )<br >
1144 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Add to dictionary data located at "addr", with specified<br >
1145 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;length.<br >
1146 <br >
1147 lit             ( n &#x2013; )<br >
1148 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Act with number depending on "mode". When interpreting,<br >
1149 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;leaves it in stack.<br >
1150 <br >
1151 <br >
1152 incmod          ( addr &#x2013; )<br >
1153 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Add to dictionary data located at "addr"+1 , length is taken<br >
1154 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;from "addr".<br >
1155 <br >
1156 here            ( &#x2013; n )<br >
1157 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;return "h" contents.<br >
1158 <br >
1159 mode    var     8 bit<br >
1160 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Holds input stream parser operation mode.<br >
1161 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;0 = interpreting<br >
1162 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;1 = compiling<br >
1163 <br >
1164 pad     var     128 bytes<br >
1165 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Holds temprorary strings.<br >
1166 <br >
1167 h       var     32 bit<br >
1168 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Pointer to free byte in memory, always at the end of the<br >
1169 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;dictionary. Each time when something is stored<br >
1170 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;by "c," command, pointer is incareased.<br >
1171 <br >
1172 lp      var     32 bit<br >
1173 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Pointer to last dictionary word. Each time when new word is<br >
1174 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;compiled or erased by "forget", this pointer is updated.<br >
1175 <br >
1176 modulechk       ( Dstr&lt;filename&gt; &#x2013; ) check if module is loaded, if not<br >
1177 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;immideately load it.<br >
1178 <br >
1179 ne              ( entrydata entrytype &#x2013; ) Compile new dictionary entry.<br >
1180 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;It's name must be in "pad".<br >
1181 </p>
1182 </div>
1183 </div>
1184 <div id="outline-container-sec-12-2" class="outline-3">
1185 <h3 id="sec-12-2"><span class="section-number-3">12.2</span> Conditionals &amp; control flow</h3>
1186 <div class="outline-text-3" id="text-12-2">
1187 <p class="verse">
1188 if              ( flag &#x2013; )   (immideate)<br >
1189 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"if 1.. else 2.. then" or<br >
1190 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"if 1.. then" construction. Conditional execution.<br >
1191 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Performs "1.." if "flag" was true,<br >
1192 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;elseway performs "2.." if exist. Execution continues after<br >
1193 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;word "then".<br >
1194 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 1 if ." nonzero" else ." zero" then<br >
1195 <br >
1196 &gt;=              ( n1 n2 &#x2013; result ) true if (n1 = n2) or (n1 &gt; n2)<br >
1197 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 5 3 &gt;= if ." first number is greater or equal" then<br >
1198 <br >
1199 &lt;=              ( n1 n2 &#x2013; result ) true if (n1 = n2) or (n1 &lt; n2)<br >
1200 =               ( n1 n2 &#x2013; result ) true if n1 = n2<br >
1201 <br >
1202 do              ( count &#x2013; )  (immideate)<br >
1203 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"do .. loop" construction. Performs ".." "count" times.<br >
1204 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;In every step "count" is decareased until it is 0.<br >
1205 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: : test 5 do i .d loop ;<br >
1206 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;result: 4 3 2 1 0<br >
1207 <br >
1208 doexit         ( &#x2013; ) exit from "do .. loop"<br >
1209 <br >
1210 for             ( count top &#x2013; )   (immideate)<br >
1211 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"for .. loop" construction. Performs ".." (top - count)  times.<br >
1212 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;In every step "count" is incareased until it reaches "top" .<br >
1213 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: : test 4 10 for i .d loop ;<br >
1214 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;result: 4 5 6 7 8 9<br >
1215 <br >
1216 forexit         ( &#x2013; ) exit from "for .. loop"<br >
1217 <br >
1218 until           ( &#x2013; )  (immideate)<br >
1219 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"until .. loop" construction. Performs ".." until flag become<br >
1220 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;true. False by default. Top of return stack holds flag.<br >
1221 <br >
1222 done            ( &#x2013; ) exit from "until .. loop"<br >
1223 <br >
1224 </p>
1225 </div>
1226 </div>
1227 <div id="outline-container-sec-12-3" class="outline-3">
1228 <h3 id="sec-12-3"><span class="section-number-3">12.3</span> Disk &amp; file access</h3>
1229 <div class="outline-text-3" id="text-12-3">
1230 <p class="verse">
1231 diskload ( FromDisk ToMem amount &#x2013; )<br >
1232 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Load specified abount of bytes from disk into memory.<br >
1233 <br >
1234 disksave ( FromMem ToDisk amount &#x2013; )<br >
1235 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;save specified abount of bytes from memory into disk.<br >
1236 <br >
1237 format ( &#x2013; )   Erase all files.<br >
1238 <br >
1239 fsDfilesize@ ( handle &#x2013; size )<br >
1240 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Return size of opened file.<br >
1241 <br >
1242 fsDcurloc@ ( handle &#x2013; location )<br >
1243 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Return current location in file.<br >
1244 <br >
1245 fsDupdated@ ( handle &#x2013; updated? )<br >
1246 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Return true if file was updated,<br >
1247 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ie. write operations occured.<br >
1248 <br >
1249 fssave ( FromMem DestFileHandle amount &#x2013; )<br >
1250 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Save data to file.<br >
1251 <br >
1252 fsload ( SrcFileHandle ToMem amount &#x2013; )<br >
1253 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Load data from file.<br >
1254 <br >
1255 fseof ( handle &#x2013; bytesLeft )<br >
1256 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Return amount of bytes left till end of file.<br >
1257 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Useful before read operation.<br >
1258 <br >
1259 fsls ( &#x2013; )     List all files and lists (directories,folders)<br >
1260 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;in current path.<br >
1261 <br >
1262 fslsr ( &#x2013; )    Same as "fsls" but recursively scans also sub lists.<br >
1263 <br >
1264 fscl ( DynStrHand &#x2013; )<br >
1265 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Change list (path)<br >
1266 <br >
1267 fscreate ( DynStrHand &#x2013; DescPnt )<br >
1268 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Create new file or list. Can create multiple lists at once.<br >
1269 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: when creating:<br >
1270 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"<br >
1271 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;and only "\listGAMES\" already exist, then<br >
1272 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"listSTRATEGY" and "listSIMWORLD" lists will be created,<br >
1273 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;and empty file "5th-runme" placed in there.<br >
1274 <br >
1275 fsDsave ( DynHand&lt;data&gt; DynStrHand&lt;filename&gt; &#x2013; )<br >
1276 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Create new file and save all data from dynamic memory<br >
1277 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;block to it.<br >
1278 <br >
1279 fsDload ( DynStr&lt;SrcFileName&gt; DynHand&lt;DataDest&gt; &#x2013; )<br >
1280 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Load whole file into dynamic memory block.<br >
1281 <br >
1282 fsDloadnew ( DynStr&lt;SrcFileName&gt; &#x2013; DynHand&lt;DataDest&gt; )<br >
1283 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Load whole file into new dynamic memory block.<br >
1284 </p>
1285 </div>
1286 </div>
1287 <div id="outline-container-sec-12-4" class="outline-3">
1288 <h3 id="sec-12-4"><span class="section-number-3">12.4</span> Dynamic memory</h3>
1289 <div class="outline-text-3" id="text-12-4">
1290 <p class="verse">
1291 dynal ( size &#x2013; handle )<br >
1292 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Allocate dynamic memory block and return it's handle.<br >
1293 <br >
1294 dynde ( handle &#x2013; )<br >
1295 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Deallocate dynamic memory block.<br >
1296 <br >
1297 dynp ( handle &#x2013; addr )<br >
1298 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Returns pointer to memory where dynamic block<br >
1299 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;data begins.<br >
1300 <br >
1301 dyns ( handle &#x2013; size )<br >
1302 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Returns size of dynamic block.<br >
1303 <br >
1304 dynresize ( NewSize handle &#x2013; )<br >
1305 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Nondestructively resize dynamic block.<br >
1306 <br >
1307 dync@ ( addr handle )<br >
1308 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Read one byte from dynamic block.<br >
1309 <br >
1310 dync! ( byte addr dynhandle )<br >
1311 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Write one byte to dynamic block.<br >
1312 <br >
1313 dyn@ ( addr handle )<br >
1314 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Read 32 bit number from dynamic block.<br >
1315 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Address will spacify, whitch number, not byte.<br >
1316 <br >
1317 dyn! ( 32BitNum addr dynhandle )<br >
1318 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Write 32 bit number to dynamic block.<br >
1319 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Address will spacify, whitch number, not byte.<br >
1320 <br >
1321 dyncon ( size "name" &#x2013; )<br >
1322 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Allocate dynamic block with specified size, and<br >
1323 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;create constant honding its handle.<br >
1324 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 100 dyncon MyNewBlock<br >
1325 <br >
1326 dyn. ( handle &#x2013; )<br >
1327 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Write contenc of dynamic memory block to screen.<br >
1328 </p>
1329 </div>
1330 </div>
1331 <div id="outline-container-sec-12-5" class="outline-3">
1332 <h3 id="sec-12-5"><span class="section-number-3">12.5</span> Graphics and text</h3>
1333 <div class="outline-text-3" id="text-12-5">
1334 <p class="verse">
1335 .               ( n &#x2013; ) print number on screen<br >
1336 <br >
1337 d.              ( n &#x2013; ) print number on screen in decimal<br >
1338 <br >
1339 ?               ( addr &#x2013; ) print 32 bit value located at addr.<br >
1340 <br >
1341 ." &lt;string&gt;"    ( &#x2013; ) print string into screen. Immideately<br >
1342 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;compiles.<br >
1343 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: : greeting ." Hello, World" ;<br >
1344 <br >
1345 tab.            ( &#x2013; ) print tabulator<br >
1346 <br >
1347 calccol         ( b g r &#x2013; c ) calculate color what best matches given<br >
1348 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Blue Green &amp; Red values. Values must be in range 0 - 255.<br >
1349 <br >
1350 imgalloc        ( xsize ysize &#x2013; imgbuf ) allocate image buffer for<br >
1351 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;specified size.<br >
1352 <br >
1353 imgsize         ( imgbuf &#x2013; ) print on the screen X &amp; Y size of image<br >
1354 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;buffer.<br >
1355 <br >
1356 point           ( x y imgbuf &#x2013; addr ) returns memory address for specified<br >
1357 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;pixel.<br >
1358 <br >
1359 pset            ( color x y imgbuf &#x2013; ) set graphic point<br >
1360 <br >
1361 boxf            ( x1 x2 y1 y2 imgbuf color &#x2013; ) draw filled box<br >
1362 <br >
1363 cls             ( imgbuf &#x2013; ) clear image buffer<br >
1364 <br >
1365 setpal          ( b g r color &#x2013; ) set palette value for specified color.<br >
1366 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;values bust be in size 0 - 63.<br >
1367 <br >
1368 putchar         ( char color x y imgbuf &#x2013; ) put graphic character in<br >
1369 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;imagebuffer to specified (x &amp; y) location.<br >
1370 <br >
1371 scroll          ( x y imgbuf &#x2013; ) scroll in imgbuf.<br >
1372 <br >
1373 scrollf         ( color x y screen &#x2013; )  scroll and fill empty space with<br >
1374 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;given color.<br >
1375 <br >
1376 at!             ( x y &#x2013; ) set cursor location<br >
1377 curc!           ( color &#x2013; ) set text color<br >
1378 curb!           ( solor &#x2013; ) set backround color<br >
1379 <br >
1380 colnorm         ( &#x2013; ) set text color to normal<br >
1381 colneg          ( &#x2013; ) set text color to negative (selected)<br >
1382 <br >
1383 dyntype         ( dynhandle &#x2013; ) display contenc of dynamic memory on screen<br >
1384 fsdisp          ( file &#x2013; ) clear screen, display file, and wait for key<br >
1385 <br >
1386 type            ( addr length &#x2013; )<br >
1387 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Types on the screen string, from memory at  addr  and<br >
1388 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;specified length.<br >
1389 <br >
1390 write           ( addr &#x2013; )<br >
1391 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Types on the screen string, from memory at "addr"+1<br >
1392 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;length is taken from "addr" .<br >
1393 <br >
1394 screen  const   32 bit<br >
1395 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Holds handle of screen buffer.<br >
1396 <br >
1397 copyscreen      ( SrcImgHandle DestImgHandle &#x2013; ) copy contenc of source<br >
1398 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;image to destination image. Source and destination images<br >
1399 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;must have same size.<br >
1400 </p>
1401 </div>
1402 </div>
1403 <div id="outline-container-sec-12-6" class="outline-3">
1404 <h3 id="sec-12-6"><span class="section-number-3">12.6</span> Math, memory &amp; stack manipulation</h3>
1405 <div class="outline-text-3" id="text-12-6">
1406 <p class="verse">
1407 off             ( n &#x2013; ) writes 0 to given address, good for zeroing variable.<br >
1408 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: MyVariable off<br >
1409 on              ( n &#x2013; ) writes -1 (true flag) to given address.<br >
1410 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: MyVariable on<br >
1411 <br >
1412 2dup            ( n1 n2 &#x2013; n1 n2 n1 n2 )<br >
1413 2drop           ( n1 n2 &#x2013; )<br >
1414 nip             ( n1 n2 &#x2013; n2 )<br >
1415 neg             ( n1 &#x2013; -n1 ) negotiate<br >
1416 bit@            ( n bit &#x2013; result ) return specified bit from n.<br >
1417 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 38 2 bit@   (result will be 1)<br >
1418 to32bit         ( n1 n2 n3 n4 &#x2013; n32 ) treat 4 last stack elements as bytes<br >
1419 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;and unite them into 32 bit dword. Most significant byte<br >
1420 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;on top.<br >
1421 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 12 76 23 11 to32bit   result: 186076172<br >
1422 <br >
1423 to8bit          ( n32 &#x2013; n1 n2 n3 n4 ) break 32 bit number into 4 bytes.<br >
1424 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Useful if you need to send 32 bit numbers thru 8 bit COM<br >
1425 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;port.<br >
1426 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 186076172 to8bit   result: 12 76 23 11<br >
1427 <br >
1428 mod             ( n1 n2 &#x2013; reminder ) divide n1 by n2 and returns reminder.<br >
1429 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 12 5 mod   result: 2<br >
1430 <br >
1431 bound           ( low n high &#x2013; n ) check if n is in given bounds,<br >
1432 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if not then incarease/decarease it to match bounds.<br >
1433 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: 5 80 15 bound    result: 15<br >
1434 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;5 10 15 bound    result: 10<br >
1435 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;5 -10 15 bound   result: 5<br >
1436 <br >
1437 bound?          ( low n high &#x2013; result ) returns true if n is in the<br >
1438 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;given bounds.<br >
1439 <br >
1440 tab             ( col &#x2013; spaces) calculate amount of spaces to add<br >
1441 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ta reach next tabulation from given column.<br >
1442 <br >
1443 count           ( addr &#x2013; addr+1 n )<br >
1444 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Useful for returning bytes from constantly incareasing<br >
1445 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;address. Module "type" is nice example.<br >
1446 <br >
1447 c,              ( n &#x2013; )<br >
1448 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;store one byte at memory specified by "h". And incarease<br >
1449 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"h" by 1.<br >
1450 <br >
1451 ,               ( n &#x2013; )<br >
1452 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;store 32 bit number at memory specified by "h". And<br >
1453 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;incarease "h" by 4.<br >
1454 <br >
1455 cmove           ( addr1 addr2 n &#x2013; )<br >
1456 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;copy "n" amount of bytes from memory at "addr1" to memory<br >
1457 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;at "addr2".<br >
1458 <br >
1459 rnd             ( limit &#x2013; result )<br >
1460 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;generates random number in range 0 to "limit"-1.<br >
1461 <br >
1462 abs             ( n &#x2013; |n| )<br >
1463 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;returns absolute value of "n"<br >
1464 </p>
1465 </div>
1466 </div>
1467 <div id="outline-container-sec-12-7" class="outline-3">
1468 <h3 id="sec-12-7"><span class="section-number-3">12.7</span> Dynamic &amp; static strings</h3>
1469 <div class="outline-text-3" id="text-12-7">
1470 <p>
1471 Fifth supports both static and dynamic strings. Static strings must
1472 have predefined space reserved, and string mustn't exceed this
1473 length. They manipulation is faster. But they use more memory. Static
1474 string memory address is used to refer to the string.
1475 </p>
1476
1477 <p>
1478 Dynamic strings can have at any time length form 0 to 0FFh, They take
1479 up only memory they currently need. They are held in dynamic memory
1480 blocks, so dynamic block handle is used to refer to this string.
1481 </p>
1482
1483 <p>
1484 Both types of strings are stored in the way, where first (0th) byte
1485 holds current string length, following bytes are string itself.
1486 </p>
1487
1488
1489 <p class="verse">
1490 Dynamic:<br >
1491 <br >
1492 Dstral ( &#x2013; handle )<br >
1493 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Allocate new string.<br >
1494 <br >
1495 Dstrlen ( handle &#x2013; length )<br >
1496 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Return string length.<br >
1497 <br >
1498 c+Dstr ( chr handle &#x2013; )<br >
1499 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Add one byte to end of the string.<br >
1500 <br >
1501 c+lDstr ( chr handle &#x2013; )<br >
1502 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Add one byte to left side (beginning) of the string.<br >
1503 <br >
1504 Dstr. ( handle &#x2013; )<br >
1505 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Write contec of string into screen.<br >
1506 <br >
1507 Dstrsure ( size Dstr &#x2013; )<br >
1508 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Makes sure that at least rquested<br >
1509 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"size" (amount of characters) is allocated for given<br >
1510 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;dynamic string.<br >
1511 <br >
1512 Dstr2str ( handle address &#x2013; )<br >
1513 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Copy dyamic string into static memory space.<br >
1514 <br >
1515 str2Dstr ( address handle &#x2013; )<br >
1516 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Copy static string into dyamic string.<br >
1517 <br >
1518 Dstr+str ( Dstr addr &#x2013; )<br >
1519 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Add contenc of dynamic string to static string.<br >
1520 <br >
1521 D" any string" ( &#x2013; Dstr )<br >
1522 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Moves specified string into dynamic string called "defDstr".<br >
1523 <br >
1524 D&gt; any_string ( &#x2013; Dstr )<br >
1525 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Moves specified string into dynamic string called "defDstr".<br >
1526 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Space marks end of string!<br >
1527 <br >
1528 D&gt;2 any_string ( &#x2013; Dstr )<br >
1529 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Moves specified string into dynamic string called "defDstr2".<br >
1530 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Space marks end of string!<br >
1531 <br >
1532 Dstr+Dstr ( Dstr1 Dstr2 &#x2013; )<br >
1533 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Adds "Dstr1" to "Dstr2" and places result into "Dstr2".<br >
1534 <br >
1535 Dstrclear ( Dstr &#x2013; )<br >
1536 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Clears contenc of dynamic string.<br >
1537 <br >
1538 Dstr2Dstr ( Dstr1 Dstr2 &#x2013; )<br >
1539 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Moves "Dstr1" to "Dstr2".<br >
1540 Dstr ( data" name &#x2013; )<br >
1541 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Creates new dynamic string and moves specified data into it.<br >
1542 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Then creates new constant with given "name" holding created<br >
1543 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;dynamic string handle.<br >
1544 <br >
1545 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: Dstr Hello, my name is Sven!" message      \ creates it<br >
1546 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;message Dstr.                              \ tests it<br >
1547 <br >
1548 Dstrlscan ( char Dstr &#x2013; loc )<br >
1549 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Searches dynamic string for "char", from left to right,<br >
1550 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;returns first found "char" location in string, or 0,<br >
1551 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if not found.<br >
1552 <br >
1553 Dstrrscan ( char Dstr &#x2013; loc )<br >
1554 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Searches dynamic string for "char", from right to left,<br >
1555 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;returns first found "char" location in string, or 0,<br >
1556 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if not found.<br >
1557 <br >
1558 Dstrlscane ( char Dstr &#x2013; loc )<br >
1559 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Same as "Dstrlscan" buf returns string length+1 as location.<br >
1560 ÿ<br >
1561 Dstrleft ( amo Dstr &#x2013; )<br >
1562 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Only specified amount of characters from left remains<br >
1563 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;in dynamic string. ie. cut right part out.<br >
1564 <br >
1565 Dstrright ( amo Dstr &#x2013; )<br >
1566 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Only specified amount of characters from right remains<br >
1567 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;in dynamic string. ie. cut left part out.<br >
1568 <br >
1569 Dstrcutl ( amo Dstr &#x2013; )<br >
1570 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Cut specified amount of characters from left of dynamic<br >
1571 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;string out.<br >
1572 <br >
1573 Dstrsp ( char Dstr1 Dstr2 &#x2013; )<br >
1574 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Separate dynamic string in Dstr1 into two parts,<br >
1575 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;using "char" as separator. First part will be stored in<br >
1576 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;"Dstr2", second part in "Dstr1".<br >
1577 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;ex: asc \                               \ ..separator<br >
1578 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;D&gt; listF\listLIB\5TH_DRVMOUSE       \ ..separate from<br >
1579 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;defDstr2                            \ ..place result in<br >
1580 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Dstrsp              \ separation command<br >
1581 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;defDstr Dstr.       \ will be: listLIB\5TH_DRVMOUSE<br >
1582 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;defDstr2 Dstr.      \ will be: listF<br >
1583 <br >
1584 Dv ( addr &#x2013; )<br >
1585 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Allocates empty dynamic string, and places it's handle<br >
1586 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;into given address.<br >
1587 <br >
1588 Df ( addr &#x2013; )<br >
1589 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Reads dynamic string handle from given address and<br >
1590 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;deallocates (frees) it.<br >
1591 <br >
1592 ex:     var mystring1<br >
1593 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;: testmodule<br >
1594 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;mystring1 Dv            \ allocates string<br >
1595 <br >
1596 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&lt;whatever&gt;<br >
1597 <br >
1598 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;mystring1 Df ;          \ deallocates it again when no longer needed.<br >
1599 </p>
1600 </div>
1601 </div>
1602 </div>
1603 <div id="outline-container-sec-13" class="outline-2">
1604 <h2 id="sec-13"><span class="section-number-2">13</span> Dynamically loadable modules</h2>
1605 <div class="outline-text-2" id="text-13">
1606 </div><div id="outline-container-sec-13-1" class="outline-3">
1607 <h3 id="sec-13-1"><span class="section-number-3">13.1</span> Keyboard driver</h3>
1608 <div class="outline-text-3" id="text-13-1">
1609 <p class="verse">
1610 <br >
1611 KBD_@           ( &#x2013; code ) get scancodes for pressed keys from keyboard.<br >
1612 KBD_down?       ( key &#x2013; result ) check is key with specified scancode<br >
1613 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;currently pressed down.<br >
1614 KBD_SC2FSCII    ( code &#x2013; FSCII ) convert key scancode into FSCII code,<br >
1615 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;or in FSK (Fifth standard keycode).<br >
1616 KBD_F@          ( &#x2013; FSCII ) read pressed key FSCII or FSK, returns -1 if no<br >
1617 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;keys are pressed.<br >
1618 KBD_FW@         ( &#x2013; FSCII ) read pressed key FSCII or FSK, if no keys is<br >
1619 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;are pressed then waits until there is.<br >
1620 <br >
1621 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;FSK<br >
1622 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#x2014;<br >
1623 In HEX.<br >
1624 <br >
1625 FC      backspace<br >
1626 FD      TAB<br >
1627 FE      enter<br >
1628 FF      space<br >
1629 <br >
1630 400     ESC<br >
1631 401 &#x2026; F1 &#x2026;<br >
1632 410     up<br >
1633 411     right<br >
1634 412     down<br >
1635 413     left<br >
1636 414     INS<br >
1637 415     DEL<br >
1638 416     home<br >
1639 417     end<br >
1640 418     PG/UP<br >
1641 419     PG/DN<br >
1642 </p>
1643 </div>
1644 </div>
1645 <div id="outline-container-sec-13-2" class="outline-3">
1646 <h3 id="sec-13-2"><span class="section-number-3">13.2</span> Mouse driver</h3>
1647 <div class="outline-text-3" id="text-13-2">
1648 <p class="verse">
1649 mousex  var     Mouse x coordinate.<br >
1650 mousey  var     Mouse y coordinate.<br >
1651 mousekeyl var   Mouse left key.<br >
1652 mousekeym var   Mouse middle key.<br >
1653 mousekeyr var   Mouse right key.<br >
1654 mousec  var     Display current mouse coordinates in top left part of screen,<br >
1655 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if true. (good for debugging)<br >
1656 mousepointer var  Image buffer, holding current mouse pointer.<br >
1657 mouseadd        ( ModuleAddr x1 x2 y1 y2 &#x2013; ) Add specified area on screen,<br >
1658 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;into mause click buffer. If any mouse button is clicked on<br >
1659 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;that area, module at "ModuleAddr" will be executed.<br >
1660 mousebe var     Amount of buffer elements.<br >
1661 mousedo         ( &#x2013; ) Updates mouse coordinates and keys. Parse mouse<br >
1662 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;click buffer, and draw mouse cursor to "screen".<br >
1663 </p>
1664 </div>
1665 </div>
1666 <div id="outline-container-sec-13-3" class="outline-3">
1667 <h3 id="sec-13-3"><span class="section-number-3">13.3</span> 2D graphic library</h3>
1668 <div class="outline-text-3" id="text-13-3">
1669 <p class="verse">
1670 lineh           ( color len x y imgbuf &#x2013; ) draws horisontal line<br >
1671 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;from X,Y coordinates to right, with specified length.<br >
1672 linev           ( color len x y imgbuf &#x2013; ) draws vertical line<br >
1673 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;down, from coordinates X,Y, with specified length.<br >
1674 box             ( color x2 x1 y2 y1 imgbuf &#x2013; ) draws rectangular<br >
1675 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;box. x2 bust be &gt;= x1, y2 must be &gt;= y1.<br >
1676 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;x1,y1&#x2013;&#x2014;&#x2014;&#x2014;+<br >
1677 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;|             |<br >
1678 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;|             |<br >
1679 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;+&#x2013;&#x2014;&#x2014;&#x2014;x2,y2<br >
1680 <br >
1681 flipv           ( imgbuf &#x2013; ) flip image vertically.<br >
1682 imgcoltrans     ( ImgBuf Color ToColor &#x2013; ) Translate all pixels in<br >
1683 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;specified image with "Color" into "ToColor".<br >
1684 imgfill         ( color x y imgbuf &#x2013; ) Fill image region starting at location<br >
1685 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;X &amp; Y with specified color.<br >
1686 </p>
1687 </div>
1688 </div>
1689 <div id="outline-container-sec-13-4" class="outline-3">
1690 <h3 id="sec-13-4"><span class="section-number-3">13.4</span> Trigonometry functions</h3>
1691 <div class="outline-text-3" id="text-13-4">
1692 <p class="verse">
1693 sin             ( a &#x2013; result ) return sinus from given angle "a",<br >
1694 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;360ø is 2000. So 1000 represents 180ø angle.<br >
1695 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Result will be in range -10'000 to 10'000, instead of ñ1.<br >
1696 <br >
1697 cos             ( a &#x2013; result ) return cosinus from given angle.<br >
1698 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;Parameters are like in "sin" function.<br >
1699 </p>
1700 </div>
1701 </div>
1702 </div>
1703 </div><div class="col-md-3"><nav id="table-of-contents">
1704 <div id="text-table-of-contents" class="bs-docs-sidebar">
1705 <ul class="nav">
1706 <li><a href="#sec-1">1. General</a>
1707 <ul class="nav">
1708 <li><a href="#sec-1-1">1.1. Source code</a></li>
1709 </ul>
1710 </li>
1711 <li><a href="#sec-2">2. !Project deprecated!</a></li>
1712 <li><a href="#sec-3">3. Introduction</a>
1713 <ul class="nav">
1714 <li><a href="#sec-3-1">3.1. screenshots</a></li>
1715 </ul>
1716 </li>
1717 <li><a href="#sec-4">4. Installation</a></li>
1718 <li><a href="#sec-5">5. Fifth distribution directory tree description</a></li>
1719 <li><a href="#sec-6">6. Software/Hardware/Human requirements</a>
1720 <ul class="nav">
1721 <li><a href="#sec-6-1">6.1. Software</a></li>
1722 <li><a href="#sec-6-2">6.2. Hardware</a></li>
1723 <li><a href="#sec-6-3">6.3. Human</a></li>
1724 </ul>
1725 </li>
1726 <li><a href="#sec-7">7. Numbers representation within Fifth</a></li>
1727 <li><a href="#sec-8">8. Disk file map, and it's data structures</a>
1728 <ul class="nav">
1729 <li><a href="#sec-8-1">8.1. disk allocation</a></li>
1730 <li><a href="#sec-8-2">8.2. FAT entry format:</a></li>
1731 <li><a href="#sec-8-3">8.3. file entry format</a></li>
1732 </ul>
1733 </li>
1734 <li><a href="#sec-9">9. Core architecture</a>
1735 <ul class="nav">
1736 <li><a href="#sec-9-1">9.1. Dictionary entry format</a></li>
1737 <li><a href="#sec-9-2">9.2. Possible module types</a></li>
1738 <li><a href="#sec-9-3">9.3. Memory map (average)</a></li>
1739 </ul>
1740 </li>
1741 <li><a href="#sec-10">10. Virtual machine</a></li>
1742 <li><a href="#sec-11">11. Fifth source format</a>
1743 <ul class="nav">
1744 <li><a href="#sec-11-1">11.1. FSCII</a></li>
1745 </ul>
1746 </li>
1747 <li><a href="#sec-12">12. Fifth commands</a>
1748 <ul class="nav">
1749 <li><a href="#sec-12-1">12.1. Compilation &amp; miscellaneous</a></li>
1750 <li><a href="#sec-12-2">12.2. Conditionals &amp; control flow</a></li>
1751 <li><a href="#sec-12-3">12.3. Disk &amp; file access</a></li>
1752 <li><a href="#sec-12-4">12.4. Dynamic memory</a></li>
1753 <li><a href="#sec-12-5">12.5. Graphics and text</a></li>
1754 <li><a href="#sec-12-6">12.6. Math, memory &amp; stack manipulation</a></li>
1755 <li><a href="#sec-12-7">12.7. Dynamic &amp; static strings</a></li>
1756 </ul>
1757 </li>
1758 <li><a href="#sec-13">13. Dynamically loadable modules</a>
1759 <ul class="nav">
1760 <li><a href="#sec-13-1">13.1. Keyboard driver</a></li>
1761 <li><a href="#sec-13-2">13.2. Mouse driver</a></li>
1762 <li><a href="#sec-13-3">13.3. 2D graphic library</a></li>
1763 <li><a href="#sec-13-4">13.4. Trigonometry functions</a></li>
1764 </ul>
1765 </li>
1766 </ul>
1767 </div>
1768 </nav>
1769 </div></div></div>
1770 <footer id="postamble" class="">
1771 <div><p class="author">Author: Svjatoslav Agejenko</p>
1772 <p class="date">Created: 2020-05-02 Sat 00:04</p>
1773 <p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 26.1 (<a href="http://orgmode.org">Org-mode</a> 9.1.9)</p>
1774 </div>
1775 </footer>
1776 </body>
1777 </html>