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">
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" />
13 #content { max-width: 60em; margin: auto; }
14 .title { text-align: center;
15 margin-bottom: .2em; }
16 .subtitle { text-align: center;
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%; }
34 border: 1px solid #e6e6e6;
36 background-color: #f2f2f2;
38 font-family: monospace;
53 background-color: #f2f2f299;
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"
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'; }
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 {
171 vertical-align: middle;
176 vertical-align: middle;
180 border: 2px solid gray;
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; }
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">
199 displayAlign: "center",
200 displayIndent: "0em",
202 "HTML-CSS": { scale: 100,
203 linebreaks: { automatic: "false" },
207 linebreaks: { automatic: "false" },
209 NativeMML: {scale: 100},
210 TeX: { equationNumbers: {autoNumber: "AMS"},
211 MultLineWidth: "85%",
217 <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
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">
226 <li><a href="#org48b7220">1. General</a>
228 <li><a href="#org22b59dd">1.1. Source code</a></li>
231 <li><a href="#org20b6805">2. !Project deprecated!</a></li>
232 <li><a href="#orgc67a478">3. Introduction</a>
234 <li><a href="#org8504a11">3.1. screenshots</a></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>
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>
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>
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>
254 <li><a href="#orgbfdae7b">9. Core architecture</a>
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>
261 <li><a href="#org835c31e">10. Dynamically loadable modules</a>
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>
268 <li><a href="#org618a2c2">10.4.1. sin ( a – result )</a></li>
269 <li><a href="#org0f995cf">10.4.2. cos ( a – result )</a></li>
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">
282 <li>This program is free software: released under Creative Commons Zero
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>
292 <li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a></li>
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">
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>
302 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=summary">Browse Git repository online</a></li>
305 Clone Git repository using command:
307 <pre class="example">
308 git clone https://www2.svjatoslav.eu/git/fifth.git
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">
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.
325 Currently I try to implement those new ideas in the project called
326 <a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
330 System is built many years ago when I was still using DOS as a primary
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">
339 Fifth is a combination of:
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>
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">
352 <div id="org9178e56" class="figure">
353 <p><img src="screenshots/start.png" alt="start.png" />
358 Startup screen diplaying Fifth logo and full file list.
362 <div id="orgf022552" class="figure">
363 <p><img src="screenshots/dictionary.png" alt="dictionary.png" />
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.
375 <div id="org415fab1" class="figure">
376 <p><img src="screenshots/text editor.png" alt="text editor.png" />
381 Built in text editor.
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">
391 Just unpack all files, witout altering original directory structure,
392 somewhere in your hard disk. For example: C:\MISC\FIFTH\…. To run
393 fifth you need minimally just 2 files. emulator itself ( EMULATOR.EXE
394 or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
398 Read more about <a href="#orgf9fdcb5">Fifth distribution directory tree description</a>.
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">
407 After downloading and unpacking the ZIP file you shoud get directory
408 tree similar to this:
412 <b>DOC</b> - Fifth documentation<br />
413   <b>commands</b> - documentation on Fifth built-in commands<br />
414   <b>modules</b> - documentation on additional commands, realized as loadable modules<br />
415   <b>shots</b> - Fifth screenshots<br />
417 <b>imageFile</b> - files contained within 'disk.raw', just an extracted form.<br />
419 <b>source</b> - source files<br />
420   <b>emulator</b> - emulator source<br />
421   <b>util</b> - utilites<br />
423 <b>disk.raw</b> - Virtual disk file, has filesystem inside.<br />
424 <b>emulator.com</b> - main executable.<br />
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">
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">
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>
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">
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>
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">
461 <li>Beginner level Forth knowledge is recommended.</li>
462 <li>Lots of enthusiasm.</li>
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">
471 Because we are in full experimentation mode here (no regard for
472 compatibility whatsoever), why not to try also alternative number
477 Here alternative hexadecimal number representation format is devised:
481 <div id="org806c6d6" class="figure">
482 <p><a href="numbers.png"><img src="numbers.png" alt="numbers.png" /></a>
487 Essentially square is split into 4 triangles. Each triangle represents
492 Fifth uses this hexadecimal format as primary throughout entire
497 See also: <a href="https://en.wikipedia.org/wiki/Bibi-binary">Bibi-binary</a>.
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">
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
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">
518 <col class="org-left" />
520 <col class="org-left" />
522 <col class="org-left" />
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>
533 <td class="org-left">0</td>
534 <td class="org-left">~4 Kb</td>
535 <td class="org-left">Fifth core</td>
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>
545 <td class="org-left">37 Kb</td>
546 <td class="org-left">~65 Kb</td>
547 <td class="org-left">FAT</td>
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>
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">
566 <col class="org-right" />
568 <col class="org-left" />
572 <th scope="col" class="org-right">code</th>
573 <th scope="col" class="org-left">meaning</th>
578 <td class="org-right">-2</td>
579 <td class="org-left">last sector</td>
583 <td class="org-right">-1</td>
584 <td class="org-left">empty sector</td>
588 <td class="org-right">0 --</td>
589 <td class="org-left">.. pointer to next block</td>
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">
602 <col class="org-right" />
604 <col class="org-right" />
606 <col class="org-left" />
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>
617 <td class="org-right">0</td>
618 <td class="org-right">4</td>
619 <td class="org-left">extension</td>
623 <td class="org-right">4</td>
624 <td class="org-right">16</td>
625 <td class="org-left">name</td>
629 <td class="org-right">20</td>
630 <td class="org-right">4</td>
631 <td class="org-left">entry point</td>
635 <td class="org-right">24</td>
636 <td class="org-right">4</td>
637 <td class="org-left">size</td>
641 <td class="org-right">28</td>
642 <td class="org-right">4</td>
643 <td class="org-left">last modification time</td>
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">
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.
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">
671 <col class="org-right" />
673 <col class="org-right" />
675 <col class="org-left" />
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>
686 <td class="org-right">0</td>
687 <td class="org-right">4</td>
688 <td class="org-left">0 &lt; previous entry</td>
692 <td class="org-right"> </td>
693 <td class="org-right"> </td>
694 <td class="org-left">0 = last</td>
698 <td class="org-right"> </td>
699 <td class="org-right"> </td>
700 <td class="org-left">-1 = empty</td>
705 <td class="org-right">4</td>
706 <td class="org-right">15</td>
707 <td class="org-left">module name string</td>
712 <td class="org-right">19</td>
713 <td class="org-right">1</td>
714 <td class="org-left">entry type</td>
719 <td class="org-right">20</td>
720 <td class="org-right">4</td>
721 <td class="org-left">entry data</td>
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.
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">
740 <col class="org-right" />
742 <col class="org-left" />
744 <col class="org-left" />
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>
755 <td class="org-right">0</td>
756 <td class="org-left">data</td>
757 <td class="org-left">compile "num" instruction</td>
761 <td class="org-right"> </td>
762 <td class="org-left"> </td>
763 <td class="org-left">with address to module</td>
768 <td class="org-right">1</td>
769 <td class="org-left">submodule</td>
770 <td class="org-left">compile "call" instruction</td>
774 <td class="org-right"> </td>
775 <td class="org-left"> </td>
776 <td class="org-left">with address to module</td>
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>
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">
796 <col class="org-right" />
798 <col class="org-left" />
800 <col class="org-left" />
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>
811 <td class="org-right">0</td>
812 <td class="org-left">~4096</td>
813 <td class="org-left">core</td>
817 <td class="org-right">1500000</td>
818 <td class="org-left">~32000</td>
819 <td class="org-left">highlevel Fifth boot code</td>
823 <td class="org-right">200000h</td>
824 <td class="org-left"> </td>
825 <td class="org-left">core startup messages area</td>
829 <td class="org-right">5200000</td>
830 <td class="org-left"> </td>
831 <td class="org-left">end of dynamic memory space</td>
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">
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">
847 KBD_@ ( – code ) get scancodes for pressed keys from keyboard.<br />
848 KBD_down? ( key – result ) check is key with specified scancode<br />
849                 currently pressed down.<br />
850 KBD_SC2FSCII ( code – FSCII ) convert key scancode into FSCII code,<br />
851                 or in FSK (Fifth standard keycode).<br />
852 KBD_F@ ( – FSCII ) read pressed key FSCII or FSK, returns -1 if no<br />
853                 keys are pressed.<br />
854 KBD_FW@ ( – FSCII ) read pressed key FSCII or FSK, if no keys is<br />
855                 are pressed then waits until there is.<br />
857                 FSK<br />
858                 —<br />
867 401 … F1 …<br />
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">
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                 if true. (good for debugging)<br />
892 mousepointer var Image buffer, holding current mouse pointer.<br />
893 mouseadd ( ModuleAddr x1 x2 y1 y2 – ) Add specified area on screen,<br />
894                 into mause click buffer. If any mouse button is clicked on<br />
895                 that area, module at "ModuleAddr" will be executed.<br />
896 mousebe var Amount of buffer elements.<br />
897 mousedo ( – ) Updates mouse coordinates and keys. Parse mouse<br />
898                 click buffer, and draw mouse cursor to "screen".<br />
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">
906 <dt>lineh ( color len x y imgbuf – )</dt><dd>draws horisontal line from X,Y
907 coordinates to right, with specified length.</dd>
909 <dt>linev ( color len x y imgbuf – )</dt><dd>draws vertical line down, from
910 coordinates X,Y, with specified length.</dd>
912 <dt>box ( color x2 x1 y2 y1 imgbuf – )</dt><dd><p>
913 draws rectangular box. x2
914 bust be >= x1, y2 must be >= y1.
917 <pre class="example" id="org0225660">
924 <dt>flipv ( imgbuf – )</dt><dd>flip image vertically.</dd>
926 <dt>imgcoltrans ( ImgBuf Color ToColor – )</dt><dd>Translate all pixels in
927 specified image with "Color" into "ToColor".</dd>
929 <dt>imgfill ( color x y imgbuf – )</dt><dd>Fill image region starting at
930 location X & Y with specified color.</dd>
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">
939 <div id="outline-container-org618a2c2" class="outline-4">
940 <h4 id="org618a2c2"><span class="section-number-4">10.4.1.</span> sin ( a – result )</h4>
941 <div class="outline-text-4" id="text-10-4-1">
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.
948 <div id="outline-container-org0f995cf" class="outline-4">
949 <h4 id="org0f995cf"><span class="section-number-4">10.4.2.</span> cos ( a – result )</h4>
950 <div class="outline-text-4" id="text-10-4-2">
952 Return cosinus from given angle. Parameters are like in <a href="#org618a2c2">sin</a> function.
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>