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