Fifth - virtual machine, operating system, programming language
--
-
-
- download latest snapshot
++
Fifth - virtual machine, operating system, programming language
++-Table of Contents
+++-
+
- 1. General + - -
- This program is free software; you can redistribute it and/or modify it under -the terms of version 3 of the GNU Lesser General Public License or later as -published by the Free Software Foundation. +
- 2. !Project deprecated! +
- 3. Introduction + - -
- Program author:
-
-
-
- Svjatoslav Agejenko +
- 4. Installation +
- 5. Fifth distribution directory tree description +
- 6. Requirements + -
- Homepage: http://svjatoslav.eu +
- 7. Numbers representation within Fifth +
- 8. Disk file map, and it's data structures + -
- Email: mailto://svjatoslav@svjatoslav.eu +
- 9. Core architecture + +
- 10. Dynamically loadable modules +
-1 !Project deprecated!
+++ +1. General
++ +-
+
- This program is free software: released under Creative Commons Zero +(CC0) license + +
- Program author:
+
-
+
- Svjatoslav Agejenko +
- Homepage: https://svjatoslav.eu +
- Email: mailto://svjatoslav@svjatoslav.eu +
+
+ - Other software projects hosted at svjatoslav.eu +
++1.1. Source code
+++-
+
- Download latest snapshot in TAR GZ format + +
- Browse Git repository online + +
+Clone Git repository using command: +
++git clone https://www2.svjatoslav.eu/git/fifth.git +
+
+-2. !Project deprecated!
+Current implementation does not support object oriented programming. While working on Fifth I got lots of cool new ideas that @@ -258,7 +323,7 @@ require reimplementation of everything.
Currently I try to implement those new ideas in the project called -Sixth +Sixth.
@@ -267,41 +332,61 @@ operating system.
-2 Introduction
-++3. Introduction
+-Fifth is programming lanquage & operating system, running on virtual -CPU, with custom instruction set. It is much like Charles Chunk -Moore's Forth, it also uses stack architecture, and many commands are -similar. Basically I got familiar with concepts of Forth, and being -inspired created my own system. +Fifth is a combination of:
+-
+
- Programming language (inspired by Forth). +
- Operating system. +
- Virtual machine with custom instruction set. +
- Example Fifth source file - text editor +
+-3.1. screenshots
+++++
++Startup screen diplaying Fifth logo and full file list. +
+ + +++
+-Screenshots +Sample words defined. Most of the words are commands that can be +executed interactively from command line or from file. When executed +they can be selectively compiled or interpreted.
+ + ++++
+-Read more about: +Built in text editor.
--3 Installation
-++ ++-4. Installation
+Just unpack all files, witout altering original directory structure, somewhere in your hard disk. For example: C:\MISC\FIFTH\…. To run @@ -310,231 +395,261 @@ or EMULATOR.COM ), and virtual disk file ( DISK.RAW ).
-Read more about distribution directory layout +Read more about Fifth distribution directory tree description.
-4 Software/Hardware/Human requirements
---4.1 Software:
-+ +++ +5. Fifth distribution directory tree description
++++After downloading and unpacking the ZIP file you shoud get directory +tree similar to this: +
+ ++DOC - Fifth documentation
+
+ commands - documentation on Fifth built-in commands
+ modules - documentation on additional commands, realized as loadable modules
+ shots - Fifth screenshots
+
+imageFile - files contained within 'disk.raw', just an extracted form.
+
+source - source files
+ emulator - emulator source
+ util - utilites
+
+disk.raw - Virtual disk file, has filesystem inside.
+emulator.com - main executable.
++6. Requirements
++++-6.1. Software
+-
-
- MS-DOS 6.22, with HIMEM.SYS loaded. - -
- Mouse driver if you have a mouse. - -
- Does work only when CPU is in real mode. - -
- To recompile ASM sources I used FASM (Flat Assembler). - -
- I ran QBasic utilities on QB 4.5 . - -
- VESA support by BIOS, or external driver (UNIVBE). - +
- MS-DOS 6.22, with HIMEM.SYS loaded. +
- Mouse driver if you have a mouse. +
- Does work only when CPU is in real mode. +
- To recompile ASM sources I used FASM (Flat Assembler). +
- I ran QBasic utilities on QB 4.5 . +
- VESA support by BIOS, or external driver (UNIVBE).
-4.2 Hardware:
-++-6.2. Hardware
+-
-
- Minimum CPU 386. - -
- 64 KB free RAM below 640KB, - -
- 2 MB of free XMS. - -
- VESA compatible video card. - +
- Minimum CPU 386. +
- 64 KB free RAM below 640KB, +
- 2 MB of free XMS. +
- VESA compatible video card.
-4.3 Human:
-+-+6.3. Human
+-
-
- Beginner level Forth knowledge is recommended. - -
- Lots of enthusiasm. - +
- Beginner level Forth knowledge is recommended. +
- Lots of enthusiasm.
-5 Numbers representation
-++-7. Numbers representation within Fifth
+++Because we are in full experimentation mode here (no regard for +compatibility whatsoever), why not to try also alternative number +representation ? +
--6 Disk file map, and it's data structures
-+ ++8. Disk file map, and it's data structures
+Core and high-level boot code is stored outside of the filesystem to allow easy access to it, at early booting time, when filesystem is not yet initialized.
-6.1 disk allocation
--+
+-8.1. Disk allocation
++- + - + - + - offset -length -description +offset +length +description - 0 -~4 Kb -Fifth core +0 +~4 Kb +Fifth core - 4 Kb -~32Kb -high-level boot code +4 Kb +~32 Kb +high-level boot code - 37 Kb -~65Kb -FAT +37 Kb +~65 Kb +FAT - 101Kb -~16MB -filesystem data area +101 Kb +~16 MB +filesystem data area -6.2 FAT entry format:
--+
+-8.2. FAT entry format:
++- + - + - code -meaning +code +meaning - -2 -last sector +-2 +last sector - -1 -empty sector +-1 +empty sector - 0 -- -.. pointer to next block +0 -- +.. pointer to next block -6.3 file entry format
--+
+-8.3. File entry format
++- + - + - + - offset -length -description +offset +length +description - 0 -4 -extension +0 +4 +extension - 4 -16 -name +4 +16 +name - 20 -4 -entry point +20 +4 +entry point - 24 -4 -size +24 +4 +size - 28 -4 -last modification time +28 +4 +last modification time -7 Core architecture
-++9. Core architecture
+Fifth core is simply some amount of already compiled into machine code and linked together modules (entries in other words). In compilation @@ -546,64 +661,64 @@ dictionary space only. Random word can be removed from dictionary at any time. Currently dictionary can contain at most 1000 entries.
-7.1 dictionary entry format
--+
+-9.1. Dictionary entry format
++- + - + - + - offset -length -description +offset +length +description - 0 -4 -0 < previous entry +0 +4 +0 < previous entry - 0 = last +0 = last - -1 = empty +-1 = empty - 4 -15 -module name string +4 +15 +module name string - 19 -1 -entry type +19 +1 +entry type - 20 -4 -entry data +20 +4 +entry data -7.2 Possible module types
--+
+-9.2. Possible module types
++- + - + - + - type -description -"execute" action +type +description +"execute" action - 0 -data -compile "num" instruction +0 +data +compile "num" instruction - with address to module +with address to module - 1 -submodule -compile "call" instruction +1 +submodule +compile "call" instruction - with address to module +with address to module - 2 -imm. submodule -immediately call to module +2 +imm. submodule +immediately call to module -7.3 Memory map: (average)
--+
+-9.3. Memory map
++- + - + - + - <loc> -<size> -<desc> +location +size +description - 0 -~4096 -core +0 +~4096 +core - 1500000 -~32000 -highlevel Fifth boot code +1500000 +~32000 +highlevel Fifth boot code - 200000h -core startup messages area +200000h +core startup messages area - 5200000 -end of dynamic memory space +5200000 +end of dynamic memory space -8 Fifth source format
---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. +
+-10. Dynamically loadable modules
++++10.1. Keyboard driver
++-+
+KBD_@ ( – code ) get scancodes for pressed keys from keyboard.
+KBD_down? ( key – result ) check is key with specified scancode
+ currently pressed down.
+KBD_SC2FSCII ( code – FSCII ) convert key scancode into FSCII code,
+ or in FSK (Fifth standard keycode).
+KBD_F@ ( – FSCII ) read pressed key FSCII or FSK, returns -1 if no
+ keys are pressed.
+KBD_FW@ ( – FSCII ) read pressed key FSCII or FSK, if no keys is
+ are pressed then waits until there is.
+
+ FSK
+ —
+In HEX.
+
+FC backspace
+FD TAB
+FE enter
+FF space
+
+400 ESC
+401 … F1 …
+410 up
+411 right
+412 down
+413 left
+414 INS
+415 DEL
+416 home
+417 end
+418 PG/UP
+419 PG/DN
-8.1 FSCII:
---- - -
+- + + ++10.2. Mouse driver
++++mousex var Mouse x coordinate.
+
+mousey var Mouse y coordinate.
+mousekeyl var Mouse left key.
+mousekeym var Mouse middle key.
+mousekeyr var Mouse right key.
+mousec var Display current mouse coordinates in top left part of screen,
+ if true. (good for debugging)
+mousepointer var Image buffer, holding current mouse pointer.
+mouseadd ( ModuleAddr x1 x2 y1 y2 – ) Add specified area on screen,
+ into mause click buffer. If any mouse button is clicked on
+ that area, module at "ModuleAddr" will be executed.
+mousebe var Amount of buffer elements.
+mousedo ( – ) Updates mouse coordinates and keys. Parse mouse
+ click buffer, and draw mouse cursor to "screen".
++10.3. 2D graphic library
++-
+
- lineh ( color len x y imgbuf – )
- draws horisontal line from X,Y +coordinates to right, with specified length. -
- linev ( color len x y imgbuf – )
- draws vertical line down, from +coordinates X,Y, with specified length. -
- box ( color x2 x1 y2 y1 imgbuf – )
+draws rectangular box. x2 +bust be >= x1, y2 must be >= y1. +
-- +252 -FC -backspace -+x1,y1-----------+ + | | + | | + +-----------x2,y2 +
-- flipv ( imgbuf – )
- flip image vertically. -
- imgcoltrans ( ImgBuf Color ToColor – )
- Translate all pixels in +specified image with "Color" into "ToColor". -
- imgfill ( color x y imgbuf – )
- Fill image region starting at +location X & Y with specified color. + + + -
+ - - - - - - -DEC -HEX -function -- +0 - 15 -0 - F -HEX numbers -- +253 -FD -tabulator (TAB) -- +254 -FE -carriage return (CR) -- +255 -FF -space -- - -else -ordinary characters, same as in ASCII. -+10.4. Trigonometry functions
+++++10.4.1. sin ( a – result )
++++Return sinus from given angle "a", 360ø is 2000. So 1000 represents +180ø angle. Result will be in range -10'000 to 10'000, instead of ñ1. +
++10.4.2. cos ( a – result )
+++Return cosinus from given angle. Parameters are like in sin function. +
+-