Rephrased documentation for better readability
[fifth.git] / doc / index.html
old mode 100755 (executable)
new mode 100644 (file)
index 696f94c..174e5ec
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
-<meta
-    http-equiv="Content-Type"
-    content="text/html; charset=UTF-8">
-<title>FIFTH</title>
+<!-- 2023-09-19 Tue 18:07 -->
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<title>Fifth - virtual machine, operating system, programming language</title>
+<meta name="author" content="Svjatoslav Agejenko" />
+<meta name="generator" content="Org Mode" />
+<style>
+  #content { max-width: 60em; margin: auto; }
+  .title  { text-align: center;
+             margin-bottom: .2em; }
+  .subtitle { text-align: center;
+              font-size: medium;
+              font-weight: bold;
+              margin-top:0; }
+  .todo   { font-family: monospace; color: red; }
+  .done   { font-family: monospace; color: green; }
+  .priority { font-family: monospace; color: orange; }
+  .tag    { background-color: #eee; font-family: monospace;
+            padding: 2px; font-size: 80%; font-weight: normal; }
+  .timestamp { color: #bebebe; }
+  .timestamp-kwd { color: #5f9ea0; }
+  .org-right  { margin-left: auto; margin-right: 0px;  text-align: right; }
+  .org-left   { margin-left: 0px;  margin-right: auto; text-align: left; }
+  .org-center { margin-left: auto; margin-right: auto; text-align: center; }
+  .underline { text-decoration: underline; }
+  #postamble p, #preamble p { font-size: 90%; margin: .2em; }
+  p.verse { margin-left: 3%; }
+  pre {
+    border: 1px solid #e6e6e6;
+    border-radius: 3px;
+    background-color: #f2f2f2;
+    padding: 8pt;
+    font-family: monospace;
+    overflow: auto;
+    margin: 1.2em;
+  }
+  pre.src {
+    position: relative;
+    overflow: auto;
+  }
+  pre.src:before {
+    display: none;
+    position: absolute;
+    top: -8px;
+    right: 12px;
+    padding: 3px;
+    color: #555;
+    background-color: #f2f2f299;
+  }
+  pre.src:hover:before { display: inline; margin-top: 14px;}
+  /* Languages per Org manual */
+  pre.src-asymptote:before { content: 'Asymptote'; }
+  pre.src-awk:before { content: 'Awk'; }
+  pre.src-authinfo::before { content: 'Authinfo'; }
+  pre.src-C:before { content: 'C'; }
+  /* pre.src-C++ doesn't work in CSS */
+  pre.src-clojure:before { content: 'Clojure'; }
+  pre.src-css:before { content: 'CSS'; }
+  pre.src-D:before { content: 'D'; }
+  pre.src-ditaa:before { content: 'ditaa'; }
+  pre.src-dot:before { content: 'Graphviz'; }
+  pre.src-calc:before { content: 'Emacs Calc'; }
+  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
+  pre.src-fortran:before { content: 'Fortran'; }
+  pre.src-gnuplot:before { content: 'gnuplot'; }
+  pre.src-haskell:before { content: 'Haskell'; }
+  pre.src-hledger:before { content: 'hledger'; }
+  pre.src-java:before { content: 'Java'; }
+  pre.src-js:before { content: 'Javascript'; }
+  pre.src-latex:before { content: 'LaTeX'; }
+  pre.src-ledger:before { content: 'Ledger'; }
+  pre.src-lisp:before { content: 'Lisp'; }
+  pre.src-lilypond:before { content: 'Lilypond'; }
+  pre.src-lua:before { content: 'Lua'; }
+  pre.src-matlab:before { content: 'MATLAB'; }
+  pre.src-mscgen:before { content: 'Mscgen'; }
+  pre.src-ocaml:before { content: 'Objective Caml'; }
+  pre.src-octave:before { content: 'Octave'; }
+  pre.src-org:before { content: 'Org mode'; }
+  pre.src-oz:before { content: 'OZ'; }
+  pre.src-plantuml:before { content: 'Plantuml'; }
+  pre.src-processing:before { content: 'Processing.js'; }
+  pre.src-python:before { content: 'Python'; }
+  pre.src-R:before { content: 'R'; }
+  pre.src-ruby:before { content: 'Ruby'; }
+  pre.src-sass:before { content: 'Sass'; }
+  pre.src-scheme:before { content: 'Scheme'; }
+  pre.src-screen:before { content: 'Gnu Screen'; }
+  pre.src-sed:before { content: 'Sed'; }
+  pre.src-sh:before { content: 'shell'; }
+  pre.src-sql:before { content: 'SQL'; }
+  pre.src-sqlite:before { content: 'SQLite'; }
+  /* additional languages in org.el's org-babel-load-languages alist */
+  pre.src-forth:before { content: 'Forth'; }
+  pre.src-io:before { content: 'IO'; }
+  pre.src-J:before { content: 'J'; }
+  pre.src-makefile:before { content: 'Makefile'; }
+  pre.src-maxima:before { content: 'Maxima'; }
+  pre.src-perl:before { content: 'Perl'; }
+  pre.src-picolisp:before { content: 'Pico Lisp'; }
+  pre.src-scala:before { content: 'Scala'; }
+  pre.src-shell:before { content: 'Shell Script'; }
+  pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
+  /* additional language identifiers per "defun org-babel-execute"
+       in ob-*.el */
+  pre.src-cpp:before  { content: 'C++'; }
+  pre.src-abc:before  { content: 'ABC'; }
+  pre.src-coq:before  { content: 'Coq'; }
+  pre.src-groovy:before  { content: 'Groovy'; }
+  /* additional language identifiers from org-babel-shell-names in
+     ob-shell.el: ob-shell is the only babel language using a lambda to put
+     the execution function name together. */
+  pre.src-bash:before  { content: 'bash'; }
+  pre.src-csh:before  { content: 'csh'; }
+  pre.src-ash:before  { content: 'ash'; }
+  pre.src-dash:before  { content: 'dash'; }
+  pre.src-ksh:before  { content: 'ksh'; }
+  pre.src-mksh:before  { content: 'mksh'; }
+  pre.src-posh:before  { content: 'posh'; }
+  /* Additional Emacs modes also supported by the LaTeX listings package */
+  pre.src-ada:before { content: 'Ada'; }
+  pre.src-asm:before { content: 'Assembler'; }
+  pre.src-caml:before { content: 'Caml'; }
+  pre.src-delphi:before { content: 'Delphi'; }
+  pre.src-html:before { content: 'HTML'; }
+  pre.src-idl:before { content: 'IDL'; }
+  pre.src-mercury:before { content: 'Mercury'; }
+  pre.src-metapost:before { content: 'MetaPost'; }
+  pre.src-modula-2:before { content: 'Modula-2'; }
+  pre.src-pascal:before { content: 'Pascal'; }
+  pre.src-ps:before { content: 'PostScript'; }
+  pre.src-prolog:before { content: 'Prolog'; }
+  pre.src-simula:before { content: 'Simula'; }
+  pre.src-tcl:before { content: 'tcl'; }
+  pre.src-tex:before { content: 'TeX'; }
+  pre.src-plain-tex:before { content: 'Plain TeX'; }
+  pre.src-verilog:before { content: 'Verilog'; }
+  pre.src-vhdl:before { content: 'VHDL'; }
+  pre.src-xml:before { content: 'XML'; }
+  pre.src-nxml:before { content: 'XML'; }
+  /* add a generic configuration mode; LaTeX export needs an additional
+     (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
+  pre.src-conf:before { content: 'Configuration File'; }
+
+  table { border-collapse:collapse; }
+  caption.t-above { caption-side: top; }
+  caption.t-bottom { caption-side: bottom; }
+  td, th { vertical-align:top;  }
+  th.org-right  { text-align: center;  }
+  th.org-left   { text-align: center;   }
+  th.org-center { text-align: center; }
+  td.org-right  { text-align: right;  }
+  td.org-left   { text-align: left;   }
+  td.org-center { text-align: center; }
+  dt { font-weight: bold; }
+  .footpara { display: inline; }
+  .footdef  { margin-bottom: 1em; }
+  .figure { padding: 1em; }
+  .figure p { text-align: center; }
+  .equation-container {
+    display: table;
+    text-align: center;
+    width: 100%;
+  }
+  .equation {
+    vertical-align: middle;
+  }
+  .equation-label {
+    display: table-cell;
+    text-align: right;
+    vertical-align: middle;
+  }
+  .inlinetask {
+    padding: 10px;
+    border: 2px solid gray;
+    margin: 10px;
+    background: #ffffcc;
+  }
+  #org-div-home-and-up
+   { text-align: right; font-size: 70%; white-space: nowrap; }
+  textarea { overflow-x: auto; }
+  .linenr { font-size: smaller }
+  .code-highlighted { background-color: #ffff00; }
+  .org-info-js_info-navigation { border-style: none; }
+  #org-info-js_console-label
+    { font-size: 10px; font-weight: bold; white-space: nowrap; }
+  .org-info-js_search-highlight
+    { background-color: #ffff00; color: #000000; font-weight: bold; }
+  .org-svg { }
+</style>
+<link rel="stylesheet" type="text/css" href="https://thomasf.github.io/solarized-css/solarized-dark.min.css" />
 </head>
 <body>
-    <h1>FIFTH - virtual machine, operating system, programming language</h1>
-    <a href="http://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=snapshot;h=HEAD;sf=tgz">Download</a>
-    &nbsp;&nbsp;
-    <a href="http://www2.svjatoslav.eu/gitbrowse/fifth/doc/index.html">Online homepage</a>
-    &nbsp;&nbsp;
-    <a href="http://svjatoslav.eu/programs.jsp">Other applications hosted on svjatoslav.eu</a>
-    <pre>
-<b>Program author:</b>
-    Svjatoslav Agejenko
-    Homepage: <a href="http://svjatoslav.eu">http://svjatoslav.eu</a>
-    Email: <a href="mailto:svjatoslav@svjatoslav.eu">svjatoslav@svjatoslav.eu</a>
-
-This software is distributed under <a href="http://www.gnu.org/licenses/gpl-2.0.html">GNU GENERAL PUBLIC LICENSE Version 2</a>.
-
-<h2>Introduction</h2>
-
-Fifth is programming lanquage & operating system, running on
-<a href="emulator.html">virtual CPU</a>, with custom instruction set. It is much like
-Charles Chunk Moore's Forth, it also uses stack architecture,
-and many commands are similar. Basically I got familiar with
-concepts of Forth, and being inspired created my own system.
-<p />
-Note:
-<i>
-Current implementation does not support object oriented programming.
-While working on Fifth I got lots of cool new ideas that require reimplementation
-of everything.
-Currently I try to implement those new ideas in the project called <a
-                href="http://svjatoslav.eu/static/gitbrowse/sixth/doc/index.html">Sixth</a>.
-</i>
-<br />
-<a href="shots/index.html">Screenshots</a>
-
-Read more about:
-<br>  <a href="emulator.html">Virtual CPU</a>
-<br>  <a href="commands/index.html">Built-in commands</a>
-<br>  <a href="modules/index.html">Additional commands, realized as loadable modules</a>
-<br>  <a href="5TH_ET.txt">Example Fifth source file - text editor </a>
-
-
-    <h2>Installation</h2>
-
+<div id="content" class="content">
+<h1 class="title">Fifth - virtual machine, operating system, programming language</h1>
+<div id="table-of-contents" role="doc-toc">
+<h2>Table of Contents</h2>
+<div id="text-table-of-contents" role="doc-toc">
+<ul>
+<li><a href="#orgdd8d5a0">1. General</a>
+<ul>
+<li><a href="#org11b4b95">1.1. Source code</a></li>
+</ul>
+</li>
+<li><a href="#org0a3946b">2. !Project deprecated!</a></li>
+<li><a href="#org74c9861">3. Introduction</a>
+<ul>
+<li><a href="#orge8b459e">3.1. Screenshots</a></li>
+</ul>
+</li>
+<li><a href="#orga9dfaee">4. Installation</a></li>
+<li><a href="#orgefa2f79">5. Fifth distribution directory tree description</a></li>
+<li><a href="#org751040b">6. Requirements</a>
+<ul>
+<li><a href="#org32f0917">6.1. Software</a></li>
+<li><a href="#orgd6ecfe1">6.2. Hardware</a></li>
+</ul>
+</li>
+<li><a href="#orgeb3cbc2">7. Numbers representation within Fifth</a></li>
+<li><a href="#orga8a8f37">8. Disk file map, and it's data structures</a>
+<ul>
+<li><a href="#org4eb67fc">8.1. Disk allocation</a></li>
+<li><a href="#org5fcae51">8.2. FAT entry format:</a></li>
+<li><a href="#org811dc5b">8.3. File entry format</a></li>
+</ul>
+</li>
+<li><a href="#orga49dca9">9. Core architecture</a>
+<ul>
+<li><a href="#org75e80d5">9.1. Dictionary entry format</a></li>
+<li><a href="#org12381ef">9.2. Possible module types</a></li>
+<li><a href="#org33be039">9.3. Memory map</a></li>
+</ul>
+</li>
+<li><a href="#org81fd544">10. Dynamically loadable modules</a>
+<ul>
+<li><a href="#org79d1c84">10.1. Keyboard driver</a></li>
+<li><a href="#org99b4378">10.2. Mouse driver</a></li>
+<li><a href="#org0aa9e1f">10.3. 2D graphic library</a></li>
+<li><a href="#orgff6cdef">10.4. Trigonometry functions</a>
+<ul>
+<li><a href="#org868f7c6">10.4.1. sin ( a &#x2013; result )</a></li>
+<li><a href="#orgc3f161e">10.4.2. cos ( a &#x2013; result )</a></li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+</div>
+</div>
+
+<div id="outline-container-orgdd8d5a0" class="outline-2">
+<h2 id="orgdd8d5a0"><span class="section-number-2">1.</span> General</h2>
+<div class="outline-text-2" id="text-1">
+<ul class="org-ul">
+<li>This program is free software: released under Creative Commons Zero
+(CC0) license</li>
+
+<li>Program author:
+<ul class="org-ul">
+<li>Svjatoslav Agejenko</li>
+<li>Homepage: <a href="https://svjatoslav.eu">https://svjatoslav.eu</a></li>
+<li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a></li>
+</ul></li>
+
+<li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a></li>
+</ul>
+</div>
+
+<div id="outline-container-org11b4b95" class="outline-3">
+<h3 id="org11b4b95"><span class="section-number-3">1.1.</span> Source code</h3>
+<div class="outline-text-3" id="text-1-1">
+<ul class="org-ul">
+<li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=snapshot;h=HEAD;sf=tgz">Download latest snapshot in TAR GZ format</a></li>
+
+<li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=summary">Browse Git repository online</a></li>
+
+<li><p>
+Clone Git repository using command:
+</p>
+<pre class="example">
+git clone https://www2.svjatoslav.eu/git/fifth.git
+</pre></li>
+</ul>
+</div>
+</div>
+</div>
+
+<div id="outline-container-org0a3946b" class="outline-2">
+<h2 id="org0a3946b"><span class="section-number-2">2.</span> !Project deprecated!</h2>
+<div class="outline-text-2" id="text-2">
+<p>
+Current implementation does not support object oriented
+programming. While working on Fifth I got lots of cool new ideas that
+require reimplementation of everything.
+</p>
+
+<p>
+Currently I try to implement those new ideas in the project called
+<a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
+</p>
+
+<p>
+System is built many years ago when I was still using DOS as a primary
+operating system.
+</p>
+</div>
+</div>
+<div id="outline-container-org74c9861" class="outline-2">
+<h2 id="org74c9861"><span class="section-number-2">3.</span> Introduction</h2>
+<div class="outline-text-2" id="text-3">
+<p>
+Fifth is a combination of:
+</p>
+<ul class="org-ul">
+<li><a href="language.html#ID-da7fff9b-0b67-4843-828a-52a404d7f401">Programming language</a> (inspired by Forth).</li>
+<li>Operating system.</li>
+<li><a href="virtual machine.html#ID-9b251eb9-aff6-4025-94bf-25e89e26d54a">Virtual machine</a> with custom instruction set.</li>
+</ul>
+</div>
+
+<div id="outline-container-orge8b459e" class="outline-3">
+<h3 id="orge8b459e"><span class="section-number-3">3.1.</span> Screenshots</h3>
+<div class="outline-text-3" id="text-3-1">
+
+<div id="org76cf04c" class="figure">
+<p><img src="screenshots/start.png" alt="start.png" />
+</p>
+</div>
+
+<p>
+Startup screen diplaying Fifth logo and full file list.
+</p>
+
+
+<div id="org7579242" class="figure">
+<p><img src="screenshots/dictionary.png" alt="dictionary.png" />
+</p>
+</div>
+
+<p>
+Sample words defined. Most of the words are commands that can be
+executed interactively from the command line or from a file. When
+executed, they can be selectively compiled or interpreted.
+</p>
+
+
+
+<div id="org17f3e64" class="figure">
+<p><img src="screenshots/text editor.png" alt="text editor.png" />
+</p>
+</div>
+
+<p>
+Built in text editor.
+</p>
+</div>
+</div>
+</div>
+
+<div id="outline-container-orga9dfaee" class="outline-2">
+<h2 id="orga9dfaee"><span class="section-number-2">4.</span> Installation</h2>
+<div class="outline-text-2" id="text-4">
+<p>
 Just unpack all files, witout altering original directory structure,
-somewhere in your hard disk. For example: C:\MISC\FIFTH\....
-To run fifth you need minimally just 2 files.
-emulator itself ( EMULATOR.EXE or EMULATOR.COM ), and
-virtual disk file ( DISK.RAW ).
-Read more about <a href="files.txt">distribution directory layout</a>.
-
-
-
-    <h2>Software/Hardware/Human requirements</h2>
-
-
-Software:
-    MS-DOS 6.22, with HIMEM.SYS loaded.
-       Mouse driver if you have a mouse.
-       Does work only when CPU is in real mode.
-       To recompile ASM sources I used FASM (Flat Assembler).
-       I ran QBasic utilities on QB 4.5 .
-       VESA support by BIOS, or external driver (UNIVBE).
-
-Hardware:
-    Minimum CPU 386.
-       64 KB free RAM below 640KB,
-       2 MB of free XMS.
-       VESA compatible video card.
-
-Human:
-    Beginner level Forth knowledge is recommended.
-       Enthusiasm.
-
-
-
-    <h2>Numbers representation</h2>
-
-<img src="numbers.png">
-
-Fifth uses hexdecimal number representation as primary.
-Numbers shape is formed by dividing a square into four parts.
-And manipulating their color (black or white).
-
-
-
-    <h2>Disk file map, and it's data structures</h2>
-
-
-Core and high-level boot code is stored outside of the filesystem to allow
-easy access to it, at early booting time, when filesystem is not yet
-initialized.
-
-                       disk allocation:
-
-offset length  description
-
-0      ~4 Kb   Fifth core
-4  Kb  ~32Kb   high-level boot code
-37 Kb  ~65Kb   FAT
-101Kb  ~16MB   filesystem data area
-
-                       FAT entry format:
-
--2     last sector
--1     empty sector
-0 --  .. pointer to next block
-
-                       file entry format
-
-offset length  description
-
-0      4       extension
-4      16      name
-20     4       entry point
-24     4       size
-28     4       last modification time
-
-
-
-    <h2>Core architecture</h2>
-
-
+somewhere in your hard disk. For example:
+</p>
+
+<pre class="example">
+C:\MISC\FIFTH\
+</pre>
+
+
+<p>
+To run fifth you need minimally just 2 files:
+</p>
+<dl class="org-dl">
+<dt>EMULATOR.COM</dt><dd>Virtual CPU emulator</dd>
+<dt>DISK.RAW</dt><dd>Virtual disk file</dd>
+</dl>
+
+<p>
+For more information, please refer to <a href="#orgefa2f79">Fifth distribution directory
+tree description</a>.
+</p>
+</div>
+</div>
+
+<div id="outline-container-orgefa2f79" class="outline-2">
+<h2 id="orgefa2f79"><span class="section-number-2">5.</span> Fifth distribution directory tree description</h2>
+<div class="outline-text-2" id="text-5">
+<p>
+After downloading and unpacking the ZIP file you shoud get directory
+tree similar to this:
+</p>
+
+<p class="verse">
+<b>DOC</b>                   - Fifth documentation<br />
+&#xa0;&#xa0;<b>commands</b>            - documentation on Fifth built-in commands<br />
+&#xa0;&#xa0;<b>modules</b>             - documentation on additional commands, realized as loadable modules<br />
+&#xa0;&#xa0;<b>shots</b>               - Fifth screenshots<br />
+<br />
+<b>imageFile</b>             - files contained within 'disk.raw', just an extracted form.<br />
+<br />
+<b>source</b>                - source files<br />
+&#xa0;&#xa0;<b>emulator</b>            - emulator source<br />
+&#xa0;&#xa0;<b>util</b>                - utilites<br />
+<br />
+<b>disk.raw</b>                - Virtual disk file, has filesystem inside.<br />
+<b>emulator.com</b>            - main executable.<br />
+</p>
+</div>
+</div>
+
+<div id="outline-container-org751040b" class="outline-2">
+<h2 id="org751040b"><span class="section-number-2">6.</span> Requirements</h2>
+<div class="outline-text-2" id="text-6">
+</div>
+<div id="outline-container-org32f0917" class="outline-3">
+<h3 id="org32f0917"><span class="section-number-3">6.1.</span> Software</h3>
+<div class="outline-text-3" id="text-6-1">
+<ul class="org-ul">
+<li>MS-DOS 6.22 with HIMEM.SYS loaded.</li>
+<li>Mouse driver (optional, if you have a mouse).</li>
+<li>CPU is initialized into <a href="https://en.wikipedia.org/wiki/Unreal_mode">Unreal Mode</a> during operation.</li>
+<li>To recompile ASM sources, you can use FASM (Flat Assembler).</li>
+<li>To run Quick Basic utilities, use Microsoft Quick Basic 4.5.</li>
+<li>VESA support through BIOS or external driver (UNIVBE).</li>
+</ul>
+</div>
+</div>
+
+<div id="outline-container-orgd6ecfe1" class="outline-3">
+<h3 id="orgd6ecfe1"><span class="section-number-3">6.2.</span> Hardware</h3>
+<div class="outline-text-3" id="text-6-2">
+<ul class="org-ul">
+<li>A minimum of a i386 CPU.</li>
+<li>64 KB of free RAM below 640KB.</li>
+<li>2 MB of free <a href="https://en.wikipedia.org/wiki/Extended_memory">extended memory</a>.</li>
+<li>A VESA-compatible video card.</li>
+</ul>
+</div>
+</div>
+</div>
+
+<div id="outline-container-orgeb3cbc2" class="outline-2">
+<h2 id="orgeb3cbc2"><span class="section-number-2">7.</span> Numbers representation within Fifth</h2>
+<div class="outline-text-2" id="text-7">
+<p>
+Because we are in full experimentation mode here (no regard for
+compatibility whatsoever), why not to try also alternative number
+representation ?
+</p>
+
+<p>
+Here alternative hexadecimal number representation format is devised:
+</p>
+
+
+<div id="org67795e4" class="figure">
+<p><a href="numbers.png"><img src="numbers.png" alt="numbers.png" /></a>
+</p>
+</div>
+
+<p>
+Essentially square is split into 4 triangles. Each triangle represents
+one bit.
+</p>
+
+<p>
+Fifth uses this hexadecimal format as primary throughout entire
+system.
+</p>
+
+<p>
+See also: <a href="https://en.wikipedia.org/wiki/Bibi-binary">Bibi-binary</a>.
+</p>
+</div>
+</div>
+
+<div id="outline-container-orga8a8f37" class="outline-2">
+<h2 id="orga8a8f37"><span class="section-number-2">8.</span> Disk file map, and it's data structures</h2>
+<div class="outline-text-2" id="text-8">
+<p>
+Core and high-level boot code is stored outside of the filesystem to
+allow easy access to it, at early booting time, when filesystem is not
+yet initialized.
+</p>
+</div>
+<div id="outline-container-org4eb67fc" class="outline-3">
+<h3 id="org4eb67fc"><span class="section-number-3">8.1.</span> Disk allocation</h3>
+<div class="outline-text-3" id="text-8-1">
+<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
+
+
+<colgroup>
+<col  class="org-left" />
+
+<col  class="org-left" />
+
+<col  class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-left">offset</th>
+<th scope="col" class="org-left">length</th>
+<th scope="col" class="org-left">description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="org-left">0</td>
+<td class="org-left">~4 Kb</td>
+<td class="org-left">Fifth core</td>
+</tr>
+
+<tr>
+<td class="org-left">4 Kb</td>
+<td class="org-left">~32 Kb</td>
+<td class="org-left">high-level boot code</td>
+</tr>
+
+<tr>
+<td class="org-left">37 Kb</td>
+<td class="org-left">~65 Kb</td>
+<td class="org-left">FAT</td>
+</tr>
+
+<tr>
+<td class="org-left">101 Kb</td>
+<td class="org-left">~16 MB</td>
+<td class="org-left">filesystem data area</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+<div id="outline-container-org5fcae51" class="outline-3">
+<h3 id="org5fcae51"><span class="section-number-3">8.2.</span> FAT entry format:</h3>
+<div class="outline-text-3" id="text-8-2">
+<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
+
+
+<colgroup>
+<col  class="org-right" />
+
+<col  class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-right">code</th>
+<th scope="col" class="org-left">meaning</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="org-right">-2</td>
+<td class="org-left">last sector</td>
+</tr>
+
+<tr>
+<td class="org-right">-1</td>
+<td class="org-left">empty sector</td>
+</tr>
+
+<tr>
+<td class="org-right">0 --</td>
+<td class="org-left">.. pointer to next block</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+<div id="outline-container-org811dc5b" class="outline-3">
+<h3 id="org811dc5b"><span class="section-number-3">8.3.</span> File entry format</h3>
+<div class="outline-text-3" id="text-8-3">
+<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
+
+
+<colgroup>
+<col  class="org-right" />
+
+<col  class="org-right" />
+
+<col  class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-right">offset</th>
+<th scope="col" class="org-right">length</th>
+<th scope="col" class="org-left">description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="org-right">0</td>
+<td class="org-right">4</td>
+<td class="org-left">extension</td>
+</tr>
+
+<tr>
+<td class="org-right">4</td>
+<td class="org-right">16</td>
+<td class="org-left">name</td>
+</tr>
+
+<tr>
+<td class="org-right">20</td>
+<td class="org-right">4</td>
+<td class="org-left">entry point</td>
+</tr>
+
+<tr>
+<td class="org-right">24</td>
+<td class="org-right">4</td>
+<td class="org-left">size</td>
+</tr>
+
+<tr>
+<td class="org-right">28</td>
+<td class="org-right">4</td>
+<td class="org-left">last modification time</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+</div>
+<div id="outline-container-orga49dca9" class="outline-2">
+<h2 id="orga49dca9"><span class="section-number-2">9.</span> Core architecture</h2>
+<div class="outline-text-2" id="text-9">
+<p>
 Fifth core is simply some amount of already compiled into machine code
 and linked together modules (entries in other words). In compilation
 process modules is compiled one by one and simply stored on top of
 already existing and growing core. Separately from core is kept
-dictionary, this is special list that contain names of compiled modules,
-variables etc. and they locations in core. Constants use dictionary space
-only. Random word can be removed from dictionary at any time. Currently
-dictionary can contain at most 1000 entries.
-
-
-                       dictionary entry format
-
-offset length  description
-
-0      4        0 &lt; previous entry
-                0 = last
-               -1 = empty
-4      15      module name string
-19     1       entry type
-20     4       entry data
-
-Core headers as linked list of module names make up something like dictionary.
-When some entry address is needed compiler can quickly run through headers
-backwards and find needed entry.
-
-                       Possible module types
-
-type   description     "execute" action
-
-0      data            compile "num" instruction
-                       with address to module
-1      submodule       compile "call" instruction
-                       with address to module
-2      imm. submodule  immediately call to module
-
-
-               Memory map: (average)
-
-<loc>  <size>  <desc>
-0      ~4096   core
-1500000 ~32000 highlevel Fifth boot code
-200000h        core startup messages area
-5200000        end of dynamic memory space
-
-
-
-    <h2>Fifth source format</h2>
-
-
-Fifth uses a different character table and codes than ASCII.
-I call it FSCII (Fifth Standard Code for Information Interchange)
-for example space character is not 32 but 255 instead.
-I plan to use mainly HEX numbers, and create new characters
-to represent numeric values. So typical nemric characters "0123..."
-is treated like ordinary letters.
-
-       FSCII:
-
-DEC    HEX     function
-
-0 - 15 0 - F   HEX numbers
-252    FC      backspace
-253    FD      tabulator (TAB)
-254    FE      carriage return (CR)
-255    FF      space
-
-else           ordinary characters, like in ASCII.
-
-
-    
-    
-    
-    </pre>
+dictionary, this is special list that contain names of compiled
+modules, variables etc. and they locations in core. Constants use
+dictionary space only. Random word can be removed from dictionary at
+any time. Currently dictionary can contain at most 1000 entries.
+</p>
+</div>
+<div id="outline-container-org75e80d5" class="outline-3">
+<h3 id="org75e80d5"><span class="section-number-3">9.1.</span> Dictionary entry format</h3>
+<div class="outline-text-3" id="text-9-1">
+<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
+
+
+<colgroup>
+<col  class="org-right" />
+
+<col  class="org-right" />
+
+<col  class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-right">offset</th>
+<th scope="col" class="org-right">length</th>
+<th scope="col" class="org-left">description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="org-right">0</td>
+<td class="org-right">4</td>
+<td class="org-left">0 &amp;lt; previous entry</td>
+</tr>
+
+<tr>
+<td class="org-right">&#xa0;</td>
+<td class="org-right">&#xa0;</td>
+<td class="org-left">0 = last</td>
+</tr>
+
+<tr>
+<td class="org-right">&#xa0;</td>
+<td class="org-right">&#xa0;</td>
+<td class="org-left">-1 = empty</td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+<td class="org-right">4</td>
+<td class="org-right">15</td>
+<td class="org-left">module name string</td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+<td class="org-right">19</td>
+<td class="org-right">1</td>
+<td class="org-left">entry type</td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+<td class="org-right">20</td>
+<td class="org-right">4</td>
+<td class="org-left">entry data</td>
+</tr>
+</tbody>
+</table>
+
+<p>
+Core headers as linked list of module names make up something like
+dictionary.  When some entry address is needed compiler can quickly
+run through headers backwards and find needed entry.
+</p>
+</div>
+</div>
+<div id="outline-container-org12381ef" class="outline-3">
+<h3 id="org12381ef"><span class="section-number-3">9.2.</span> Possible module types</h3>
+<div class="outline-text-3" id="text-9-2">
+<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
+
+
+<colgroup>
+<col  class="org-right" />
+
+<col  class="org-left" />
+
+<col  class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-right">type</th>
+<th scope="col" class="org-left">description</th>
+<th scope="col" class="org-left">"execute" action</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="org-right">0</td>
+<td class="org-left">data</td>
+<td class="org-left">compile "num" instruction</td>
+</tr>
+
+<tr>
+<td class="org-right">&#xa0;</td>
+<td class="org-left">&#xa0;</td>
+<td class="org-left">with address to module</td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+<td class="org-right">1</td>
+<td class="org-left">submodule</td>
+<td class="org-left">compile "call" instruction</td>
+</tr>
+
+<tr>
+<td class="org-right">&#xa0;</td>
+<td class="org-left">&#xa0;</td>
+<td class="org-left">with address to module</td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+<td class="org-right">2</td>
+<td class="org-left">imm. submodule</td>
+<td class="org-left">immediately call to module</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+<div id="outline-container-org33be039" class="outline-3">
+<h3 id="org33be039"><span class="section-number-3">9.3.</span> Memory map</h3>
+<div class="outline-text-3" id="text-9-3">
+<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
+
+
+<colgroup>
+<col  class="org-right" />
+
+<col  class="org-left" />
+
+<col  class="org-left" />
+</colgroup>
+<thead>
+<tr>
+<th scope="col" class="org-right">location</th>
+<th scope="col" class="org-left">size</th>
+<th scope="col" class="org-left">description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="org-right">0</td>
+<td class="org-left">~4096</td>
+<td class="org-left">core</td>
+</tr>
+
+<tr>
+<td class="org-right">1500000</td>
+<td class="org-left">~32000</td>
+<td class="org-left">highlevel Fifth boot code</td>
+</tr>
+
+<tr>
+<td class="org-right">200000h</td>
+<td class="org-left">&#xa0;</td>
+<td class="org-left">core startup messages area</td>
+</tr>
+
+<tr>
+<td class="org-right">5200000</td>
+<td class="org-left">&#xa0;</td>
+<td class="org-left">end of dynamic memory space</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+</div>
+<div id="outline-container-org81fd544" class="outline-2">
+<h2 id="org81fd544"><span class="section-number-2">10.</span> Dynamically loadable modules</h2>
+<div class="outline-text-2" id="text-10">
+</div>
+<div id="outline-container-org79d1c84" class="outline-3">
+<h3 id="org79d1c84"><span class="section-number-3">10.1.</span> Keyboard driver</h3>
+<div class="outline-text-3" id="text-10-1">
+<p class="verse">
+<br />
+KBD_@           ( &#x2013; code ) get scancodes for pressed keys from keyboard.<br />
+KBD_down?       ( key &#x2013; result ) check is key with specified scancode<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;currently pressed down.<br />
+KBD_SC2FSCII    ( code &#x2013; FSCII ) convert key scancode into FSCII code,<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;or in FSK (Fifth standard keycode).<br />
+KBD_F@          ( &#x2013; FSCII ) read pressed key FSCII or FSK, returns -1 if no<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;keys are pressed.<br />
+KBD_FW@         ( &#x2013; FSCII ) read pressed key FSCII or FSK, if no keys is<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;are pressed then waits until there is.<br />
+<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;FSK<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#x2014;<br />
+In HEX.<br />
+<br />
+FC      backspace<br />
+FD      TAB<br />
+FE      enter<br />
+FF      space<br />
+<br />
+400     ESC<br />
+401 &#x2026; F1 &#x2026;<br />
+410     up<br />
+411     right<br />
+412     down<br />
+413     left<br />
+414     INS<br />
+415     DEL<br />
+416     home<br />
+417     end<br />
+418     PG/UP<br />
+419     PG/DN<br />
+</p>
+</div>
+</div>
+<div id="outline-container-org99b4378" class="outline-3">
+<h3 id="org99b4378"><span class="section-number-3">10.2.</span> Mouse driver</h3>
+<div class="outline-text-3" id="text-10-2">
+<p class="verse">
+mousex  var     Mouse x coordinate.<br />
+mousey  var     Mouse y coordinate.<br />
+mousekeyl var   Mouse left key.<br />
+mousekeym var   Mouse middle key.<br />
+mousekeyr var   Mouse right key.<br />
+mousec  var     Display current mouse coordinates in top left part of screen,<br />
+&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if true. (good for debugging)<br />
+mousepointer var  Image buffer, holding current mouse pointer.<br />
+mouseadd        ( ModuleAddr x1 x2 y1 y2 &#x2013; ) Add specified area on screen,<br />
+&#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 />
+&#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 />
+mousebe var     Amount of buffer elements.<br />
+mousedo         ( &#x2013; ) Updates mouse coordinates and keys. Parse mouse<br />
+&#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 />
+</p>
+</div>
+</div>
+<div id="outline-container-org0aa9e1f" class="outline-3">
+<h3 id="org0aa9e1f"><span class="section-number-3">10.3.</span> 2D graphic library</h3>
+<div class="outline-text-3" id="text-10-3">
+<dl class="org-dl">
+<dt>lineh ( color len x y imgbuf &#x2013; )</dt><dd>draws horisontal line from X,Y
+coordinates to right, with specified length.</dd>
+
+<dt>linev ( color len x y imgbuf &#x2013; )</dt><dd>draws vertical line down, from
+coordinates X,Y, with specified length.</dd>
+
+<dt>box ( color x2 x1 y2 y1 imgbuf &#x2013; )</dt><dd><p>
+draws rectangular box. x2
+bust be &gt;= x1, y2 must be &gt;= y1.
+</p>
+
+<pre class="example" id="orgfea073c">
+x1,y1-----------+
+  |             |
+  |             |
+  +-----------x2,y2
+</pre></dd>
+
+<dt>flipv ( imgbuf &#x2013; )</dt><dd>flip image vertically.</dd>
+
+<dt>imgcoltrans ( ImgBuf Color ToColor &#x2013; )</dt><dd>Translate all pixels in
+specified image with "Color" into "ToColor".</dd>
+
+<dt>imgfill ( color x y imgbuf &#x2013; )</dt><dd>Fill image region starting at
+location X &amp; Y with specified color.</dd>
+</dl>
+</div>
+</div>
+
+<div id="outline-container-orgff6cdef" class="outline-3">
+<h3 id="orgff6cdef"><span class="section-number-3">10.4.</span> Trigonometry functions</h3>
+<div class="outline-text-3" id="text-10-4">
+</div>
+<div id="outline-container-org868f7c6" class="outline-4">
+<h4 id="org868f7c6"><span class="section-number-4">10.4.1.</span> sin ( a &#x2013; result )</h4>
+<div class="outline-text-4" id="text-10-4-1">
+<p>
+Return sinus from given angle "a", 360ø is 2000. So 1000 represents
+180ø angle.  Result will be in range -10'000 to 10'000, instead of ñ1.
+</p>
+</div>
+</div>
+<div id="outline-container-orgc3f161e" class="outline-4">
+<h4 id="orgc3f161e"><span class="section-number-4">10.4.2.</span> cos ( a &#x2013; result )</h4>
+<div class="outline-text-4" id="text-10-4-2">
+<p>
+Return cosinus from given angle.  Parameters are like in <a href="#org868f7c6">sin</a> function.
+</p>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="postamble" class="status">
+<p class="author">Author: Svjatoslav Agejenko</p>
+<p class="date">Created: 2023-09-19 Tue 18:07</p>
+<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
+</div>
 </body>
-</html>
\ No newline at end of file
+</html>