-<p>
-Using CPU emulator slows it down but I shouldn't now think too mutch
-about, and waste my time on batteling with problems whitch results on
-complex design of PC hardware. Also it allows me to use existing DOS
-and resident drivers services in real mode. So I don't need to deal
-with hardware too mutch. It also allows me to use all free XMS for
-flat code & data storage.
-</p>
-
-<p>
-Current emulator emulates 1 CPU. It has 2 stacks, ~50 instructions,
-and 4GB flat address space (theoretically). I'm not sure that DOS
-6.22 that I currently prefer can handle more than 64 MB of RAM. While
-I tried to keep instructionset simple, I was forced to put in lot of
-complex instructions to make it's performance acceptable on
-emulator. On actual silicon ~20 instructions is enaugh (I think).
-</p>
-
-<p>
-Maybe one day similar system will run directly on custom silicon chip :)
-</p>
-
-
-<p>
-CPU has following registers:
-</p>
-<table class="table table-striped table-bordered table-hover table-condensed">
-
-
-<colgroup>
-<col class="left">
-
-<col class="left">
-</colgroup>
-<tbody>
-<tr>
-<td class="text-left">IP</td>
-<td class="text-left">instruction pointer</td>
-</tr>
-
-<tr>
-<td class="text-left">DSP</td>
-<td class="text-left">data stack pointer</td>
-</tr>
-
-<tr>
-<td class="text-left">RSP</td>
-<td class="text-left">return stack pointer</td>
-</tr>
-</tbody>
-</table>
-
-<p>
-Virtual CPU, commands (most of them are avaiable as ordinary commands
-in programming lanquage):
-</p>
-
-<p class="verse">
-<br >
-code mnemonic description<br >
-<br >
-0 nop does notheing<br >
-1 halt halt CPU ( return to DOS on emulator )<br >
-<br >
-2 kbd@ ( – c ) read scancode of pressed or released key.<br >
-                                Returns 0, if no data avaiable.<br >
-3 num <dword> ( – n ) put immidiate number into datastack<br >
-<br >
-4 jmp <dword> jump to specified code<br >
-5 call <dword>jump to specified code, save return address to<br >
-                                return stack.<br >
-<br >
-6 1+ ( n – n+1 )<br >
-7 1- ( n – n-1 )<br >
-<br >
-8 dup ( n – n n ) duplicate top of data stack<br >
-9 drop ( n – ) drop last element in data stack<br >
-<br >
-10 if <dword> ( n – ) jump to addr if top element was 0<br >
-11 ret jump to code, specified in return stack.<br >
-<br >
-12 c@ ( addr – n ) read byte from memory at specified address<br >
-13 c! ( n addr – ) store byte to specified memory<br >
-<br >
-14 push ( DSTK -> RSTK ) move top of datastack to returnstack<br >
-15 pop ( RSTK -> DSTK ) move top of returnstack to datastack<br >
-<br >
-16 <unused><br >
-17 rot ( n1 n2 n3 – n2 n3 n1) rotate stack elements<br >
-<br >
-18 disk@ ( FromDiskSect ToMem – ) read 1KB from disk into RAM<br >
-19 disk! ( FromMem ToDiskSect – ) write 1KB to disk<br >
-<br >
-20 @ ( addr – n ) read 32 bit number from memory<br >
-21 ! ( n addr – ) store 32 bit number to memory<br >
-<br >
-22 over ( n1 n2 – n1 n2 n1 ) self explaining …<br >
-23 swap ( n1 n2 – n2 n1 ) -,,-<br >
-<br >
-24 + ( n1 n2 – n1+n2 ) -,,-<br >
-25 - ( n1 n2 – n1-n2 ) -,,-<br >
-<br >
-26 * ( n1 n2 – n1*n2 ) -,,-<br >
-27 / ( n1 n2 – n1/n2 ) -,,-<br >
-<br >
-28 > ( n1 n2 – result ) is true when n1 > n2<br >
-29 < ( n1 n2 – result ) is true when n1 < n2<br >
-<br >
-30 not ( n1 – not_n1 ) logical not<br >
-31 i ( – n ) copies top of return stack into datastack<br >
-<br >
-32 cprt@ ( addr – n ) read one byte from hardware port<br >
-33 cprt! ( n addr – ) store one byte to hardware port<br >
-<br >
-34 i2 ( – n ) like "i" but takes socond top stack element.<br >
-35 i3 ( – n ) like "i" but takes third top stack element.<br >
-<br >
-36 shl ( n amount – n ) left bit shift<br >
-37 shr ( n amount – n ) right bit shift<br >
-<br >
-38 or ( n1 n2 – n ) logical or<br >
-39 xor ( n1 n2 – n ) exclusive logical or<br >
-<br >
-40 vidmap ( addr – ) copy memory from "addr" to video memory.<br >
-<br >
-41 mouse@ ( – x y button ) read mouse coordinates & buttons<br >
-<br >
-42 vidput ( addr1 addr2 x y – ) put image1 into image2, at<br >
-                                location x, y. Does clipping, so part of a big image<br >
-                                can be mapped into smaller one.<br >
-<br >
-43 cmove ( addr1 addr2 amount ) move memory from addr1 to addr2<br >
-                                if addr1 is greater than addr2 then count address<br >
-                                foward while moving, elseway starts from end and<br >
-                                counts backwards, so no data loss will occure on<br >
-                                overlapping.<br >
-<br >
-44 cfill ( c addr amount – ) fill memory starting at "addr"<br >
-                                with "c" bytes.<br >
-<br >
-45 tvidput ( addr1 addr2 x y – ) same as "vidput" but treats<br >
-                                color 255 in source image as transparent.<br >
-<br >
-46 depth ( – depth ) returns current depth of data stack.<br >
-<br >
-47 charput ( colorfg colorbg addrsrc addrdest x y )<br >
-                                draw character to image buffer located at "addrdest"<br >
-                                to specified x & y location. Decodes 8 bytes from<br >
-                                source to bits, used to draw character.<br >
-</p>
-</div>
-</div>
-
-<div id="outline-container-sec-11" class="outline-2">
-<h2 id="sec-11"><span class="section-number-2">11</span> Fifth source format</h2>
-<div class="outline-text-2" id="text-11">
-<p>
-Fifth uses a different character table and codes than ASCII (still
-almost similar). I call it FSCII (Fifth Standard Code for Information
-Interchange) for example space character is not 32 but 255 instead. I
-plan to use mainly HEX numbers, and create new characters to represent
-numeric values. So typical nemric characters "0123…" is treated
-like ordinary letters.
-</p>
-</div>
-<div id="outline-container-sec-11-1" class="outline-3">
-<h3 id="sec-11-1"><span class="section-number-3">11.1</span> FSCII</h3>
-<div class="outline-text-3" id="text-11-1">
-<table class="table table-striped table-bordered table-hover table-condensed">
-
-
-<colgroup>
-<col class="right">
-
-<col class="left">
-
-<col class="left">
-</colgroup>
-<thead>
-<tr>
-<th scope="col" class="text-right">DEC</th>
-<th scope="col" class="text-left">HEX</th>
-<th scope="col" class="text-left">function</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="text-right">0 - 15</td>
-<td class="text-left">0 - F</td>
-<td class="text-left">HEX numbers</td>
-</tr>
-
-<tr>
-<td class="text-right">252</td>
-<td class="text-left">FC</td>
-<td class="text-left">backspace</td>
-</tr>
-
-<tr>
-<td class="text-right">253</td>
-<td class="text-left">FD</td>
-<td class="text-left">tabulator (TAB)</td>
-</tr>
-
-<tr>
-<td class="text-right">254</td>
-<td class="text-left">FE</td>
-<td class="text-left">carriage return (CR)</td>
-</tr>
-
-<tr>
-<td class="text-right">255</td>
-<td class="text-left">FF</td>
-<td class="text-left">space</td>
-</tr>
-
-<tr>
-<td class="text-right">else</td>
-<td class="text-left"> </td>
-<td class="text-left">ordinary characters, same as in ASCII.</td>
-</tr>
-</tbody>
-</table>
-</div>
-</div>
-</div>
-<div id="outline-container-sec-12" class="outline-2">
-<h2 id="sec-12"><span class="section-number-2">12</span> Fifth commands</h2>
-<div class="outline-text-2" id="text-12">
-</div><div id="outline-container-sec-12-1" class="outline-3">
-<h3 id="sec-12-1"><span class="section-number-3">12.1</span> Compilation & miscellaneous</h3>
-<div class="outline-text-3" id="text-12-1">
-<p class="verse">
-init module ( – )<br >
-                First module, control is passed to on startup. Contains<br >
-                initialization routines. Also it is the last core module.<br >
-                All new modules on top of it comes as result of executing<br >
-                external source files.<br >
-<br >
-head <name> ( – ) compiles new dictionary entry without specifying<br >
-                new module type.<br >
-                ex: head myentry<br >
-<br >
-: <name> ( – ) creates new code module<br >
-; ( – ) ends module (immideate)<br >
-                ex: : hello ." hi there" ;<br >
-<br >
-const <name> ( n – ) defines new constant.<br >
-                ex: 2147483647 const max<br >
-<br >
-:i <name> ( – ) same as ":" but this module will be executed<br >
-                immideately even in compile mode.<br >
-                ex: :i ( 41 scan ;<br >
-<br >
-create <name> ( – ) same as "head" , but specify module type as data.<br >
-                ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 ,<br >
-<br >
-allot ( n – ) allocate n bytes in dictionary.<br >
-                ex: create MyArray 100 allot<br >
-<br >
-" <string>" ( – ) compile string and its size into core.<br >
-                ex: create Mystring " This is it's contects"<br >
-<br >
-str <name> <string>" ( – ) just shorter way for defining strings.<br >
-                ex: str Mystring This is it's contenc"<br >
-<br >
-var <name> ( – ) define new 32 bit variable.<br >
-                ex: var result<br >
-<br >
-' <module> ( – n ) return memory address of given entry.<br >
-                ex: ' init<br >
-<br >
-forget <name> ( – ) erases from RAM given entry and all entries what was<br >
-                defined after it.<br >
-                ex: forget myprog<br >
-<br >
-[ ( – ) set interpret mode (immideate)<br >
-] ( n – ) set compile mode and compile top stack element<br >
-                in as literal. Together [ …. ] cobination provides good<br >
-                way to compute some values only once, at compile time,<br >
-                rather than every time while program is running.<br >
-                ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ;<br >
-<br >
-defer <name> ( – ) creates new module, with jump instruction.<br >
-                Later address where to jump can be modified by "is" command.<br >
-                This provides method of foward referencing. So you can use<br >
-                modules what not jet exist.<br >
-is ( address1 address2 – ) address1 - where to jump, address2 -<br >
-                address of module created by defer command.<br >
-                ex: defer dispver<br >
-                        : run dispver ." running …" ;<br >
-                               … whatever …<br >
-                        : (dispver ." Version 9.99 " ;<br >
-                        ' (dispver ' dispver is<br >
-<br >
-                Now if I type "run" on the screen appears:<br >
-                        Version 9.99 running …<br >
-<br >
-asc <char> ( – ) reads char ascii code and treats it as literal.<br >
-                (immideate)<br >
-                ex: : BreakLine 30 do asc - emit loop ;<br >
-                                 same as:<br >
-                    : BreakLine 30 do 45 emit loop ;<br >
-<br >
-dyninc ( handle – ) execute code in dynamic memory handle.<br >
-                automatically deallocates it when done.<br >
-<br >
-include ( filenumber – ) execute code in specified file.<br >
-<br >
-words ( – ) display existing blocks in core.<br >
-<br >
-bye ( – ) exit from Fifth<br >
-<br >
-fkey ( – c )<br >
-                Read one byte from input stream.<br >
-<br >
-sadd ( c addr – )<br >
-                Add one byte "c" to string located at "addr" and updates<br >
-                string length.<br >
-<br >
-scan ( c – )<br >
-                Read input stream and store it to pad until it finds c .<br >
-                It ignores all "c" bytes until it finds any non "c" byte.<br >
-                in other words:<br >
-                                c is: "<br >
-                         input stream: """"This is test !"aoeu idh<br >
-                               result: This is test !<br >
-<br >
-                Is useful for breaking text lines into words.<br >
-<br >
-skey ( – c )<br >
-                So called safe "fkey". Reads data from input stream<br >
-                but converts characters with ASCII codes: 9 13 10<br >
-                to spaces.<br >
-<br >
-str=str? ( adr1 adr2 – result )<br >
-                Compares string at "adr1" with string at "adr2", returns<br >
-                true flag if they are equal or false if they are not.<br >
-                true = -1<br >
-                false = 0<br >
-<br >
-find ( – addr )<br >
-                Searches whole dictionary for word in "pad". If found,<br >
-                returns it address, if not, returns 0.<br >
-<br >
-execute ( – )<br >
-                Execute word located in "pad". Depending on "mode".<br >
-<br >
-dta ( addr – DataAddr )<br >
-                Calculates address of dictionary entry data area, from<br >
-                entry point.<br >
-<br >
-2num ( – num result )<br >
-                Attempt to convert string located in "pad" into numeric<br >
-                value. If succeed returns number and true as result.<br >
-                If not, returns whatever and false as result.<br >
-<br >
-dadd ( addr length – )<br >
-                Add to dictionary data located at "addr", with specified<br >
-                length.<br >
-<br >
-lit ( n – )<br >
-                Act with number depending on "mode". When interpreting,<br >
-                leaves it in stack.<br >
-<br >
-<br >
-incmod ( addr – )<br >
-                Add to dictionary data located at "addr"+1 , length is taken<br >
-                from "addr".<br >
-<br >
-here ( – n )<br >
-                return "h" contents.<br >
-<br >
-mode var 8 bit<br >
-                Holds input stream parser operation mode.<br >
-                0 = interpreting<br >
-                1 = compiling<br >
-<br >
-pad var 128 bytes<br >
-                Holds temprorary strings.<br >
-<br >
-h var 32 bit<br >
-                Pointer to free byte in memory, always at the end of the<br >
-                dictionary. Each time when something is stored<br >
-                by "c," command, pointer is incareased.<br >
-<br >
-lp var 32 bit<br >
-                Pointer to last dictionary word. Each time when new word is<br >
-                compiled or erased by "forget", this pointer is updated.<br >
-<br >
-modulechk ( Dstr<filename> – ) check if module is loaded, if not<br >
-                immideately load it.<br >
-<br >
-ne ( entrydata entrytype – ) Compile new dictionary entry.<br >
-                It's name must be in "pad".<br >
-</p>