Rephrased documentation for better readability
[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-19 Tue 18:07 -->
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 </head>
198 <body>
199 <div id="content" class="content">
200 <h1 class="title">Fifth - virtual machine, operating system, programming language</h1>
201 <div id="table-of-contents" role="doc-toc">
202 <h2>Table of Contents</h2>
203 <div id="text-table-of-contents" role="doc-toc">
204 <ul>
205 <li><a href="#orgdd8d5a0">1. General</a>
206 <ul>
207 <li><a href="#org11b4b95">1.1. Source code</a></li>
208 </ul>
209 </li>
210 <li><a href="#org0a3946b">2. !Project deprecated!</a></li>
211 <li><a href="#org74c9861">3. Introduction</a>
212 <ul>
213 <li><a href="#orge8b459e">3.1. Screenshots</a></li>
214 </ul>
215 </li>
216 <li><a href="#orga9dfaee">4. Installation</a></li>
217 <li><a href="#orgefa2f79">5. Fifth distribution directory tree description</a></li>
218 <li><a href="#org751040b">6. Requirements</a>
219 <ul>
220 <li><a href="#org32f0917">6.1. Software</a></li>
221 <li><a href="#orgd6ecfe1">6.2. Hardware</a></li>
222 </ul>
223 </li>
224 <li><a href="#orgeb3cbc2">7. Numbers representation within Fifth</a></li>
225 <li><a href="#orga8a8f37">8. Disk file map, and it's data structures</a>
226 <ul>
227 <li><a href="#org4eb67fc">8.1. Disk allocation</a></li>
228 <li><a href="#org5fcae51">8.2. FAT entry format:</a></li>
229 <li><a href="#org811dc5b">8.3. File entry format</a></li>
230 </ul>
231 </li>
232 <li><a href="#orga49dca9">9. Core architecture</a>
233 <ul>
234 <li><a href="#org75e80d5">9.1. Dictionary entry format</a></li>
235 <li><a href="#org12381ef">9.2. Possible module types</a></li>
236 <li><a href="#org33be039">9.3. Memory map</a></li>
237 </ul>
238 </li>
239 <li><a href="#org81fd544">10. Dynamically loadable modules</a>
240 <ul>
241 <li><a href="#org79d1c84">10.1. Keyboard driver</a></li>
242 <li><a href="#org99b4378">10.2. Mouse driver</a></li>
243 <li><a href="#org0aa9e1f">10.3. 2D graphic library</a></li>
244 <li><a href="#orgff6cdef">10.4. Trigonometry functions</a>
245 <ul>
246 <li><a href="#org868f7c6">10.4.1. sin ( a &#x2013; result )</a></li>
247 <li><a href="#orgc3f161e">10.4.2. cos ( a &#x2013; result )</a></li>
248 </ul>
249 </li>
250 </ul>
251 </li>
252 </ul>
253 </div>
254 </div>
255
256 <div id="outline-container-orgdd8d5a0" class="outline-2">
257 <h2 id="orgdd8d5a0"><span class="section-number-2">1.</span> General</h2>
258 <div class="outline-text-2" id="text-1">
259 <ul class="org-ul">
260 <li>This program is free software: released under Creative Commons Zero
261 (CC0) license</li>
262
263 <li>Program author:
264 <ul class="org-ul">
265 <li>Svjatoslav Agejenko</li>
266 <li>Homepage: <a href="https://svjatoslav.eu">https://svjatoslav.eu</a></li>
267 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a></li>
268 </ul></li>
269
270 <li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a></li>
271 </ul>
272 </div>
273
274 <div id="outline-container-org11b4b95" class="outline-3">
275 <h3 id="org11b4b95"><span class="section-number-3">1.1.</span> Source code</h3>
276 <div class="outline-text-3" id="text-1-1">
277 <ul class="org-ul">
278 <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>
279
280 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=summary">Browse Git repository online</a></li>
281
282 <li><p>
283 Clone Git repository using command:
284 </p>
285 <pre class="example">
286 git clone https://www2.svjatoslav.eu/git/fifth.git
287 </pre></li>
288 </ul>
289 </div>
290 </div>
291 </div>
292
293 <div id="outline-container-org0a3946b" class="outline-2">
294 <h2 id="org0a3946b"><span class="section-number-2">2.</span> !Project deprecated!</h2>
295 <div class="outline-text-2" id="text-2">
296 <p>
297 Current implementation does not support object oriented
298 programming. While working on Fifth I got lots of cool new ideas that
299 require reimplementation of everything.
300 </p>
301
302 <p>
303 Currently I try to implement those new ideas in the project called
304 <a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
305 </p>
306
307 <p>
308 System is built many years ago when I was still using DOS as a primary
309 operating system.
310 </p>
311 </div>
312 </div>
313 <div id="outline-container-org74c9861" class="outline-2">
314 <h2 id="org74c9861"><span class="section-number-2">3.</span> Introduction</h2>
315 <div class="outline-text-2" id="text-3">
316 <p>
317 Fifth is a combination of:
318 </p>
319 <ul class="org-ul">
320 <li><a href="language.html#ID-da7fff9b-0b67-4843-828a-52a404d7f401">Programming language</a> (inspired by Forth).</li>
321 <li>Operating system.</li>
322 <li><a href="virtual machine.html#ID-9b251eb9-aff6-4025-94bf-25e89e26d54a">Virtual machine</a> with custom instruction set.</li>
323 </ul>
324 </div>
325
326 <div id="outline-container-orge8b459e" class="outline-3">
327 <h3 id="orge8b459e"><span class="section-number-3">3.1.</span> Screenshots</h3>
328 <div class="outline-text-3" id="text-3-1">
329
330 <div id="org76cf04c" class="figure">
331 <p><img src="screenshots/start.png" alt="start.png" />
332 </p>
333 </div>
334
335 <p>
336 Startup screen diplaying Fifth logo and full file list.
337 </p>
338
339
340 <div id="org7579242" class="figure">
341 <p><img src="screenshots/dictionary.png" alt="dictionary.png" />
342 </p>
343 </div>
344
345 <p>
346 Sample words defined. Most of the words are commands that can be
347 executed interactively from the command line or from a file. When
348 executed, they can be selectively compiled or interpreted.
349 </p>
350
351
352
353 <div id="org17f3e64" class="figure">
354 <p><img src="screenshots/text editor.png" alt="text editor.png" />
355 </p>
356 </div>
357
358 <p>
359 Built in text editor.
360 </p>
361 </div>
362 </div>
363 </div>
364
365 <div id="outline-container-orga9dfaee" class="outline-2">
366 <h2 id="orga9dfaee"><span class="section-number-2">4.</span> Installation</h2>
367 <div class="outline-text-2" id="text-4">
368 <p>
369 Just unpack all files, witout altering original directory structure,
370 somewhere in your hard disk. For example:
371 </p>
372
373 <pre class="example">
374 C:\MISC\FIFTH\
375 </pre>
376
377
378 <p>
379 To run fifth you need minimally just 2 files:
380 </p>
381 <dl class="org-dl">
382 <dt>EMULATOR.COM</dt><dd>Virtual CPU emulator</dd>
383 <dt>DISK.RAW</dt><dd>Virtual disk file</dd>
384 </dl>
385
386 <p>
387 For more information, please refer to <a href="#orgefa2f79">Fifth distribution directory
388 tree description</a>.
389 </p>
390 </div>
391 </div>
392
393 <div id="outline-container-orgefa2f79" class="outline-2">
394 <h2 id="orgefa2f79"><span class="section-number-2">5.</span> Fifth distribution directory tree description</h2>
395 <div class="outline-text-2" id="text-5">
396 <p>
397 After downloading and unpacking the ZIP file you shoud get directory
398 tree similar to this:
399 </p>
400
401 <p class="verse">
402 <b>DOC</b>                   - Fifth documentation<br />
403 &#xa0;&#xa0;<b>commands</b>            - documentation on Fifth built-in commands<br />
404 &#xa0;&#xa0;<b>modules</b>             - documentation on additional commands, realized as loadable modules<br />
405 &#xa0;&#xa0;<b>shots</b>               - Fifth screenshots<br />
406 <br />
407 <b>imageFile</b>             - files contained within 'disk.raw', just an extracted form.<br />
408 <br />
409 <b>source</b>                - source files<br />
410 &#xa0;&#xa0;<b>emulator</b>            - emulator source<br />
411 &#xa0;&#xa0;<b>util</b>                - utilites<br />
412 <br />
413 <b>disk.raw</b>                - Virtual disk file, has filesystem inside.<br />
414 <b>emulator.com</b>            - main executable.<br />
415 </p>
416 </div>
417 </div>
418
419 <div id="outline-container-org751040b" class="outline-2">
420 <h2 id="org751040b"><span class="section-number-2">6.</span> Requirements</h2>
421 <div class="outline-text-2" id="text-6">
422 </div>
423 <div id="outline-container-org32f0917" class="outline-3">
424 <h3 id="org32f0917"><span class="section-number-3">6.1.</span> Software</h3>
425 <div class="outline-text-3" id="text-6-1">
426 <ul class="org-ul">
427 <li>MS-DOS 6.22 with HIMEM.SYS loaded.</li>
428 <li>Mouse driver (optional, if you have a mouse).</li>
429 <li>CPU is initialized into <a href="https://en.wikipedia.org/wiki/Unreal_mode">Unreal Mode</a> during operation.</li>
430 <li>To recompile ASM sources, you can use FASM (Flat Assembler).</li>
431 <li>To run Quick Basic utilities, use Microsoft Quick Basic 4.5.</li>
432 <li>VESA support through BIOS or external driver (UNIVBE).</li>
433 </ul>
434 </div>
435 </div>
436
437 <div id="outline-container-orgd6ecfe1" class="outline-3">
438 <h3 id="orgd6ecfe1"><span class="section-number-3">6.2.</span> Hardware</h3>
439 <div class="outline-text-3" id="text-6-2">
440 <ul class="org-ul">
441 <li>A minimum of a i386 CPU.</li>
442 <li>64 KB of free RAM below 640KB.</li>
443 <li>2 MB of free <a href="https://en.wikipedia.org/wiki/Extended_memory">extended memory</a>.</li>
444 <li>A VESA-compatible video card.</li>
445 </ul>
446 </div>
447 </div>
448 </div>
449
450 <div id="outline-container-orgeb3cbc2" class="outline-2">
451 <h2 id="orgeb3cbc2"><span class="section-number-2">7.</span> Numbers representation within Fifth</h2>
452 <div class="outline-text-2" id="text-7">
453 <p>
454 Because we are in full experimentation mode here (no regard for
455 compatibility whatsoever), why not to try also alternative number
456 representation ?
457 </p>
458
459 <p>
460 Here alternative hexadecimal number representation format is devised:
461 </p>
462
463
464 <div id="org67795e4" class="figure">
465 <p><a href="numbers.png"><img src="numbers.png" alt="numbers.png" /></a>
466 </p>
467 </div>
468
469 <p>
470 Essentially square is split into 4 triangles. Each triangle represents
471 one bit.
472 </p>
473
474 <p>
475 Fifth uses this hexadecimal format as primary throughout entire
476 system.
477 </p>
478
479 <p>
480 See also: <a href="https://en.wikipedia.org/wiki/Bibi-binary">Bibi-binary</a>.
481 </p>
482 </div>
483 </div>
484
485 <div id="outline-container-orga8a8f37" class="outline-2">
486 <h2 id="orga8a8f37"><span class="section-number-2">8.</span> Disk file map, and it's data structures</h2>
487 <div class="outline-text-2" id="text-8">
488 <p>
489 Core and high-level boot code is stored outside of the filesystem to
490 allow easy access to it, at early booting time, when filesystem is not
491 yet initialized.
492 </p>
493 </div>
494 <div id="outline-container-org4eb67fc" class="outline-3">
495 <h3 id="org4eb67fc"><span class="section-number-3">8.1.</span> Disk allocation</h3>
496 <div class="outline-text-3" id="text-8-1">
497 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
498
499
500 <colgroup>
501 <col  class="org-left" />
502
503 <col  class="org-left" />
504
505 <col  class="org-left" />
506 </colgroup>
507 <thead>
508 <tr>
509 <th scope="col" class="org-left">offset</th>
510 <th scope="col" class="org-left">length</th>
511 <th scope="col" class="org-left">description</th>
512 </tr>
513 </thead>
514 <tbody>
515 <tr>
516 <td class="org-left">0</td>
517 <td class="org-left">~4 Kb</td>
518 <td class="org-left">Fifth core</td>
519 </tr>
520
521 <tr>
522 <td class="org-left">4 Kb</td>
523 <td class="org-left">~32 Kb</td>
524 <td class="org-left">high-level boot code</td>
525 </tr>
526
527 <tr>
528 <td class="org-left">37 Kb</td>
529 <td class="org-left">~65 Kb</td>
530 <td class="org-left">FAT</td>
531 </tr>
532
533 <tr>
534 <td class="org-left">101 Kb</td>
535 <td class="org-left">~16 MB</td>
536 <td class="org-left">filesystem data area</td>
537 </tr>
538 </tbody>
539 </table>
540 </div>
541 </div>
542 <div id="outline-container-org5fcae51" class="outline-3">
543 <h3 id="org5fcae51"><span class="section-number-3">8.2.</span> FAT entry format:</h3>
544 <div class="outline-text-3" id="text-8-2">
545 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
546
547
548 <colgroup>
549 <col  class="org-right" />
550
551 <col  class="org-left" />
552 </colgroup>
553 <thead>
554 <tr>
555 <th scope="col" class="org-right">code</th>
556 <th scope="col" class="org-left">meaning</th>
557 </tr>
558 </thead>
559 <tbody>
560 <tr>
561 <td class="org-right">-2</td>
562 <td class="org-left">last sector</td>
563 </tr>
564
565 <tr>
566 <td class="org-right">-1</td>
567 <td class="org-left">empty sector</td>
568 </tr>
569
570 <tr>
571 <td class="org-right">0 --</td>
572 <td class="org-left">.. pointer to next block</td>
573 </tr>
574 </tbody>
575 </table>
576 </div>
577 </div>
578 <div id="outline-container-org811dc5b" class="outline-3">
579 <h3 id="org811dc5b"><span class="section-number-3">8.3.</span> File entry format</h3>
580 <div class="outline-text-3" id="text-8-3">
581 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
582
583
584 <colgroup>
585 <col  class="org-right" />
586
587 <col  class="org-right" />
588
589 <col  class="org-left" />
590 </colgroup>
591 <thead>
592 <tr>
593 <th scope="col" class="org-right">offset</th>
594 <th scope="col" class="org-right">length</th>
595 <th scope="col" class="org-left">description</th>
596 </tr>
597 </thead>
598 <tbody>
599 <tr>
600 <td class="org-right">0</td>
601 <td class="org-right">4</td>
602 <td class="org-left">extension</td>
603 </tr>
604
605 <tr>
606 <td class="org-right">4</td>
607 <td class="org-right">16</td>
608 <td class="org-left">name</td>
609 </tr>
610
611 <tr>
612 <td class="org-right">20</td>
613 <td class="org-right">4</td>
614 <td class="org-left">entry point</td>
615 </tr>
616
617 <tr>
618 <td class="org-right">24</td>
619 <td class="org-right">4</td>
620 <td class="org-left">size</td>
621 </tr>
622
623 <tr>
624 <td class="org-right">28</td>
625 <td class="org-right">4</td>
626 <td class="org-left">last modification time</td>
627 </tr>
628 </tbody>
629 </table>
630 </div>
631 </div>
632 </div>
633 <div id="outline-container-orga49dca9" class="outline-2">
634 <h2 id="orga49dca9"><span class="section-number-2">9.</span> Core architecture</h2>
635 <div class="outline-text-2" id="text-9">
636 <p>
637 Fifth core is simply some amount of already compiled into machine code
638 and linked together modules (entries in other words). In compilation
639 process modules is compiled one by one and simply stored on top of
640 already existing and growing core. Separately from core is kept
641 dictionary, this is special list that contain names of compiled
642 modules, variables etc. and they locations in core. Constants use
643 dictionary space only. Random word can be removed from dictionary at
644 any time. Currently dictionary can contain at most 1000 entries.
645 </p>
646 </div>
647 <div id="outline-container-org75e80d5" class="outline-3">
648 <h3 id="org75e80d5"><span class="section-number-3">9.1.</span> Dictionary entry format</h3>
649 <div class="outline-text-3" id="text-9-1">
650 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
651
652
653 <colgroup>
654 <col  class="org-right" />
655
656 <col  class="org-right" />
657
658 <col  class="org-left" />
659 </colgroup>
660 <thead>
661 <tr>
662 <th scope="col" class="org-right">offset</th>
663 <th scope="col" class="org-right">length</th>
664 <th scope="col" class="org-left">description</th>
665 </tr>
666 </thead>
667 <tbody>
668 <tr>
669 <td class="org-right">0</td>
670 <td class="org-right">4</td>
671 <td class="org-left">0 &amp;lt; previous entry</td>
672 </tr>
673
674 <tr>
675 <td class="org-right">&#xa0;</td>
676 <td class="org-right">&#xa0;</td>
677 <td class="org-left">0 = last</td>
678 </tr>
679
680 <tr>
681 <td class="org-right">&#xa0;</td>
682 <td class="org-right">&#xa0;</td>
683 <td class="org-left">-1 = empty</td>
684 </tr>
685 </tbody>
686 <tbody>
687 <tr>
688 <td class="org-right">4</td>
689 <td class="org-right">15</td>
690 <td class="org-left">module name string</td>
691 </tr>
692 </tbody>
693 <tbody>
694 <tr>
695 <td class="org-right">19</td>
696 <td class="org-right">1</td>
697 <td class="org-left">entry type</td>
698 </tr>
699 </tbody>
700 <tbody>
701 <tr>
702 <td class="org-right">20</td>
703 <td class="org-right">4</td>
704 <td class="org-left">entry data</td>
705 </tr>
706 </tbody>
707 </table>
708
709 <p>
710 Core headers as linked list of module names make up something like
711 dictionary.  When some entry address is needed compiler can quickly
712 run through headers backwards and find needed entry.
713 </p>
714 </div>
715 </div>
716 <div id="outline-container-org12381ef" class="outline-3">
717 <h3 id="org12381ef"><span class="section-number-3">9.2.</span> Possible module types</h3>
718 <div class="outline-text-3" id="text-9-2">
719 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
720
721
722 <colgroup>
723 <col  class="org-right" />
724
725 <col  class="org-left" />
726
727 <col  class="org-left" />
728 </colgroup>
729 <thead>
730 <tr>
731 <th scope="col" class="org-right">type</th>
732 <th scope="col" class="org-left">description</th>
733 <th scope="col" class="org-left">"execute" action</th>
734 </tr>
735 </thead>
736 <tbody>
737 <tr>
738 <td class="org-right">0</td>
739 <td class="org-left">data</td>
740 <td class="org-left">compile "num" instruction</td>
741 </tr>
742
743 <tr>
744 <td class="org-right">&#xa0;</td>
745 <td class="org-left">&#xa0;</td>
746 <td class="org-left">with address to module</td>
747 </tr>
748 </tbody>
749 <tbody>
750 <tr>
751 <td class="org-right">1</td>
752 <td class="org-left">submodule</td>
753 <td class="org-left">compile "call" instruction</td>
754 </tr>
755
756 <tr>
757 <td class="org-right">&#xa0;</td>
758 <td class="org-left">&#xa0;</td>
759 <td class="org-left">with address to module</td>
760 </tr>
761 </tbody>
762 <tbody>
763 <tr>
764 <td class="org-right">2</td>
765 <td class="org-left">imm. submodule</td>
766 <td class="org-left">immediately call to module</td>
767 </tr>
768 </tbody>
769 </table>
770 </div>
771 </div>
772 <div id="outline-container-org33be039" class="outline-3">
773 <h3 id="org33be039"><span class="section-number-3">9.3.</span> Memory map</h3>
774 <div class="outline-text-3" id="text-9-3">
775 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
776
777
778 <colgroup>
779 <col  class="org-right" />
780
781 <col  class="org-left" />
782
783 <col  class="org-left" />
784 </colgroup>
785 <thead>
786 <tr>
787 <th scope="col" class="org-right">location</th>
788 <th scope="col" class="org-left">size</th>
789 <th scope="col" class="org-left">description</th>
790 </tr>
791 </thead>
792 <tbody>
793 <tr>
794 <td class="org-right">0</td>
795 <td class="org-left">~4096</td>
796 <td class="org-left">core</td>
797 </tr>
798
799 <tr>
800 <td class="org-right">1500000</td>
801 <td class="org-left">~32000</td>
802 <td class="org-left">highlevel Fifth boot code</td>
803 </tr>
804
805 <tr>
806 <td class="org-right">200000h</td>
807 <td class="org-left">&#xa0;</td>
808 <td class="org-left">core startup messages area</td>
809 </tr>
810
811 <tr>
812 <td class="org-right">5200000</td>
813 <td class="org-left">&#xa0;</td>
814 <td class="org-left">end of dynamic memory space</td>
815 </tr>
816 </tbody>
817 </table>
818 </div>
819 </div>
820 </div>
821 <div id="outline-container-org81fd544" class="outline-2">
822 <h2 id="org81fd544"><span class="section-number-2">10.</span> Dynamically loadable modules</h2>
823 <div class="outline-text-2" id="text-10">
824 </div>
825 <div id="outline-container-org79d1c84" class="outline-3">
826 <h3 id="org79d1c84"><span class="section-number-3">10.1.</span> Keyboard driver</h3>
827 <div class="outline-text-3" id="text-10-1">
828 <p class="verse">
829 <br />
830 KBD_@           ( &#x2013; code ) get scancodes for pressed keys from keyboard.<br />
831 KBD_down?       ( key &#x2013; result ) check is key with specified scancode<br />
832 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;currently pressed down.<br />
833 KBD_SC2FSCII    ( code &#x2013; FSCII ) convert key scancode into FSCII code,<br />
834 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;or in FSK (Fifth standard keycode).<br />
835 KBD_F@          ( &#x2013; FSCII ) read pressed key FSCII or FSK, returns -1 if no<br />
836 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;keys are pressed.<br />
837 KBD_FW@         ( &#x2013; FSCII ) read pressed key FSCII or FSK, if no keys is<br />
838 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;are pressed then waits until there is.<br />
839 <br />
840 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;FSK<br />
841 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#x2014;<br />
842 In HEX.<br />
843 <br />
844 FC      backspace<br />
845 FD      TAB<br />
846 FE      enter<br />
847 FF      space<br />
848 <br />
849 400     ESC<br />
850 401 &#x2026; F1 &#x2026;<br />
851 410     up<br />
852 411     right<br />
853 412     down<br />
854 413     left<br />
855 414     INS<br />
856 415     DEL<br />
857 416     home<br />
858 417     end<br />
859 418     PG/UP<br />
860 419     PG/DN<br />
861 </p>
862 </div>
863 </div>
864 <div id="outline-container-org99b4378" class="outline-3">
865 <h3 id="org99b4378"><span class="section-number-3">10.2.</span> Mouse driver</h3>
866 <div class="outline-text-3" id="text-10-2">
867 <p class="verse">
868 mousex  var     Mouse x coordinate.<br />
869 mousey  var     Mouse y coordinate.<br />
870 mousekeyl var   Mouse left key.<br />
871 mousekeym var   Mouse middle key.<br />
872 mousekeyr var   Mouse right key.<br />
873 mousec  var     Display current mouse coordinates in top left part of screen,<br />
874 &#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;if true. (good for debugging)<br />
875 mousepointer var  Image buffer, holding current mouse pointer.<br />
876 mouseadd        ( ModuleAddr x1 x2 y1 y2 &#x2013; ) Add specified area on screen,<br />
877 &#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 />
878 &#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 />
879 mousebe var     Amount of buffer elements.<br />
880 mousedo         ( &#x2013; ) Updates mouse coordinates and keys. Parse mouse<br />
881 &#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 />
882 </p>
883 </div>
884 </div>
885 <div id="outline-container-org0aa9e1f" class="outline-3">
886 <h3 id="org0aa9e1f"><span class="section-number-3">10.3.</span> 2D graphic library</h3>
887 <div class="outline-text-3" id="text-10-3">
888 <dl class="org-dl">
889 <dt>lineh ( color len x y imgbuf &#x2013; )</dt><dd>draws horisontal line from X,Y
890 coordinates to right, with specified length.</dd>
891
892 <dt>linev ( color len x y imgbuf &#x2013; )</dt><dd>draws vertical line down, from
893 coordinates X,Y, with specified length.</dd>
894
895 <dt>box ( color x2 x1 y2 y1 imgbuf &#x2013; )</dt><dd><p>
896 draws rectangular box. x2
897 bust be &gt;= x1, y2 must be &gt;= y1.
898 </p>
899
900 <pre class="example" id="orgfea073c">
901 x1,y1-----------+
902   |             |
903   |             |
904   +-----------x2,y2
905 </pre></dd>
906
907 <dt>flipv ( imgbuf &#x2013; )</dt><dd>flip image vertically.</dd>
908
909 <dt>imgcoltrans ( ImgBuf Color ToColor &#x2013; )</dt><dd>Translate all pixels in
910 specified image with "Color" into "ToColor".</dd>
911
912 <dt>imgfill ( color x y imgbuf &#x2013; )</dt><dd>Fill image region starting at
913 location X &amp; Y with specified color.</dd>
914 </dl>
915 </div>
916 </div>
917
918 <div id="outline-container-orgff6cdef" class="outline-3">
919 <h3 id="orgff6cdef"><span class="section-number-3">10.4.</span> Trigonometry functions</h3>
920 <div class="outline-text-3" id="text-10-4">
921 </div>
922 <div id="outline-container-org868f7c6" class="outline-4">
923 <h4 id="org868f7c6"><span class="section-number-4">10.4.1.</span> sin ( a &#x2013; result )</h4>
924 <div class="outline-text-4" id="text-10-4-1">
925 <p>
926 Return sinus from given angle "a", 360ø is 2000. So 1000 represents
927 180ø angle.  Result will be in range -10'000 to 10'000, instead of ñ1.
928 </p>
929 </div>
930 </div>
931 <div id="outline-container-orgc3f161e" class="outline-4">
932 <h4 id="orgc3f161e"><span class="section-number-4">10.4.2.</span> cos ( a &#x2013; result )</h4>
933 <div class="outline-text-4" id="text-10-4-2">
934 <p>
935 Return cosinus from given angle.  Parameters are like in <a href="#org868f7c6">sin</a> function.
936 </p>
937 </div>
938 </div>
939 </div>
940 </div>
941 </div>
942 <div id="postamble" class="status">
943 <p class="author">Author: Svjatoslav Agejenko</p>
944 <p class="date">Created: 2023-09-19 Tue 18:07</p>
945 <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
946 </div>
947 </body>
948 </html>