cadd753a94c9a80d3f960e015999c8a2787aff4f
[fifth.git] / doc / index.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
5 <head>
6 <!-- 2023-09-18 Mon 01:47 -->
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8 <meta name="viewport" content="width=device-width, initial-scale=1" />
9 <title>Fifth - virtual machine, operating system, programming language</title>
10 <meta name="author" content="Svjatoslav Agejenko" />
11 <meta name="generator" content="Org Mode" />
12 <style>
13   #content { max-width: 60em; margin: auto; }
14   .title  { text-align: center;
15              margin-bottom: .2em; }
16   .subtitle { text-align: center;
17               font-size: medium;
18               font-weight: bold;
19               margin-top:0; }
20   .todo   { font-family: monospace; color: red; }
21   .done   { font-family: monospace; color: green; }
22   .priority { font-family: monospace; color: orange; }
23   .tag    { background-color: #eee; font-family: monospace;
24             padding: 2px; font-size: 80%; font-weight: normal; }
25   .timestamp { color: #bebebe; }
26   .timestamp-kwd { color: #5f9ea0; }
27   .org-right  { margin-left: auto; margin-right: 0px;  text-align: right; }
28   .org-left   { margin-left: 0px;  margin-right: auto; text-align: left; }
29   .org-center { margin-left: auto; margin-right: auto; text-align: center; }
30   .underline { text-decoration: underline; }
31   #postamble p, #preamble p { font-size: 90%; margin: .2em; }
32   p.verse { margin-left: 3%; }
33   pre {
34     border: 1px solid #e6e6e6;
35     border-radius: 3px;
36     background-color: #f2f2f2;
37     padding: 8pt;
38     font-family: monospace;
39     overflow: auto;
40     margin: 1.2em;
41   }
42   pre.src {
43     position: relative;
44     overflow: auto;
45   }
46   pre.src:before {
47     display: none;
48     position: absolute;
49     top: -8px;
50     right: 12px;
51     padding: 3px;
52     color: #555;
53     background-color: #f2f2f299;
54   }
55   pre.src:hover:before { display: inline; margin-top: 14px;}
56   /* Languages per Org manual */
57   pre.src-asymptote:before { content: 'Asymptote'; }
58   pre.src-awk:before { content: 'Awk'; }
59   pre.src-authinfo::before { content: 'Authinfo'; }
60   pre.src-C:before { content: 'C'; }
61   /* pre.src-C++ doesn't work in CSS */
62   pre.src-clojure:before { content: 'Clojure'; }
63   pre.src-css:before { content: 'CSS'; }
64   pre.src-D:before { content: 'D'; }
65   pre.src-ditaa:before { content: 'ditaa'; }
66   pre.src-dot:before { content: 'Graphviz'; }
67   pre.src-calc:before { content: 'Emacs Calc'; }
68   pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
69   pre.src-fortran:before { content: 'Fortran'; }
70   pre.src-gnuplot:before { content: 'gnuplot'; }
71   pre.src-haskell:before { content: 'Haskell'; }
72   pre.src-hledger:before { content: 'hledger'; }
73   pre.src-java:before { content: 'Java'; }
74   pre.src-js:before { content: 'Javascript'; }
75   pre.src-latex:before { content: 'LaTeX'; }
76   pre.src-ledger:before { content: 'Ledger'; }
77   pre.src-lisp:before { content: 'Lisp'; }
78   pre.src-lilypond:before { content: 'Lilypond'; }
79   pre.src-lua:before { content: 'Lua'; }
80   pre.src-matlab:before { content: 'MATLAB'; }
81   pre.src-mscgen:before { content: 'Mscgen'; }
82   pre.src-ocaml:before { content: 'Objective Caml'; }
83   pre.src-octave:before { content: 'Octave'; }
84   pre.src-org:before { content: 'Org mode'; }
85   pre.src-oz:before { content: 'OZ'; }
86   pre.src-plantuml:before { content: 'Plantuml'; }
87   pre.src-processing:before { content: 'Processing.js'; }
88   pre.src-python:before { content: 'Python'; }
89   pre.src-R:before { content: 'R'; }
90   pre.src-ruby:before { content: 'Ruby'; }
91   pre.src-sass:before { content: 'Sass'; }
92   pre.src-scheme:before { content: 'Scheme'; }
93   pre.src-screen:before { content: 'Gnu Screen'; }
94   pre.src-sed:before { content: 'Sed'; }
95   pre.src-sh:before { content: 'shell'; }
96   pre.src-sql:before { content: 'SQL'; }
97   pre.src-sqlite:before { content: 'SQLite'; }
98   /* additional languages in org.el's org-babel-load-languages alist */
99   pre.src-forth:before { content: 'Forth'; }
100   pre.src-io:before { content: 'IO'; }
101   pre.src-J:before { content: 'J'; }
102   pre.src-makefile:before { content: 'Makefile'; }
103   pre.src-maxima:before { content: 'Maxima'; }
104   pre.src-perl:before { content: 'Perl'; }
105   pre.src-picolisp:before { content: 'Pico Lisp'; }
106   pre.src-scala:before { content: 'Scala'; }
107   pre.src-shell:before { content: 'Shell Script'; }
108   pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
109   /* additional language identifiers per "defun org-babel-execute"
110        in ob-*.el */
111   pre.src-cpp:before  { content: 'C++'; }
112   pre.src-abc:before  { content: 'ABC'; }
113   pre.src-coq:before  { content: 'Coq'; }
114   pre.src-groovy:before  { content: 'Groovy'; }
115   /* additional language identifiers from org-babel-shell-names in
116      ob-shell.el: ob-shell is the only babel language using a lambda to put
117      the execution function name together. */
118   pre.src-bash:before  { content: 'bash'; }
119   pre.src-csh:before  { content: 'csh'; }
120   pre.src-ash:before  { content: 'ash'; }
121   pre.src-dash:before  { content: 'dash'; }
122   pre.src-ksh:before  { content: 'ksh'; }
123   pre.src-mksh:before  { content: 'mksh'; }
124   pre.src-posh:before  { content: 'posh'; }
125   /* Additional Emacs modes also supported by the LaTeX listings package */
126   pre.src-ada:before { content: 'Ada'; }
127   pre.src-asm:before { content: 'Assembler'; }
128   pre.src-caml:before { content: 'Caml'; }
129   pre.src-delphi:before { content: 'Delphi'; }
130   pre.src-html:before { content: 'HTML'; }
131   pre.src-idl:before { content: 'IDL'; }
132   pre.src-mercury:before { content: 'Mercury'; }
133   pre.src-metapost:before { content: 'MetaPost'; }
134   pre.src-modula-2:before { content: 'Modula-2'; }
135   pre.src-pascal:before { content: 'Pascal'; }
136   pre.src-ps:before { content: 'PostScript'; }
137   pre.src-prolog:before { content: 'Prolog'; }
138   pre.src-simula:before { content: 'Simula'; }
139   pre.src-tcl:before { content: 'tcl'; }
140   pre.src-tex:before { content: 'TeX'; }
141   pre.src-plain-tex:before { content: 'Plain TeX'; }
142   pre.src-verilog:before { content: 'Verilog'; }
143   pre.src-vhdl:before { content: 'VHDL'; }
144   pre.src-xml:before { content: 'XML'; }
145   pre.src-nxml:before { content: 'XML'; }
146   /* add a generic configuration mode; LaTeX export needs an additional
147      (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
148   pre.src-conf:before { content: 'Configuration File'; }
149
150   table { border-collapse:collapse; }
151   caption.t-above { caption-side: top; }
152   caption.t-bottom { caption-side: bottom; }
153   td, th { vertical-align:top;  }
154   th.org-right  { text-align: center;  }
155   th.org-left   { text-align: center;   }
156   th.org-center { text-align: center; }
157   td.org-right  { text-align: right;  }
158   td.org-left   { text-align: left;   }
159   td.org-center { text-align: center; }
160   dt { font-weight: bold; }
161   .footpara { display: inline; }
162   .footdef  { margin-bottom: 1em; }
163   .figure { padding: 1em; }
164   .figure p { text-align: center; }
165   .equation-container {
166     display: table;
167     text-align: center;
168     width: 100%;
169   }
170   .equation {
171     vertical-align: middle;
172   }
173   .equation-label {
174     display: table-cell;
175     text-align: right;
176     vertical-align: middle;
177   }
178   .inlinetask {
179     padding: 10px;
180     border: 2px solid gray;
181     margin: 10px;
182     background: #ffffcc;
183   }
184   #org-div-home-and-up
185    { text-align: right; font-size: 70%; white-space: nowrap; }
186   textarea { overflow-x: auto; }
187   .linenr { font-size: smaller }
188   .code-highlighted { background-color: #ffff00; }
189   .org-info-js_info-navigation { border-style: none; }
190   #org-info-js_console-label
191     { font-size: 10px; font-weight: bold; white-space: nowrap; }
192   .org-info-js_search-highlight
193     { background-color: #ffff00; color: #000000; font-weight: bold; }
194   .org-svg { }
195 </style>
196 <link rel="stylesheet" type="text/css" href="https://thomasf.github.io/solarized-css/solarized-dark.min.css" />
197 <script type="text/x-mathjax-config">
198     MathJax.Hub.Config({
199         displayAlign: "center",
200         displayIndent: "0em",
201
202         "HTML-CSS": { scale: 100,
203                         linebreaks: { automatic: "false" },
204                         webFont: "TeX"
205                        },
206         SVG: {scale: 100,
207               linebreaks: { automatic: "false" },
208               font: "TeX"},
209         NativeMML: {scale: 100},
210         TeX: { equationNumbers: {autoNumber: "AMS"},
211                MultLineWidth: "85%",
212                TagSide: "right",
213                TagIndent: ".8em"
214              }
215 });
216 </script>
217 <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
218 </head>
219 <body>
220 <div id="content" class="content">
221 <h1 class="title">Fifth - virtual machine, operating system, programming language</h1>
222 <div id="table-of-contents" role="doc-toc">
223 <h2>Table of Contents</h2>
224 <div id="text-table-of-contents" role="doc-toc">
225 <ul>
226 <li><a href="#org48b7220">1. General</a>
227 <ul>
228 <li><a href="#org22b59dd">1.1. Source code</a></li>
229 </ul>
230 </li>
231 <li><a href="#org20b6805">2. !Project deprecated!</a></li>
232 <li><a href="#orgc67a478">3. Introduction</a>
233 <ul>
234 <li><a href="#org8504a11">3.1. screenshots</a></li>
235 </ul>
236 </li>
237 <li><a href="#org0e56472">4. Installation</a></li>
238 <li><a href="#orgf9fdcb5">5. Fifth distribution directory tree description</a></li>
239 <li><a href="#org415759c">6. Requirements</a>
240 <ul>
241 <li><a href="#org44f8cdd">6.1. Software</a></li>
242 <li><a href="#orgf4e46f6">6.2. Hardware</a></li>
243 <li><a href="#org00ed0b8">6.3. Human</a></li>
244 </ul>
245 </li>
246 <li><a href="#orgc60d938">7. Numbers representation within Fifth</a></li>
247 <li><a href="#orgd7d6a8e">8. Disk file map, and it's data structures</a>
248 <ul>
249 <li><a href="#org2db1035">8.1. Disk allocation</a></li>
250 <li><a href="#org776d15e">8.2. FAT entry format:</a></li>
251 <li><a href="#org03a8280">8.3. File entry format</a></li>
252 </ul>
253 </li>
254 <li><a href="#orgbfdae7b">9. Core architecture</a>
255 <ul>
256 <li><a href="#org77ca4ba">9.1. Dictionary entry format</a></li>
257 <li><a href="#orga2a22a5">9.2. Possible module types</a></li>
258 <li><a href="#org6b34748">9.3. Memory map</a></li>
259 </ul>
260 </li>
261 <li><a href="#org835c31e">10. Dynamically loadable modules</a>
262 <ul>
263 <li><a href="#orgd31a968">10.1. Keyboard driver</a></li>
264 <li><a href="#orgc5f8a76">10.2. Mouse driver</a></li>
265 <li><a href="#org64da03a">10.3. 2D graphic library</a></li>
266 <li><a href="#org203890d">10.4. Trigonometry functions</a>
267 <ul>
268 <li><a href="#org618a2c2">10.4.1. sin ( a &#x2013; result )</a></li>
269 <li><a href="#org0f995cf">10.4.2. cos ( a &#x2013; result )</a></li>
270 </ul>
271 </li>
272 </ul>
273 </li>
274 </ul>
275 </div>
276 </div>
277
278 <div id="outline-container-org48b7220" class="outline-2">
279 <h2 id="org48b7220"><span class="section-number-2">1.</span> General</h2>
280 <div class="outline-text-2" id="text-1">
281 <ul class="org-ul">
282 <li>This program is free software: released under Creative Commons Zero
283 (CC0) license</li>
284
285 <li>Program author:
286 <ul class="org-ul">
287 <li>Svjatoslav Agejenko</li>
288 <li>Homepage: <a href="https://svjatoslav.eu">https://svjatoslav.eu</a></li>
289 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a></li>
290 </ul></li>
291
292 <li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a></li>
293 </ul>
294 </div>
295
296 <div id="outline-container-org22b59dd" class="outline-3">
297 <h3 id="org22b59dd"><span class="section-number-3">1.1.</span> Source code</h3>
298 <div class="outline-text-3" id="text-1-1">
299 <ul class="org-ul">
300 <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>
301
302 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=summary">Browse Git repository online</a></li>
303
304 <li><p>
305 Clone Git repository using command:
306 </p>
307 <pre class="example">
308 git clone https://www2.svjatoslav.eu/git/fifth.git
309 </pre></li>
310 </ul>
311 </div>
312 </div>
313 </div>
314
315 <div id="outline-container-org20b6805" class="outline-2">
316 <h2 id="org20b6805"><span class="section-number-2">2.</span> !Project deprecated!</h2>
317 <div class="outline-text-2" id="text-2">
318 <p>
319 Current implementation does not support object oriented
320 programming. While working on Fifth I got lots of cool new ideas that
321 require reimplementation of everything.
322 </p>
323
324 <p>
325 Currently I try to implement those new ideas in the project called
326 <a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
327 </p>
328
329 <p>
330 System is built many years ago when I was still using DOS as a primary
331 operating system.
332 </p>
333 </div>
334 </div>
335 <div id="outline-container-orgc67a478" class="outline-2">
336 <h2 id="orgc67a478"><span class="section-number-2">3.</span> Introduction</h2>
337 <div class="outline-text-2" id="text-3">
338 <p>
339 Fifth is a combination of:
340 </p>
341 <ul class="org-ul">
342 <li><a href="language.html#ID-da7fff9b-0b67-4843-828a-52a404d7f401">Programming language</a> (inspired by Forth).</li>
343 <li>Operating system.</li>
344 <li><a href="virtual machine.html#ID-9b251eb9-aff6-4025-94bf-25e89e26d54a">Virtual machine</a> with custom instruction set.</li>
345 <li><a href="5TH_ET.txt">Example Fifth source file - text editor</a></li>
346 </ul>
347 </div>
348 <div id="outline-container-org8504a11" class="outline-3">
349 <h3 id="org8504a11"><span class="section-number-3">3.1.</span> screenshots</h3>
350 <div class="outline-text-3" id="text-3-1">
351
352 <div id="org9178e56" class="figure">
353 <p><img src="screenshots/start.png" alt="start.png" />
354 </p>
355 </div>
356
357 <p>
358 Startup screen diplaying Fifth logo and full file list.
359 </p>
360
361
362 <div id="orgf022552" class="figure">
363 <p><img src="screenshots/dictionary.png" alt="dictionary.png" />
364 </p>
365 </div>
366
367 <p>
368 Sample words defined. Most of the words are commands that can be
369 executed interactively from command line or from file. When executed
370 they can be selectively compiled or interpreted.
371 </p>
372
373
374
375 <div id="org415fab1" class="figure">
376 <p><img src="screenshots/text editor.png" alt="text editor.png" />
377 </p>
378 </div>
379
380 <p>
381 Built in text editor.
382 </p>
383 </div>
384 </div>
385 </div>
386
387 <div id="outline-container-org0e56472" class="outline-2">
388 <h2 id="org0e56472"><span class="section-number-2">4.</span> Installation</h2>
389 <div class="outline-text-2" id="text-4">
390 <p>
391 Just unpack all files, witout altering original directory structure,
392 somewhere in your hard disk. For example: C:\MISC\FIFTH\&#x2026;.  To run
393 fifth you need minimally just 2 files.  emulator itself ( EMULATOR.EXE
394 or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
395 </p>
396
397 <p>
398 Read more about <a href="#orgf9fdcb5">Fifth distribution directory tree description</a>.
399 </p>
400 </div>
401 </div>
402
403 <div id="outline-container-orgf9fdcb5" class="outline-2">
404 <h2 id="orgf9fdcb5"><span class="section-number-2">5.</span> Fifth distribution directory tree description</h2>
405 <div class="outline-text-2" id="text-5">
406 <p>
407 After downloading and unpacking the ZIP file you shoud get directory
408 tree similar to this:
409 </p>
410
411 <p class="verse">
412 <b>DOC</b>                   - Fifth documentation<br />
413 &#xa0;&#xa0;<b>commands</b>            - documentation on Fifth built-in commands<br />
414 &#xa0;&#xa0;<b>modules</b>             - documentation on additional commands, realized as loadable modules<br />
415 &#xa0;&#xa0;<b>shots</b>               - Fifth screenshots<br />
416 <br />
417 <b>imageFile</b>             - files contained within 'disk.raw', just an extracted form.<br />
418 <br />
419 <b>source</b>                - source files<br />
420 &#xa0;&#xa0;<b>emulator</b>            - emulator source<br />
421 &#xa0;&#xa0;<b>util</b>                - utilites<br />
422 <br />
423 <b>disk.raw</b>                - Virtual disk file, has filesystem inside.<br />
424 <b>emulator.com</b>            - main executable.<br />
425 </p>
426 </div>
427 </div>
428
429 <div id="outline-container-org415759c" class="outline-2">
430 <h2 id="org415759c"><span class="section-number-2">6.</span> Requirements</h2>
431 <div class="outline-text-2" id="text-6">
432 </div>
433 <div id="outline-container-org44f8cdd" class="outline-3">
434 <h3 id="org44f8cdd"><span class="section-number-3">6.1.</span> Software</h3>
435 <div class="outline-text-3" id="text-6-1">
436 <ul class="org-ul">
437 <li>MS-DOS 6.22, with HIMEM.SYS loaded.</li>
438 <li>Mouse driver if you have a mouse.</li>
439 <li>Does work only when CPU is in real mode.</li>
440 <li>To recompile ASM sources I used FASM (Flat Assembler).</li>
441 <li>I ran QBasic utilities on QB 4.5 .</li>
442 <li>VESA support by BIOS, or external driver (UNIVBE).</li>
443 </ul>
444 </div>
445 </div>
446 <div id="outline-container-orgf4e46f6" class="outline-3">
447 <h3 id="orgf4e46f6"><span class="section-number-3">6.2.</span> Hardware</h3>
448 <div class="outline-text-3" id="text-6-2">
449 <ul class="org-ul">
450 <li>Minimum CPU 386.</li>
451 <li>64 KB free RAM below 640KB,</li>
452 <li>2 MB of free XMS.</li>
453 <li>VESA compatible video card.</li>
454 </ul>
455 </div>
456 </div>
457 <div id="outline-container-org00ed0b8" class="outline-3">
458 <h3 id="org00ed0b8"><span class="section-number-3">6.3.</span> Human</h3>
459 <div class="outline-text-3" id="text-6-3">
460 <ul class="org-ul">
461 <li>Beginner level Forth knowledge is recommended.</li>
462 <li>Lots of enthusiasm.</li>
463 </ul>
464 </div>
465 </div>
466 </div>
467 <div id="outline-container-orgc60d938" class="outline-2">
468 <h2 id="orgc60d938"><span class="section-number-2">7.</span> Numbers representation within Fifth</h2>
469 <div class="outline-text-2" id="text-7">
470 <p>
471 Because we are in full experimentation mode here (no regard for
472 compatibility whatsoever), why not to try also alternative number
473 representation ?
474 </p>
475
476 <p>
477 Here alternative hexadecimal number representation format is devised:
478 </p>
479
480
481 <div id="org806c6d6" class="figure">
482 <p><a href="numbers.png"><img src="numbers.png" alt="numbers.png" /></a>
483 </p>
484 </div>
485
486 <p>
487 Essentially square is split into 4 triangles. Each triangle represents
488 one bit.
489 </p>
490
491 <p>
492 Fifth uses this hexadecimal format as primary throughout entire
493 system.
494 </p>
495
496 <p>
497 See also: <a href="https://en.wikipedia.org/wiki/Bibi-binary">Bibi-binary</a>.
498 </p>
499 </div>
500 </div>
501
502 <div id="outline-container-orgd7d6a8e" class="outline-2">
503 <h2 id="orgd7d6a8e"><span class="section-number-2">8.</span> Disk file map, and it's data structures</h2>
504 <div class="outline-text-2" id="text-8">
505 <p>
506 Core and high-level boot code is stored outside of the filesystem to
507 allow easy access to it, at early booting time, when filesystem is not
508 yet initialized.
509 </p>
510 </div>
511 <div id="outline-container-org2db1035" class="outline-3">
512 <h3 id="org2db1035"><span class="section-number-3">8.1.</span> Disk allocation</h3>
513 <div class="outline-text-3" id="text-8-1">
514 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
515
516
517 <colgroup>
518 <col  class="org-left" />
519
520 <col  class="org-left" />
521
522 <col  class="org-left" />
523 </colgroup>
524 <thead>
525 <tr>
526 <th scope="col" class="org-left">offset</th>
527 <th scope="col" class="org-left">length</th>
528 <th scope="col" class="org-left">description</th>
529 </tr>
530 </thead>
531 <tbody>
532 <tr>
533 <td class="org-left">0</td>
534 <td class="org-left">~4 Kb</td>
535 <td class="org-left">Fifth core</td>
536 </tr>
537
538 <tr>
539 <td class="org-left">4 Kb</td>
540 <td class="org-left">~32 Kb</td>
541 <td class="org-left">high-level boot code</td>
542 </tr>
543
544 <tr>
545 <td class="org-left">37 Kb</td>
546 <td class="org-left">~65 Kb</td>
547 <td class="org-left">FAT</td>
548 </tr>
549
550 <tr>
551 <td class="org-left">101 Kb</td>
552 <td class="org-left">~16 MB</td>
553 <td class="org-left">filesystem data area</td>
554 </tr>
555 </tbody>
556 </table>
557 </div>
558 </div>
559 <div id="outline-container-org776d15e" class="outline-3">
560 <h3 id="org776d15e"><span class="section-number-3">8.2.</span> FAT entry format:</h3>
561 <div class="outline-text-3" id="text-8-2">
562 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
563
564
565 <colgroup>
566 <col  class="org-right" />
567
568 <col  class="org-left" />
569 </colgroup>
570 <thead>
571 <tr>
572 <th scope="col" class="org-right">code</th>
573 <th scope="col" class="org-left">meaning</th>
574 </tr>
575 </thead>
576 <tbody>
577 <tr>
578 <td class="org-right">-2</td>
579 <td class="org-left">last sector</td>
580 </tr>
581
582 <tr>
583 <td class="org-right">-1</td>
584 <td class="org-left">empty sector</td>
585 </tr>
586
587 <tr>
588 <td class="org-right">0 --</td>
589 <td class="org-left">.. pointer to next block</td>
590 </tr>
591 </tbody>
592 </table>
593 </div>
594 </div>
595 <div id="outline-container-org03a8280" class="outline-3">
596 <h3 id="org03a8280"><span class="section-number-3">8.3.</span> File entry format</h3>
597 <div class="outline-text-3" id="text-8-3">
598 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
599
600
601 <colgroup>
602 <col  class="org-right" />
603
604 <col  class="org-right" />
605
606 <col  class="org-left" />
607 </colgroup>
608 <thead>
609 <tr>
610 <th scope="col" class="org-right">offset</th>
611 <th scope="col" class="org-right">length</th>
612 <th scope="col" class="org-left">description</th>
613 </tr>
614 </thead>
615 <tbody>
616 <tr>
617 <td class="org-right">0</td>
618 <td class="org-right">4</td>
619 <td class="org-left">extension</td>
620 </tr>
621
622 <tr>
623 <td class="org-right">4</td>
624 <td class="org-right">16</td>
625 <td class="org-left">name</td>
626 </tr>
627
628 <tr>
629 <td class="org-right">20</td>
630 <td class="org-right">4</td>
631 <td class="org-left">entry point</td>
632 </tr>
633
634 <tr>
635 <td class="org-right">24</td>
636 <td class="org-right">4</td>
637 <td class="org-left">size</td>
638 </tr>
639
640 <tr>
641 <td class="org-right">28</td>
642 <td class="org-right">4</td>
643 <td class="org-left">last modification time</td>
644 </tr>
645 </tbody>
646 </table>
647 </div>
648 </div>
649 </div>
650 <div id="outline-container-orgbfdae7b" class="outline-2">
651 <h2 id="orgbfdae7b"><span class="section-number-2">9.</span> Core architecture</h2>
652 <div class="outline-text-2" id="text-9">
653 <p>
654 Fifth core is simply some amount of already compiled into machine code
655 and linked together modules (entries in other words). In compilation
656 process modules is compiled one by one and simply stored on top of
657 already existing and growing core. Separately from core is kept
658 dictionary, this is special list that contain names of compiled
659 modules, variables etc. and they locations in core. Constants use
660 dictionary space only. Random word can be removed from dictionary at
661 any time. Currently dictionary can contain at most 1000 entries.
662 </p>
663 </div>
664 <div id="outline-container-org77ca4ba" class="outline-3">
665 <h3 id="org77ca4ba"><span class="section-number-3">9.1.</span> Dictionary entry format</h3>
666 <div class="outline-text-3" id="text-9-1">
667 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
668
669
670 <colgroup>
671 <col  class="org-right" />
672
673 <col  class="org-right" />
674
675 <col  class="org-left" />
676 </colgroup>
677 <thead>
678 <tr>
679 <th scope="col" class="org-right">offset</th>
680 <th scope="col" class="org-right">length</th>
681 <th scope="col" class="org-left">description</th>
682 </tr>
683 </thead>
684 <tbody>
685 <tr>
686 <td class="org-right">0</td>
687 <td class="org-right">4</td>
688 <td class="org-left">0 &amp;lt; previous entry</td>
689 </tr>
690
691 <tr>
692 <td class="org-right">&#xa0;</td>
693 <td class="org-right">&#xa0;</td>
694 <td class="org-left">0 = last</td>
695 </tr>
696
697 <tr>
698 <td class="org-right">&#xa0;</td>
699 <td class="org-right">&#xa0;</td>
700 <td class="org-left">-1 = empty</td>
701 </tr>
702 </tbody>
703 <tbody>
704 <tr>
705 <td class="org-right">4</td>
706 <td class="org-right">15</td>
707 <td class="org-left">module name string</td>
708 </tr>
709 </tbody>
710 <tbody>
711 <tr>
712 <td class="org-right">19</td>
713 <td class="org-right">1</td>
714 <td class="org-left">entry type</td>
715 </tr>
716 </tbody>
717 <tbody>
718 <tr>
719 <td class="org-right">20</td>
720 <td class="org-right">4</td>
721 <td class="org-left">entry data</td>
722 </tr>
723 </tbody>
724 </table>
725
726 <p>
727 Core headers as linked list of module names make up something like
728 dictionary.  When some entry address is needed compiler can quickly
729 run through headers backwards and find needed entry.
730 </p>
731 </div>
732 </div>
733 <div id="outline-container-orga2a22a5" class="outline-3">
734 <h3 id="orga2a22a5"><span class="section-number-3">9.2.</span> Possible module types</h3>
735 <div class="outline-text-3" id="text-9-2">
736 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
737
738
739 <colgroup>
740 <col  class="org-right" />
741
742 <col  class="org-left" />
743
744 <col  class="org-left" />
745 </colgroup>
746 <thead>
747 <tr>
748 <th scope="col" class="org-right">type</th>
749 <th scope="col" class="org-left">description</th>
750 <th scope="col" class="org-left">"execute" action</th>
751 </tr>
752 </thead>
753 <tbody>
754 <tr>
755 <td class="org-right">0</td>
756 <td class="org-left">data</td>
757 <td class="org-left">compile "num" instruction</td>
758 </tr>
759
760 <tr>
761 <td class="org-right">&#xa0;</td>
762 <td class="org-left">&#xa0;</td>
763 <td class="org-left">with address to module</td>
764 </tr>
765 </tbody>
766 <tbody>
767 <tr>
768 <td class="org-right">1</td>
769 <td class="org-left">submodule</td>
770 <td class="org-left">compile "call" instruction</td>
771 </tr>
772
773 <tr>
774 <td class="org-right">&#xa0;</td>
775 <td class="org-left">&#xa0;</td>
776 <td class="org-left">with address to module</td>
777 </tr>
778 </tbody>
779 <tbody>
780 <tr>
781 <td class="org-right">2</td>
782 <td class="org-left">imm. submodule</td>
783 <td class="org-left">immediately call to module</td>
784 </tr>
785 </tbody>
786 </table>
787 </div>
788 </div>
789 <div id="outline-container-org6b34748" class="outline-3">
790 <h3 id="org6b34748"><span class="section-number-3">9.3.</span> Memory map</h3>
791 <div class="outline-text-3" id="text-9-3">
792 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
793
794
795 <colgroup>
796 <col  class="org-right" />
797
798 <col  class="org-left" />
799
800 <col  class="org-left" />
801 </colgroup>
802 <thead>
803 <tr>
804 <th scope="col" class="org-right">location</th>
805 <th scope="col" class="org-left">size</th>
806 <th scope="col" class="org-left">description</th>
807 </tr>
808 </thead>
809 <tbody>
810 <tr>
811 <td class="org-right">0</td>
812 <td class="org-left">~4096</td>
813 <td class="org-left">core</td>
814 </tr>
815
816 <tr>
817 <td class="org-right">1500000</td>
818 <td class="org-left">~32000</td>
819 <td class="org-left">highlevel Fifth boot code</td>
820 </tr>
821
822 <tr>
823 <td class="org-right">200000h</td>
824 <td class="org-left">&#xa0;</td>
825 <td class="org-left">core startup messages area</td>
826 </tr>
827
828 <tr>
829 <td class="org-right">5200000</td>
830 <td class="org-left">&#xa0;</td>
831 <td class="org-left">end of dynamic memory space</td>
832 </tr>
833 </tbody>
834 </table>
835 </div>
836 </div>
837 </div>
838 <div id="outline-container-org835c31e" class="outline-2">
839 <h2 id="org835c31e"><span class="section-number-2">10.</span> Dynamically loadable modules</h2>
840 <div class="outline-text-2" id="text-10">
841 </div>
842 <div id="outline-container-orgd31a968" class="outline-3">
843 <h3 id="orgd31a968"><span class="section-number-3">10.1.</span> Keyboard driver</h3>
844 <div class="outline-text-3" id="text-10-1">
845 <p class="verse">
846 <br />
847 KBD_@           ( &#x2013; code ) get scancodes for pressed keys from keyboard.<br />
848 KBD_down?       ( key &#x2013; result ) check is key with specified scancode<br />
849 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;currently pressed down.<br />
850 KBD_SC2FSCII    ( code &#x2013; FSCII ) convert key scancode into FSCII code,<br />
851 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;or in FSK (Fifth standard keycode).<br />
852 KBD_F@          ( &#x2013; FSCII ) read pressed key FSCII or FSK, returns -1 if no<br />
853 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;keys are pressed.<br />
854 KBD_FW@         ( &#x2013; FSCII ) read pressed key FSCII or FSK, if no keys is<br />
855 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;are pressed then waits until there is.<br />
856 <br />
857 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;FSK<br />
858 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#x2014;<br />
859 In HEX.<br />
860 <br />
861 FC      backspace<br />
862 FD      TAB<br />
863 FE      enter<br />
864 FF      space<br />
865 <br />
866 400     ESC<br />
867 401 &#x2026; F1 &#x2026;<br />
868 410     up<br />
869 411     right<br />
870 412     down<br />
871 413     left<br />
872 414     INS<br />
873 415     DEL<br />
874 416     home<br />
875 417     end<br />
876 418     PG/UP<br />
877 419     PG/DN<br />
878 </p>
879 </div>
880 </div>
881 <div id="outline-container-orgc5f8a76" class="outline-3">
882 <h3 id="orgc5f8a76"><span class="section-number-3">10.2.</span> Mouse driver</h3>
883 <div class="outline-text-3" id="text-10-2">
884 <p class="verse">
885 mousex  var     Mouse x coordinate.<br />
886 mousey  var     Mouse y coordinate.<br />
887 mousekeyl var   Mouse left key.<br />
888 mousekeym var   Mouse middle key.<br />
889 mousekeyr var   Mouse right key.<br />
890 mousec  var     Display current mouse coordinates in top left part of screen,<br />
891 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if true. (good for debugging)<br />
892 mousepointer var  Image buffer, holding current mouse pointer.<br />
893 mouseadd        ( ModuleAddr x1 x2 y1 y2 &#x2013; ) Add specified area on screen,<br />
894 &#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 />
895 &#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 />
896 mousebe var     Amount of buffer elements.<br />
897 mousedo         ( &#x2013; ) Updates mouse coordinates and keys. Parse mouse<br />
898 &#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 />
899 </p>
900 </div>
901 </div>
902 <div id="outline-container-org64da03a" class="outline-3">
903 <h3 id="org64da03a"><span class="section-number-3">10.3.</span> 2D graphic library</h3>
904 <div class="outline-text-3" id="text-10-3">
905 <dl class="org-dl">
906 <dt>lineh ( color len x y imgbuf &#x2013; )</dt><dd>draws horisontal line from X,Y
907 coordinates to right, with specified length.</dd>
908
909 <dt>linev ( color len x y imgbuf &#x2013; )</dt><dd>draws vertical line down, from
910 coordinates X,Y, with specified length.</dd>
911
912 <dt>box ( color x2 x1 y2 y1 imgbuf &#x2013; )</dt><dd><p>
913 draws rectangular box. x2
914 bust be &gt;= x1, y2 must be &gt;= y1.
915 </p>
916
917 <pre class="example" id="org0225660">
918 x1,y1-----------+
919   |             |
920   |             |
921   +-----------x2,y2
922 </pre></dd>
923
924 <dt>flipv ( imgbuf &#x2013; )</dt><dd>flip image vertically.</dd>
925
926 <dt>imgcoltrans ( ImgBuf Color ToColor &#x2013; )</dt><dd>Translate all pixels in
927 specified image with "Color" into "ToColor".</dd>
928
929 <dt>imgfill ( color x y imgbuf &#x2013; )</dt><dd>Fill image region starting at
930 location X &amp; Y with specified color.</dd>
931 </dl>
932 </div>
933 </div>
934
935 <div id="outline-container-org203890d" class="outline-3">
936 <h3 id="org203890d"><span class="section-number-3">10.4.</span> Trigonometry functions</h3>
937 <div class="outline-text-3" id="text-10-4">
938 </div>
939 <div id="outline-container-org618a2c2" class="outline-4">
940 <h4 id="org618a2c2"><span class="section-number-4">10.4.1.</span> sin ( a &#x2013; result )</h4>
941 <div class="outline-text-4" id="text-10-4-1">
942 <p>
943 Return sinus from given angle "a", 360ø is 2000. So 1000 represents
944 180ø angle.  Result will be in range -10'000 to 10'000, instead of ñ1.
945 </p>
946 </div>
947 </div>
948 <div id="outline-container-org0f995cf" class="outline-4">
949 <h4 id="org0f995cf"><span class="section-number-4">10.4.2.</span> cos ( a &#x2013; result )</h4>
950 <div class="outline-text-4" id="text-10-4-2">
951 <p>
952 Return cosinus from given angle.  Parameters are like in <a href="#org618a2c2">sin</a> function.
953 </p>
954 </div>
955 </div>
956 </div>
957 </div>
958 </div>
959 <div id="postamble" class="status">
960 <p class="author">Author: Svjatoslav Agejenko</p>
961 <p class="date">Created: 2023-09-18 Mon 01:47</p>
962 <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
963 </div>
964 </body>
965 </html>