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