4 <title>Fifth - virtual machine, operating system, programming language</title>
5 <!-- 2018-01-01 Mon 23:29 -->
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;}
17 <style type="text/css">
18 /* org mode styles on top of twbs */
35 background-color: #f5f5f5;
62 display: inline-block;
74 .bs-docs-sidebar.affix {
77 @media (min-width: 768px) {
83 /* All levels of nav */
84 .bs-docs-sidebar .nav > li > a {
91 .bs-docs-sidebar .nav > li > a:hover,
92 .bs-docs-sidebar .nav > li > a:focus {
95 text-decoration: none;
96 background-color: transparent;
97 border-left: 1px solid #A1283B;
99 .bs-docs-sidebar .nav > .active > a,
100 .bs-docs-sidebar .nav > .active:hover > a,
101 .bs-docs-sidebar .nav > .active:focus > a {
105 background-color: transparent;
106 border-left: 2px solid #A1283B;
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;
114 .bs-docs-sidebar .nav .nav > li > a {
121 .bs-docs-sidebar .nav .nav > li > a:hover,
122 .bs-docs-sidebar .nav .nav > li > a:focus {
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 {
132 /* Nav: third level (shown on .active) */
133 .bs-docs-sidebar .nav .nav .nav {
134 padding-bottom: 10px;
136 .bs-docs-sidebar .nav .nav .nav > li > a {
143 .bs-docs-sidebar .nav .nav .nav > li > a:hover,
144 .bs-docs-sidebar .nav .nav .nav > li > a:focus {
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 {
154 /* Show and affix the side nav when space allows it */
155 @media (min-width: 992px) {
156 .bs-docs-sidebar .nav > .active > ul {
159 /* Widen the fixed sidebar */
160 .bs-docs-sidebar.affix,
161 .bs-docs-sidebar.affix-bottom {
164 .bs-docs-sidebar.affix {
165 position: fixed; /* Undo the static from mobile first approach */
168 .bs-docs-sidebar.affix-bottom {
169 position: absolute; /* Undo the static from mobile first approach */
171 .bs-docs-sidebar.affix .bs-docs-sidenav,.bs-docs-sidebar.affix-bottom .bs-docs-sidenav {
176 @media (min-width: 1200px) {
177 /* Widen the fixed sidebar again */
178 .bs-docs-sidebar.affix-bottom,
179 .bs-docs-sidebar.affix {
184 <script type="text/javascript">
188 $('.bs-docs-sidebar li').first().addClass('active');
190 $(document.body).scrollspy({target: '.bs-docs-sidebar'});
192 $('.bs-docs-sidebar').affix();
196 <script type="text/x-mathjax-config">
198 displayAlign: "center",
199 displayIndent: "2em",
200 messageStyle: "none",
204 ".MathJax_Display": {
212 ".MathJax_SVG_Display": {
214 "margin-left": "-2.281em"
220 <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_SVG"></script>
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>
227 <li><a href="http://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=snapshot;h=HEAD;sf=tgz">download latest snapshot</a>
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.
237 <li>Svjatoslav Agejenko
239 <li>Homepage: <a href="http://svjatoslav.eu">http://svjatoslav.eu</a>
241 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a>
246 <li><a href="http://www.svjatoslav.eu/programs.jsp">other applications hosted at svjatoslav.eu</a>
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">
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.
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>
265 System is built many years ago when I was still using DOS as a primary
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">
274 Fifth is programming lanquage & 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.
282 <li><a href="5TH_ET.txt">Example Fifth source file - text editor</a>
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">
290 <li><img src="screenshots/start.png" class="img-responsive" alt="start.png">
292 <li>Startup screen diplaying Fifth logo and full file list.
297 <li><img src="screenshots/dictionary.png" class="img-responsive" alt="dictionary.png">
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.
306 <li><img src="screenshots/text editor.png" class="img-responsive" alt="text editor.png">
308 <li>Built in text editor.
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">
321 Just unpack all files, witout altering original directory structure,
322 somewhere in your hard disk. For example: C:\MISC\FIFTH\…. To run
323 fifth you need minimally just 2 files. emulator itself ( EMULATOR.EXE
324 or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
328 Read more about <i>distribution directory layout</i>
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">
336 After downloading and unpacking the ZIP file you shoud get directory
337 tree similar to this:
341 [DOC] - Fifth documentation<br >
342   [commands] - documentation on Fifth built-in commands<br >
343   [modules] - documentation on additional commands, realized as loadable modules<br >
344   [shots] - Fifth screenshots<br >
346 [imageFile] - files contained within 'disk.raw', just an extracted form.<br >
348 [source] - source files<br >
349   [emulator] - emulator source<br >
350   [util] - utilites<br >
352 disk.raw - Virtual disk file, has filesystem inside.<br >
353 emulator.com - main executable.<br >
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">
365 <li>MS-DOS 6.22, with HIMEM.SYS loaded.
367 <li>Mouse driver if you have a mouse.
369 <li>Does work only when CPU is in real mode.
371 <li>To recompile ASM sources I used FASM (Flat Assembler).
373 <li>I ran QBasic utilities on QB 4.5 .
375 <li>VESA support by BIOS, or external driver (UNIVBE).
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">
386 <li>64 KB free RAM below 640KB,
388 <li>2 MB of free XMS.
390 <li>VESA compatible video card.
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">
399 <li>Beginner level Forth knowledge is recommended.
401 <li>Lots of enthusiasm.
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">
412 <p><a href="numbers.png"><img src="numbers.png" class="img-responsive" alt="numbers.png"></a>
417 Because I can define everything, starting from CPU, why not try also
418 alternative and unique number representation ?
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).
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">
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
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">
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>
459 <td class="text-left">0</td>
460 <td class="text-left">~4 Kb</td>
461 <td class="text-left">Fifth core</td>
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>
471 <td class="text-left">37 Kb</td>
472 <td class="text-left">~65Kb</td>
473 <td class="text-left">FAT</td>
477 <td class="text-left">101Kb</td>
478 <td class="text-left">~16MB</td>
479 <td class="text-left">filesystem data area</td>
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">
498 <th scope="col" class="text-right">code</th>
499 <th scope="col" class="text-left">meaning</th>
504 <td class="text-right">-2</td>
505 <td class="text-left">last sector</td>
509 <td class="text-right">-1</td>
510 <td class="text-left">empty sector</td>
514 <td class="text-right">0 --</td>
515 <td class="text-left">.. pointer to next block</td>
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">
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>
543 <td class="text-right">0</td>
544 <td class="text-right">4</td>
545 <td class="text-left">extension</td>
549 <td class="text-right">4</td>
550 <td class="text-right">16</td>
551 <td class="text-left">name</td>
555 <td class="text-right">20</td>
556 <td class="text-right">4</td>
557 <td class="text-left">entry point</td>
561 <td class="text-right">24</td>
562 <td class="text-right">4</td>
563 <td class="text-left">size</td>
567 <td class="text-right">28</td>
568 <td class="text-right">4</td>
569 <td class="text-left">last modification time</td>
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">
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.
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">
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>
612 <td class="text-right">0</td>
613 <td class="text-right">4</td>
614 <td class="text-left">0 &lt; previous entry</td>
618 <td class="text-right"> </td>
619 <td class="text-right"> </td>
620 <td class="text-left">0 = last</td>
624 <td class="text-right"> </td>
625 <td class="text-right"> </td>
626 <td class="text-left">-1 = empty</td>
631 <td class="text-right">4</td>
632 <td class="text-right">15</td>
633 <td class="text-left">module name string</td>
638 <td class="text-right">19</td>
639 <td class="text-right">1</td>
640 <td class="text-left">entry type</td>
645 <td class="text-right">20</td>
646 <td class="text-right">4</td>
647 <td class="text-left">entry data</td>
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.
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">
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>
681 <td class="text-right">0</td>
682 <td class="text-left">data</td>
683 <td class="text-left">compile "num" instruction</td>
687 <td class="text-right"> </td>
688 <td class="text-left"> </td>
689 <td class="text-left">with address to module</td>
694 <td class="text-right">1</td>
695 <td class="text-left">submodule</td>
696 <td class="text-left">compile "call" instruction</td>
700 <td class="text-right"> </td>
701 <td class="text-left"> </td>
702 <td class="text-left">with address to module</td>
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>
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">
730 <th scope="col" class="text-right"><loc></th>
731 <th scope="col" class="text-left"><size></th>
732 <th scope="col" class="text-left"><desc></th>
737 <td class="text-right">0</td>
738 <td class="text-left">~4096</td>
739 <td class="text-left">core</td>
743 <td class="text-right">1500000</td>
744 <td class="text-left">~32000</td>
745 <td class="text-left">highlevel Fifth boot code</td>
749 <td class="text-right">200000h</td>
750 <td class="text-left"> </td>
751 <td class="text-left">core startup messages area</td>
755 <td class="text-right">5200000</td>
756 <td class="text-left"> </td>
757 <td class="text-left">end of dynamic memory space</td>
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">
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 & data storage.
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).
786 Maybe one day similar system will run directly on custom silicon chip :)
791 CPU has following registers:
793 <table class="table table-striped table-bordered table-hover table-condensed">
803 <td class="text-left">IP</td>
804 <td class="text-left">instruction pointer</td>
808 <td class="text-left">DSP</td>
809 <td class="text-left">data stack pointer</td>
813 <td class="text-left">RSP</td>
814 <td class="text-left">return stack pointer</td>
820 Virtual CPU, commands (most of them are avaiable as ordinary commands
821 in programming lanquage):
826 code mnemonic description<br >
828 0 nop does notheing<br >
829 1 halt halt CPU ( return to DOS on emulator )<br >
831 2 kbd@ ( – c ) read scancode of pressed or released key.<br >
832                                 Returns 0, if no data avaiable.<br >
833 3 num <dword> ( – n ) put immidiate number into datastack<br >
835 4 jmp <dword> jump to specified code<br >
836 5 call <dword>jump to specified code, save return address to<br >
837                                 return stack.<br >
839 6 1+ ( n – n+1 )<br >
840 7 1- ( n – n-1 )<br >
842 8 dup ( n – n n ) duplicate top of data stack<br >
843 9 drop ( n – ) drop last element in data stack<br >
845 10 if <dword> ( n – ) jump to addr if top element was 0<br >
846 11 ret jump to code, specified in return stack.<br >
848 12 c@ ( addr – n ) read byte from memory at specified address<br >
849 13 c! ( n addr – ) store byte to specified memory<br >
851 14 push ( DSTK -> RSTK ) move top of datastack to returnstack<br >
852 15 pop ( RSTK -> DSTK ) move top of returnstack to datastack<br >
854 16 <unused><br >
855 17 rot ( n1 n2 n3 – n2 n3 n1) rotate stack elements<br >
857 18 disk@ ( FromDiskSect ToMem – ) read 1KB from disk into RAM<br >
858 19 disk! ( FromMem ToDiskSect – ) write 1KB to disk<br >
860 20 @ ( addr – n ) read 32 bit number from memory<br >
861 21 ! ( n addr – ) store 32 bit number to memory<br >
863 22 over ( n1 n2 – n1 n2 n1 ) self explaining …<br >
864 23 swap ( n1 n2 – n2 n1 ) -,,-<br >
866 24 + ( n1 n2 – n1+n2 ) -,,-<br >
867 25 - ( n1 n2 – n1-n2 ) -,,-<br >
869 26 * ( n1 n2 – n1*n2 ) -,,-<br >
870 27 / ( n1 n2 – n1/n2 ) -,,-<br >
872 28 > ( n1 n2 – result ) is true when n1 > n2<br >
873 29 < ( n1 n2 – result ) is true when n1 < n2<br >
875 30 not ( n1 – not_n1 ) logical not<br >
876 31 i ( – n ) copies top of return stack into datastack<br >
878 32 cprt@ ( addr – n ) read one byte from hardware port<br >
879 33 cprt! ( n addr – ) store one byte to hardware port<br >
881 34 i2 ( – n ) like "i" but takes socond top stack element.<br >
882 35 i3 ( – n ) like "i" but takes third top stack element.<br >
884 36 shl ( n amount – n ) left bit shift<br >
885 37 shr ( n amount – n ) right bit shift<br >
887 38 or ( n1 n2 – n ) logical or<br >
888 39 xor ( n1 n2 – n ) exclusive logical or<br >
890 40 vidmap ( addr – ) copy memory from "addr" to video memory.<br >
892 41 mouse@ ( – x y button ) read mouse coordinates & buttons<br >
894 42 vidput ( addr1 addr2 x y – ) put image1 into image2, at<br >
895                                 location x, y. Does clipping, so part of a big image<br >
896                                 can be mapped into smaller one.<br >
898 43 cmove ( addr1 addr2 amount ) move memory from addr1 to addr2<br >
899                                 if addr1 is greater than addr2 then count address<br >
900                                 foward while moving, elseway starts from end and<br >
901                                 counts backwards, so no data loss will occure on<br >
902                                 overlapping.<br >
904 44 cfill ( c addr amount – ) fill memory starting at "addr"<br >
905                                 with "c" bytes.<br >
907 45 tvidput ( addr1 addr2 x y – ) same as "vidput" but treats<br >
908                                 color 255 in source image as transparent.<br >
910 46 depth ( – depth ) returns current depth of data stack.<br >
912 47 charput ( colorfg colorbg addrsrc addrdest x y )<br >
913                                 draw character to image buffer located at "addrdest"<br >
914                                 to specified x & y location. Decodes 8 bytes from<br >
915                                 source to bits, used to draw character.<br >
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">
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…" is treated
929 like ordinary letters.
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">
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>
954 <td class="text-right">0 - 15</td>
955 <td class="text-left">0 - F</td>
956 <td class="text-left">HEX numbers</td>
960 <td class="text-right">252</td>
961 <td class="text-left">FC</td>
962 <td class="text-left">backspace</td>
966 <td class="text-right">253</td>
967 <td class="text-left">FD</td>
968 <td class="text-left">tabulator (TAB)</td>
972 <td class="text-right">254</td>
973 <td class="text-left">FE</td>
974 <td class="text-left">carriage return (CR)</td>
978 <td class="text-right">255</td>
979 <td class="text-left">FF</td>
980 <td class="text-left">space</td>
984 <td class="text-right">else</td>
985 <td class="text-left"> </td>
986 <td class="text-left">ordinary characters, same as in ASCII.</td>
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 & miscellaneous</h3>
998 <div class="outline-text-3" id="text-11-1">
1000 init module ( – )<br >
1001                 First module, control is passed to on startup. Contains<br >
1002                 initialization routines. Also it is the last core module.<br >
1003                 All new modules on top of it comes as result of executing<br >
1004                 external source files.<br >
1006 head <name> ( – ) compiles new dictionary entry without specifying<br >
1007                 new module type.<br >
1008                 ex: head myentry<br >
1010 : <name> ( – ) creates new code module<br >
1011 ; ( – ) ends module (immideate)<br >
1012                 ex: : hello ." hi there" ;<br >
1014 const <name> ( n – ) defines new constant.<br >
1015                 ex: 2147483647 const max<br >
1017 :i <name> ( – ) same as ":" but this module will be executed<br >
1018                 immideately even in compile mode.<br >
1019                 ex: :i ( 41 scan ;<br >
1021 create <name> ( – ) same as "head" , but specify module type as data.<br >
1022                 ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,<br >
1024 allot ( n – ) allocate n bytes in dictionary.<br >
1025                 ex: create MyArray 100 allot<br >
1027 " <string>" ( – ) compile string and its size into core.<br >
1028                 ex: create Mystring " This is it's contects"<br >
1030 str <name> <string>" ( – ) just shorter way for defining strings.<br >
1031                 ex: str Mystring This is it's contenc"<br >
1033 var <name> ( – ) define new 32 bit variable.<br >
1034                 ex: var result<br >
1036 ' <module> ( – n ) return memory address of given entry.<br >
1037                 ex: ' init<br >
1039 forget <name> ( – ) erases from RAM given entry and all entries what was<br >
1040                 defined after it.<br >
1041                 ex: forget myprog<br >
1043 [ ( – ) set interpret mode (immideate)<br >
1044 ] ( n – ) set compile mode and compile top stack element<br >
1045                 in as literal. Together [ …. ] cobination provides good<br >
1046                 way to compute some values only once, at compile time,<br >
1047                 rather than every time while program is running.<br >
1048                 ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;<br >
1050 defer <name> ( – ) creates new module, with jump instruction.<br >
1051                 Later address where to jump can be modified by "is" command.<br >
1052                 This provides method of foward referencing. So you can use<br >
1053                 modules what not jet exist.<br >
1054 is ( address1 address2 – ) address1 - where to jump, address2 -<br >
1055                 address of module created by defer command.<br >
1056                 ex: defer dispver<br >
1057                         : run dispver ." running …" ;<br >
1058                                … whatever …<br >
1059                         : (dispver ." Version 9.99 " ;<br >
1060                         ' (dispver ' dispver is<br >
1062                 Now if I type "run" on the screen appears:<br >
1063                         Version 9.99 running …<br >
1065 asc <char> ( – ) reads char ascii code and treats it as literal.<br >
1066                 (immideate)<br >
1067                 ex: : BreakLine 30 do asc - emit loop ;<br >
1068                                  same as:<br >
1069                     : BreakLine 30 do 45 emit loop ;<br >
1071 dyninc ( handle – ) execute code in dynamic memory handle.<br >
1072                 automatically deallocates it when done.<br >
1074 include ( filenumber – ) execute code in specified file.<br >
1076 words ( – ) display existing blocks in core.<br >
1078 bye ( – ) exit from Fifth<br >
1080 fkey ( – c )<br >
1081                 Read one byte from input stream.<br >
1083 sadd ( c addr – )<br >
1084                 Add one byte "c" to string located at "addr" and updates<br >
1085                 string length.<br >
1087 scan ( c – )<br >
1088                 Read input stream and store it to pad until it finds c .<br >
1089                 It ignores all "c" bytes until it finds any non "c" byte.<br >
1090                 in other words:<br >
1091                                 c is: "<br >
1092                          input stream: """"This is test !"aoeu idh<br >
1093                                result: This is test !<br >
1095                 Is useful for breaking text lines into words.<br >
1097 skey ( – c )<br >
1098                 So called safe "fkey". Reads data from input stream<br >
1099                 but converts characters with ASCII codes: 9 13 10<br >
1100                 to spaces.<br >
1102 str=str? ( adr1 adr2 – result )<br >
1103                 Compares string at "adr1" with string at "adr2", returns<br >
1104                 true flag if they are equal or false if they are not.<br >
1105                 true = -1<br >
1106                 false = 0<br >
1108 find ( – addr )<br >
1109                 Searches whole dictionary for word in "pad". If found,<br >
1110                 returns it address, if not, returns 0.<br >
1112 execute ( – )<br >
1113                 Execute word located in "pad". Depending on "mode".<br >
1115 dta ( addr – DataAddr )<br >
1116                 Calculates address of dictionary entry data area, from<br >
1117                 entry point.<br >
1119 2num ( – num result )<br >
1120                 Attempt to convert string located in "pad" into numeric<br >
1121                 value. If succeed returns number and true as result.<br >
1122                 If not, returns whatever and false as result.<br >
1124 dadd ( addr length – )<br >
1125                 Add to dictionary data located at "addr", with specified<br >
1126                 length.<br >
1128 lit ( n – )<br >
1129                 Act with number depending on "mode". When interpreting,<br >
1130                 leaves it in stack.<br >
1133 incmod ( addr – )<br >
1134                 Add to dictionary data located at "addr"+1 , length is taken<br >
1135                 from "addr".<br >
1137 here ( – n )<br >
1138                 return "h" contents.<br >
1141                 Holds input stream parser operation mode.<br >
1142                 0 = interpreting<br >
1143                 1 = compiling<br >
1145 pad var 128 bytes<br >
1146                 Holds temprorary strings.<br >
1149                 Pointer to free byte in memory, always at the end of the<br >
1150                 dictionary. Each time when something is stored<br >
1151                 by "c," command, pointer is incareased.<br >
1154                 Pointer to last dictionary word. Each time when new word is<br >
1155                 compiled or erased by "forget", this pointer is updated.<br >
1157 modulechk ( Dstr<filename> – ) check if module is loaded, if not<br >
1158                 immideately load it.<br >
1160 ne ( entrydata entrytype – ) Compile new dictionary entry.<br >
1161                 It's name must be in "pad".<br >
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 & control flow</h3>
1167 <div class="outline-text-3" id="text-11-2">
1169 if ( flag – ) (immideate)<br >
1170                 "if 1.. else 2.. then" or<br >
1171                 "if 1.. then" construction. Conditional execution.<br >
1172                 Performs "1.." if "flag" was true,<br >
1173                 elseway performs "2.." if exist. Execution continues after<br >
1174                 word "then".<br >
1175                 ex: 1 if ." nonzero" else ." zero" then<br >
1177 >= ( n1 n2 – result ) true if (n1 = n2) or (n1 > n2)<br >
1178                 ex: 5 3 >= if ." first number is greater or equal" then<br >
1180 <= ( n1 n2 – result ) true if (n1 = n2) or (n1 < n2)<br >
1181 = ( n1 n2 – result ) true if n1 = n2<br >
1183 do ( count – ) (immideate)<br >
1184                 "do .. loop" construction. Performs ".." "count" times.<br >
1185                 In every step "count" is decareased until it is 0.<br >
1186                 ex: : test 5 do i .d loop ;<br >
1187                 result: 4 3 2 1 0<br >
1189 doexit ( – ) exit from "do .. loop"<br >
1191 for ( count top – ) (immideate)<br >
1192                 "for .. loop" construction. Performs ".." (top - count) times.<br >
1193                 In every step "count" is incareased until it reaches "top" .<br >
1194                 ex: : test 4 10 for i .d loop ;<br >
1195                 result: 4 5 6 7 8 9<br >
1197 forexit ( – ) exit from "for .. loop"<br >
1199 until ( – ) (immideate)<br >
1200                 "until .. loop" construction. Performs ".." until flag become<br >
1201                 true. False by default. Top of return stack holds flag.<br >
1203 done ( – ) exit from "until .. loop"<br >
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 & file access</h3>
1210 <div class="outline-text-3" id="text-11-3">
1212 diskload ( FromDisk ToMem amount – )<br >
1213                 Load specified abount of bytes from disk into memory.<br >
1215 disksave ( FromMem ToDisk amount – )<br >
1216                 save specified abount of bytes from memory into disk.<br >
1218 format ( – ) Erase all files.<br >
1220 fsDfilesize@ ( handle – size )<br >
1221                 Return size of opened file.<br >
1223 fsDcurloc@ ( handle – location )<br >
1224                 Return current location in file.<br >
1226 fsDupdated@ ( handle – updated? )<br >
1227                 Return true if file was updated,<br >
1228                 ie. write operations occured.<br >
1230 fssave ( FromMem DestFileHandle amount – )<br >
1231                 Save data to file.<br >
1233 fsload ( SrcFileHandle ToMem amount – )<br >
1234                 Load data from file.<br >
1236 fseof ( handle – bytesLeft )<br >
1237                 Return amount of bytes left till end of file.<br >
1238                 Useful before read operation.<br >
1240 fsls ( – ) List all files and lists (directories,folders)<br >
1241                 in current path.<br >
1243 fslsr ( – ) Same as "fsls" but recursively scans also sub lists.<br >
1245 fscl ( DynStrHand – )<br >
1246                 Change list (path)<br >
1248 fscreate ( DynStrHand – DescPnt )<br >
1249                 Create new file or list. Can create multiple lists at once.<br >
1250                 ex: when creating:<br >
1251                     "\listGAMES\listSTRATEGY\listSIMWORLD\5th-runme"<br >
1252                 and only "\listGAMES\" already exist, then<br >
1253                 "listSTRATEGY" and "listSIMWORLD" lists will be created,<br >
1254                 and empty file "5th-runme" placed in there.<br >
1256 fsDsave ( DynHand<data> DynStrHand<filename> – )<br >
1257                 Create new file and save all data from dynamic memory<br >
1258                 block to it.<br >
1260 fsDload ( DynStr<SrcFileName> DynHand<DataDest> – )<br >
1261                 Load whole file into dynamic memory block.<br >
1263 fsDloadnew ( DynStr<SrcFileName> – DynHand<DataDest> )<br >
1264                 Load whole file into new dynamic memory block.<br >
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">
1272 dynal ( size – handle )<br >
1273                 Allocate dynamic memory block and return it's handle.<br >
1275 dynde ( handle – )<br >
1276                 Deallocate dynamic memory block.<br >
1278 dynp ( handle – addr )<br >
1279                 Returns pointer to memory where dynamic block<br >
1280                 data begins.<br >
1282 dyns ( handle – size )<br >
1283                 Returns size of dynamic block.<br >
1285 dynresize ( NewSize handle – )<br >
1286                 Nondestructively resize dynamic block.<br >
1288 dync@ ( addr handle )<br >
1289                 Read one byte from dynamic block.<br >
1291 dync! ( byte addr dynhandle )<br >
1292                 Write one byte to dynamic block.<br >
1294 dyn@ ( addr handle )<br >
1295                 Read 32 bit number from dynamic block.<br >
1296                 Address will spacify, whitch number, not byte.<br >
1298 dyn! ( 32BitNum addr dynhandle )<br >
1299                 Write 32 bit number to dynamic block.<br >
1300                 Address will spacify, whitch number, not byte.<br >
1302 dyncon ( size "name" – )<br >
1303                 Allocate dynamic block with specified size, and<br >
1304                 create constant honding its handle.<br >
1305                 ex: 100 dyncon MyNewBlock<br >
1307 dyn. ( handle – )<br >
1308                 Write contenc of dynamic memory block to screen.<br >
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">
1316 . ( n – ) print number on screen<br >
1318 d. ( n – ) print number on screen in decimal<br >
1320 ? ( addr – ) print 32 bit value located at addr.<br >
1322 ." <string>" ( – ) print string into screen. Immideately<br >
1323                 compiles.<br >
1324                 ex: : greeting ." Hello, World" ;<br >
1326 tab. ( – ) print tabulator<br >
1328 calccol ( b g r – c ) calculate color what best matches given<br >
1329                 Blue Green & Red values. Values must be in range 0 - 255.<br >
1331 imgalloc ( xsize ysize – imgbuf ) allocate image buffer for<br >
1332                 specified size.<br >
1334 imgsize ( imgbuf – ) print on the screen X & Y size of image<br >
1335                 buffer.<br >
1337 point ( x y imgbuf – addr ) returns memory address for specified<br >
1338                 pixel.<br >
1340 pset ( color x y imgbuf – ) set graphic point<br >
1342 boxf ( x1 x2 y1 y2 imgbuf color – ) draw filled box<br >
1344 cls ( imgbuf – ) clear image buffer<br >
1346 setpal ( b g r color – ) set palette value for specified color.<br >
1347                 values bust be in size 0 - 63.<br >
1349 putchar ( char color x y imgbuf – ) put graphic character in<br >
1350                 imagebuffer to specified (x & y) location.<br >
1352 scroll ( x y imgbuf – ) scroll in imgbuf.<br >
1354 scrollf ( color x y screen – ) scroll and fill empty space with<br >
1355                 given color.<br >
1357 at! ( x y – ) set cursor location<br >
1358 curc! ( color – ) set text color<br >
1359 curb! ( solor – ) set backround color<br >
1361 colnorm ( – ) set text color to normal<br >
1362 colneg ( – ) set text color to negative (selected)<br >
1364 dyntype ( dynhandle – ) display contenc of dynamic memory on screen<br >
1365 fsdisp ( file – ) clear screen, display file, and wait for key<br >
1367 type ( addr length – )<br >
1368                 Types on the screen string, from memory at addr and<br >
1369                 specified length.<br >
1371 write ( addr – )<br >
1372                 Types on the screen string, from memory at "addr"+1<br >
1373                 length is taken from "addr" .<br >
1375 screen const 32 bit<br >
1376                 Holds handle of screen buffer.<br >
1378 copyscreen ( SrcImgHandle DestImgHandle – ) copy contenc of source<br >
1379                 image to destination image. Source and destination images<br >
1380                 must have same size.<br >
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 & stack manipulation</h3>
1386 <div class="outline-text-3" id="text-11-6">
1388 off ( n – ) writes 0 to given address, good for zeroing variable.<br >
1389                 ex: MyVariable off<br >
1390 on ( n – ) writes -1 (true flag) to given address.<br >
1391                 ex: MyVariable on<br >
1393 2dup ( n1 n2 – n1 n2 n1 n2 )<br >
1394 2drop ( n1 n2 – )<br >
1395 nip ( n1 n2 – n2 )<br >
1396 neg ( n1 – -n1 ) negotiate<br >
1397 bit@ ( n bit – result ) return specified bit from n.<br >
1398                 ex: 38 2 bit@ (result will be 1)<br >
1399 to32bit ( n1 n2 n3 n4 – n32 ) treat 4 last stack elements as bytes<br >
1400                 and unite them into 32 bit dword. Most significant byte<br >
1401                 on top.<br >
1402                 ex: 12 76 23 11 to32bit result: 186076172<br >
1404 to8bit ( n32 – n1 n2 n3 n4 ) break 32 bit number into 4 bytes.<br >
1405                 Useful if you need to send 32 bit numbers thru 8 bit COM<br >
1406                 port.<br >
1407                 ex: 186076172 to8bit result: 12 76 23 11<br >
1409 mod ( n1 n2 – reminder ) divide n1 by n2 and returns reminder.<br >
1410                 ex: 12 5 mod result: 2<br >
1412 bound ( low n high – n ) check if n is in given bounds,<br >
1413                 if not then incarease/decarease it to match bounds.<br >
1414                 ex: 5 80 15 bound result: 15<br >
1415                     5 10 15 bound result: 10<br >
1416                     5 -10 15 bound result: 5<br >
1418 bound? ( low n high – result ) returns true if n is in the<br >
1419                 given bounds.<br >
1421 tab ( col – spaces) calculate amount of spaces to add<br >
1422                 ta reach next tabulation from given column.<br >
1424 count ( addr – addr+1 n )<br >
1425                 Useful for returning bytes from constantly incareasing<br >
1426                 address. Module "type" is nice example.<br >
1428 c, ( n – )<br >
1429                 store one byte at memory specified by "h". And incarease<br >
1430                 "h" by 1.<br >
1432 , ( n – )<br >
1433                 store 32 bit number at memory specified by "h". And<br >
1434                 incarease "h" by 4.<br >
1436 cmove ( addr1 addr2 n – )<br >
1437                 copy "n" amount of bytes from memory at "addr1" to memory<br >
1438                 at "addr2".<br >
1440 rnd ( limit – result )<br >
1441                 generates random number in range 0 to "limit"-1.<br >
1443 abs ( n – |n| )<br >
1444                 returns absolute value of "n"<br >
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 & static strings</h3>
1450 <div class="outline-text-3" id="text-11-7">
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.
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.
1465 Both types of strings are stored in the way, where first (0th) byte
1466 holds current string length, following bytes are string itself.
1473 Dstral ( – handle )<br >
1474                 Allocate new string.<br >
1476 Dstrlen ( handle – length )<br >
1477                 Return string length.<br >
1479 c+Dstr ( chr handle – )<br >
1480                 Add one byte to end of the string.<br >
1482 c+lDstr ( chr handle – )<br >
1483                 Add one byte to left side (beginning) of the string.<br >
1485 Dstr. ( handle – )<br >
1486                 Write contec of string into screen.<br >
1488 Dstrsure ( size Dstr – )<br >
1489                 Makes sure that at least rquested<br >
1490                 "size" (amount of characters) is allocated for given<br >
1491                 dynamic string.<br >
1493 Dstr2str ( handle address – )<br >
1494                 Copy dyamic string into static memory space.<br >
1496 str2Dstr ( address handle – )<br >
1497                 Copy static string into dyamic string.<br >
1499 Dstr+str ( Dstr addr – )<br >
1500                 Add contenc of dynamic string to static string.<br >
1502 D" any string" ( – Dstr )<br >
1503                 Moves specified string into dynamic string called "defDstr".<br >
1505 D> any_string ( – Dstr )<br >
1506                 Moves specified string into dynamic string called "defDstr".<br >
1507                 Space marks end of string!<br >
1509 D>2 any_string ( – Dstr )<br >
1510                 Moves specified string into dynamic string called "defDstr2".<br >
1511                 Space marks end of string!<br >
1513 Dstr+Dstr ( Dstr1 Dstr2 – )<br >
1514                 Adds "Dstr1" to "Dstr2" and places result into "Dstr2".<br >
1516 Dstrclear ( Dstr – )<br >
1517                 Clears contenc of dynamic string.<br >
1519 Dstr2Dstr ( Dstr1 Dstr2 – )<br >
1520                 Moves "Dstr1" to "Dstr2".<br >
1521 Dstr ( data" name – )<br >
1522                 Creates new dynamic string and moves specified data into it.<br >
1523                 Then creates new constant with given "name" holding created<br >
1524                 dynamic string handle.<br >
1526                 ex: Dstr Hello, my name is Sven!" message \ creates it<br >
1527                     message Dstr. \ tests it<br >
1529 Dstrlscan ( char Dstr – loc )<br >
1530                 Searches dynamic string for "char", from left to right,<br >
1531                 returns first found "char" location in string, or 0,<br >
1532                 if not found.<br >
1534 Dstrrscan ( char Dstr – loc )<br >
1535                 Searches dynamic string for "char", from right to left,<br >
1536                 returns first found "char" location in string, or 0,<br >
1537                 if not found.<br >
1539 Dstrlscane ( char Dstr – loc )<br >
1540                 Same as "Dstrlscan" buf returns string length+1 as location.<br >
1542 Dstrleft ( amo Dstr – )<br >
1543                 Only specified amount of characters from left remains<br >
1544                 in dynamic string. ie. cut right part out.<br >
1546 Dstrright ( amo Dstr – )<br >
1547                 Only specified amount of characters from right remains<br >
1548                 in dynamic string. ie. cut left part out.<br >
1550 Dstrcutl ( amo Dstr – )<br >
1551                 Cut specified amount of characters from left of dynamic<br >
1552                 string out.<br >
1554 Dstrsp ( char Dstr1 Dstr2 – )<br >
1555                 Separate dynamic string in Dstr1 into two parts,<br >
1556                 using "char" as separator. First part will be stored in<br >
1557                 "Dstr2", second part in "Dstr1".<br >
1558                 ex: asc \ \ ..separator<br >
1559                     D> listF\listLIB\5TH_DRVMOUSE \ ..separate from<br >
1560                     defDstr2 \ ..place result in<br >
1561                     Dstrsp \ separation command<br >
1562                     defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE<br >
1563                     defDstr2 Dstr. \ will be: listF<br >
1565 Dv ( addr – )<br >
1566                 Allocates empty dynamic string, and places it's handle<br >
1567                 into given address.<br >
1569 Df ( addr – )<br >
1570                 Reads dynamic string handle from given address and<br >
1571                 deallocates (frees) it.<br >
1573 ex: var mystring1<br >
1574         : testmodule<br >
1575         mystring1 Dv \ allocates string<br >
1577                 <whatever><br >
1579         mystring1 Df ; \ deallocates it again when no longer needed.<br >
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">
1592 KBD_@ ( – code ) get scancodes for pressed keys from keyboard.<br >
1593 KBD_down? ( key – result ) check is key with specified scancode<br >
1594                 currently pressed down.<br >
1595 KBD_SC2FSCII ( code – FSCII ) convert key scancode into FSCII code,<br >
1596                 or in FSK (Fifth standard keycode).<br >
1597 KBD_F@ ( – FSCII ) read pressed key FSCII or FSK, returns -1 if no<br >
1598                 keys are pressed.<br >
1599 KBD_FW@ ( – FSCII ) read pressed key FSCII or FSK, if no keys is<br >
1600                 are pressed then waits until there is.<br >
1602                 FSK<br >
1603                 —<br >
1612 401 … F1 …<br >
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">
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                 if true. (good for debugging)<br >
1637 mousepointer var Image buffer, holding current mouse pointer.<br >
1638 mouseadd ( ModuleAddr x1 x2 y1 y2 – ) Add specified area on screen,<br >
1639                 into mause click buffer. If any mouse button is clicked on<br >
1640                 that area, module at "ModuleAddr" will be executed.<br >
1641 mousebe var Amount of buffer elements.<br >
1642 mousedo ( – ) Updates mouse coordinates and keys. Parse mouse<br >
1643                 click buffer, and draw mouse cursor to "screen".<br >
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">
1651 lineh ( color len x y imgbuf – ) draws horisontal line<br >
1652                 from X,Y coordinates to right, with specified length.<br >
1653 linev ( color len x y imgbuf – ) draws vertical line<br >
1654                 down, from coordinates X,Y, with specified length.<br >
1655 box ( color x2 x1 y2 y1 imgbuf – ) draws rectangular<br >
1656                 box. x2 bust be >= x1, y2 must be >= y1.<br >
1657                         x1,y1–———+<br >
1658                           | |<br >
1659                           | |<br >
1660                           +–———x2,y2<br >
1662 flipv ( imgbuf – ) flip image vertically.<br >
1663 imgcoltrans ( ImgBuf Color ToColor – ) Translate all pixels in<br >
1664                 specified image with "Color" into "ToColor".<br >
1665 imgfill ( color x y imgbuf – ) Fill image region starting at location<br >
1666                 X & Y with specified color.<br >
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">
1674 sin ( a – result ) return sinus from given angle "a",<br >
1675                 360ø is 2000. So 1000 represents 180ø angle.<br >
1676                 Result will be in range -10'000 to 10'000, instead of ñ1.<br >
1678 cos ( a – result ) return cosinus from given angle.<br >
1679                 Parameters are like in "sin" function.<br >
1684 </div><div class="col-md-3"><nav id="table-of-contents">
1685 <div id="text-table-of-contents" class="bs-docs-sidebar">
1687 <li><a href="#sec-1">1. !Project deprecated!</a></li>
1688 <li><a href="#sec-2">2. Introduction</a>
1690 <li><a href="#sec-2-1">2.1. screenshots</a></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>
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>
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>
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>
1710 <li><a href="#sec-8">8. Core architecture</a>
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>
1717 <li><a href="#sec-9">9. Virtual machine</a></li>
1718 <li><a href="#sec-10">10. Fifth source format</a>
1720 <li><a href="#sec-10-1">10.1. FSCII</a></li>
1723 <li><a href="#sec-11">11. Fifth commands</a>
1725 <li><a href="#sec-11-1">11.1. Compilation & miscellaneous</a></li>
1726 <li><a href="#sec-11-2">11.2. Conditionals & control flow</a></li>
1727 <li><a href="#sec-11-3">11.3. Disk & 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 & stack manipulation</a></li>
1731 <li><a href="#sec-11-7">11.7. Dynamic & static strings</a></li>
1734 <li><a href="#sec-12">12. Dynamically loadable modules</a>
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>
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>