4 <title>Fifth - virtual machine, operating system, programming language</title>
5 <!-- 2017-11-29 Wed 23:48 -->
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.
291 <li><a href="emulator.html">Virtual CPU</a>
293 <li><a href="commands/index.html">Built-in commands</a>
295 <li><a href="modules/index.html">Additional commands, realized as loadable modules</a>
297 <li><a href="5TH_ET.txt">Example Fifth source file - text editor</a>
302 <div id="outline-container-sec-3" class="outline-2">
303 <h2 id="sec-3"><span class="section-number-2">3</span> Installation</h2>
304 <div class="outline-text-2" id="text-3">
306 Just unpack all files, witout altering original directory structure,
307 somewhere in your hard disk. For example: C:\MISC\FIFTH\…. To run
308 fifth you need minimally just 2 files. emulator itself ( EMULATOR.EXE
309 or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
313 Read more about <i>distribution directory layout</i>
317 <div id="outline-container-sec-4" class="outline-2">
318 <h2 id="sec-4"><span class="section-number-2">4</span> Software/Hardware/Human requirements</h2>
319 <div class="outline-text-2" id="text-4">
320 </div><div id="outline-container-sec-4-1" class="outline-3">
321 <h3 id="sec-4-1"><span class="section-number-3">4.1</span> Software:</h3>
322 <div class="outline-text-3" id="text-4-1">
324 <li>MS-DOS 6.22, with HIMEM.SYS loaded.
326 <li>Mouse driver if you have a mouse.
328 <li>Does work only when CPU is in real mode.
330 <li>To recompile ASM sources I used FASM (Flat Assembler).
332 <li>I ran QBasic utilities on QB 4.5 .
334 <li>VESA support by BIOS, or external driver (UNIVBE).
339 <div id="outline-container-sec-4-2" class="outline-3">
340 <h3 id="sec-4-2"><span class="section-number-3">4.2</span> Hardware:</h3>
341 <div class="outline-text-3" id="text-4-2">
345 <li>64 KB free RAM below 640KB,
347 <li>2 MB of free XMS.
349 <li>VESA compatible video card.
354 <div id="outline-container-sec-4-3" class="outline-3">
355 <h3 id="sec-4-3"><span class="section-number-3">4.3</span> Human:</h3>
356 <div class="outline-text-3" id="text-4-3">
358 <li>Beginner level Forth knowledge is recommended.
360 <li>Lots of enthusiasm.
366 <div id="outline-container-sec-5" class="outline-2">
367 <h2 id="sec-5"><span class="section-number-2">5</span> Numbers representation</h2>
368 <div class="outline-text-2" id="text-5">
371 <p><a href="numbers.png"><img src="numbers.png" class="img-responsive" alt="numbers.png"></a>
376 Because I can define everything, starting from CPU, why not try also
377 alternative and unique number representation ?
381 Fifth uses its hexdecimal number representation as primary. Numbers
382 shape is formed by dividing a square into four parts. And manipulating
383 their color (black or white).
387 <div id="outline-container-sec-6" class="outline-2">
388 <h2 id="sec-6"><span class="section-number-2">6</span> Disk file map, and it's data structures</h2>
389 <div class="outline-text-2" id="text-6">
391 Core and high-level boot code is stored outside of the filesystem to
392 allow easy access to it, at early booting time, when filesystem is not
396 <div id="outline-container-sec-6-1" class="outline-3">
397 <h3 id="sec-6-1"><span class="section-number-3">6.1</span> disk allocation</h3>
398 <div class="outline-text-3" id="text-6-1">
399 <table class="table table-striped table-bordered table-hover table-condensed">
411 <th scope="col" class="text-left">offset</th>
412 <th scope="col" class="text-left">length</th>
413 <th scope="col" class="text-left">description</th>
418 <td class="text-left">0</td>
419 <td class="text-left">~4 Kb</td>
420 <td class="text-left">Fifth core</td>
424 <td class="text-left">4 Kb</td>
425 <td class="text-left">~32Kb</td>
426 <td class="text-left">high-level boot code</td>
430 <td class="text-left">37 Kb</td>
431 <td class="text-left">~65Kb</td>
432 <td class="text-left">FAT</td>
436 <td class="text-left">101Kb</td>
437 <td class="text-left">~16MB</td>
438 <td class="text-left">filesystem data area</td>
444 <div id="outline-container-sec-6-2" class="outline-3">
445 <h3 id="sec-6-2"><span class="section-number-3">6.2</span> FAT entry format:</h3>
446 <div class="outline-text-3" id="text-6-2">
447 <table class="table table-striped table-bordered table-hover table-condensed">
457 <th scope="col" class="text-right">code</th>
458 <th scope="col" class="text-left">meaning</th>
463 <td class="text-right">-2</td>
464 <td class="text-left">last sector</td>
468 <td class="text-right">-1</td>
469 <td class="text-left">empty sector</td>
473 <td class="text-right">0 --</td>
474 <td class="text-left">.. pointer to next block</td>
480 <div id="outline-container-sec-6-3" class="outline-3">
481 <h3 id="sec-6-3"><span class="section-number-3">6.3</span> file entry format</h3>
482 <div class="outline-text-3" id="text-6-3">
483 <table class="table table-striped table-bordered table-hover table-condensed">
495 <th scope="col" class="text-right">offset</th>
496 <th scope="col" class="text-right">length</th>
497 <th scope="col" class="text-left">description</th>
502 <td class="text-right">0</td>
503 <td class="text-right">4</td>
504 <td class="text-left">extension</td>
508 <td class="text-right">4</td>
509 <td class="text-right">16</td>
510 <td class="text-left">name</td>
514 <td class="text-right">20</td>
515 <td class="text-right">4</td>
516 <td class="text-left">entry point</td>
520 <td class="text-right">24</td>
521 <td class="text-right">4</td>
522 <td class="text-left">size</td>
526 <td class="text-right">28</td>
527 <td class="text-right">4</td>
528 <td class="text-left">last modification time</td>
535 <div id="outline-container-sec-7" class="outline-2">
536 <h2 id="sec-7"><span class="section-number-2">7</span> Core architecture</h2>
537 <div class="outline-text-2" id="text-7">
539 Fifth core is simply some amount of already compiled into machine code
540 and linked together modules (entries in other words). In compilation
541 process modules is compiled one by one and simply stored on top of
542 already existing and growing core. Separately from core is kept
543 dictionary, this is special list that contain names of compiled
544 modules, variables etc. and they locations in core. Constants use
545 dictionary space only. Random word can be removed from dictionary at
546 any time. Currently dictionary can contain at most 1000 entries.
549 <div id="outline-container-sec-7-1" class="outline-3">
550 <h3 id="sec-7-1"><span class="section-number-3">7.1</span> dictionary entry format</h3>
551 <div class="outline-text-3" id="text-7-1">
552 <table class="table table-striped table-bordered table-hover table-condensed">
564 <th scope="col" class="text-right">offset</th>
565 <th scope="col" class="text-right">length</th>
566 <th scope="col" class="text-left">description</th>
571 <td class="text-right">0</td>
572 <td class="text-right">4</td>
573 <td class="text-left">0 &lt; previous entry</td>
577 <td class="text-right"> </td>
578 <td class="text-right"> </td>
579 <td class="text-left">0 = last</td>
583 <td class="text-right"> </td>
584 <td class="text-right"> </td>
585 <td class="text-left">-1 = empty</td>
590 <td class="text-right">4</td>
591 <td class="text-right">15</td>
592 <td class="text-left">module name string</td>
597 <td class="text-right">19</td>
598 <td class="text-right">1</td>
599 <td class="text-left">entry type</td>
604 <td class="text-right">20</td>
605 <td class="text-right">4</td>
606 <td class="text-left">entry data</td>
612 Core headers as linked list of module names make up something like
613 dictionary. When some entry address is needed compiler can quickly
614 run through headers backwards and find needed entry.
618 <div id="outline-container-sec-7-2" class="outline-3">
619 <h3 id="sec-7-2"><span class="section-number-3">7.2</span> Possible module types</h3>
620 <div class="outline-text-3" id="text-7-2">
621 <table class="table table-striped table-bordered table-hover table-condensed">
633 <th scope="col" class="text-right">type</th>
634 <th scope="col" class="text-left">description</th>
635 <th scope="col" class="text-left">"execute" action</th>
640 <td class="text-right">0</td>
641 <td class="text-left">data</td>
642 <td class="text-left">compile "num" instruction</td>
646 <td class="text-right"> </td>
647 <td class="text-left"> </td>
648 <td class="text-left">with address to module</td>
653 <td class="text-right">1</td>
654 <td class="text-left">submodule</td>
655 <td class="text-left">compile "call" instruction</td>
659 <td class="text-right"> </td>
660 <td class="text-left"> </td>
661 <td class="text-left">with address to module</td>
666 <td class="text-right">2</td>
667 <td class="text-left">imm. submodule</td>
668 <td class="text-left">immediately call to module</td>
674 <div id="outline-container-sec-7-3" class="outline-3">
675 <h3 id="sec-7-3"><span class="section-number-3">7.3</span> Memory map: (average)</h3>
676 <div class="outline-text-3" id="text-7-3">
677 <table class="table table-striped table-bordered table-hover table-condensed">
689 <th scope="col" class="text-right"><loc></th>
690 <th scope="col" class="text-left"><size></th>
691 <th scope="col" class="text-left"><desc></th>
696 <td class="text-right">0</td>
697 <td class="text-left">~4096</td>
698 <td class="text-left">core</td>
702 <td class="text-right">1500000</td>
703 <td class="text-left">~32000</td>
704 <td class="text-left">highlevel Fifth boot code</td>
708 <td class="text-right">200000h</td>
709 <td class="text-left"> </td>
710 <td class="text-left">core startup messages area</td>
714 <td class="text-right">5200000</td>
715 <td class="text-left"> </td>
716 <td class="text-left">end of dynamic memory space</td>
723 <div id="outline-container-sec-8" class="outline-2">
724 <h2 id="sec-8"><span class="section-number-2">8</span> Fifth source format</h2>
725 <div class="outline-text-2" id="text-8">
727 Fifth uses a different character table and codes than ASCII (still
728 almost similar). I call it FSCII (Fifth Standard Code for Information
729 Interchange) for example space character is not 32 but 255 instead. I
730 plan to use mainly HEX numbers, and create new characters to represent
731 numeric values. So typical nemric characters "0123…" is treated
732 like ordinary letters.
735 <div id="outline-container-sec-8-1" class="outline-3">
736 <h3 id="sec-8-1"><span class="section-number-3">8.1</span> FSCII:</h3>
737 <div class="outline-text-3" id="text-8-1">
738 <table class="table table-striped table-bordered table-hover table-condensed">
750 <th scope="col" class="text-right">DEC</th>
751 <th scope="col" class="text-left">HEX</th>
752 <th scope="col" class="text-left">function</th>
757 <td class="text-right">0 - 15</td>
758 <td class="text-left">0 - F</td>
759 <td class="text-left">HEX numbers</td>
763 <td class="text-right">252</td>
764 <td class="text-left">FC</td>
765 <td class="text-left">backspace</td>
769 <td class="text-right">253</td>
770 <td class="text-left">FD</td>
771 <td class="text-left">tabulator (TAB)</td>
775 <td class="text-right">254</td>
776 <td class="text-left">FE</td>
777 <td class="text-left">carriage return (CR)</td>
781 <td class="text-right">255</td>
782 <td class="text-left">FF</td>
783 <td class="text-left">space</td>
787 <td class="text-right">else</td>
788 <td class="text-left"> </td>
789 <td class="text-left">ordinary characters, same as in ASCII.</td>
796 </div><div class="col-md-3"><nav id="table-of-contents">
797 <div id="text-table-of-contents" class="bs-docs-sidebar">
799 <li><a href="#sec-1">1. !Project deprecated!</a></li>
800 <li><a href="#sec-2">2. Introduction</a></li>
801 <li><a href="#sec-3">3. Installation</a></li>
802 <li><a href="#sec-4">4. Software/Hardware/Human requirements</a>
804 <li><a href="#sec-4-1">4.1. Software:</a></li>
805 <li><a href="#sec-4-2">4.2. Hardware:</a></li>
806 <li><a href="#sec-4-3">4.3. Human:</a></li>
809 <li><a href="#sec-5">5. Numbers representation</a></li>
810 <li><a href="#sec-6">6. Disk file map, and it's data structures</a>
812 <li><a href="#sec-6-1">6.1. disk allocation</a></li>
813 <li><a href="#sec-6-2">6.2. FAT entry format:</a></li>
814 <li><a href="#sec-6-3">6.3. file entry format</a></li>
817 <li><a href="#sec-7">7. Core architecture</a>
819 <li><a href="#sec-7-1">7.1. dictionary entry format</a></li>
820 <li><a href="#sec-7-2">7.2. Possible module types</a></li>
821 <li><a href="#sec-7-3">7.3. Memory map: (average)</a></li>
824 <li><a href="#sec-8">8. Fifth source format</a>
826 <li><a href="#sec-8-1">8.1. FSCII:</a></li>
833 <footer id="postamble" class="">
834 <div><p class="author">Author: Svjatoslav Agejenko</p>
835 <p class="date">Created: 2017-11-29 Wed 23:48</p>
836 <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>