X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=doc%2Findex.html;h=107188f06f40ef3c9565b68dc1c9f0aacb774b34;hb=be12874c4742b31507e81536b80db7de4b800d24;hp=d367d2a5c25d534f79f88670af8d54c9205e80ca;hpb=1bfb3ff178c78561252ef705b9aad2857a95e424;p=fifth.git diff --git a/doc/index.html b/doc/index.html index d367d2a..107188f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1,255 +1,396 @@ - - + + + + + + Fifth - virtual machine, operating system, programming language - - - - - - - -" + + - + - - + -
-

Fifth - virtual machine, operating system, programming language

-
-
    -
  • download latest snapshot +
    +

    Fifth - virtual machine, operating system, programming language

    +
    +

    Table of Contents

    +
    +
    +
    -
    -

    1 !Project deprecated!

    +
    +

    1 General

    + +
    +
    +

    1.1 Source code

    +
    + +
    +
    +
    + +
    +

    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 +399,7 @@ require reimplementation of everything.

    Currently I try to implement those new ideas in the project called -Sixth +Sixth.

    @@ -267,41 +408,63 @@ 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 +Fifth is programming lanquage & operating system, running on virtual +machine, 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.

    + +
    +
    +

    3.1 screenshots

    +
    +
    +

    start.png +

    +

    -Screenshots +Startup screen diplaying Fifth logo and full file list.

    + +
    +

    dictionary.png +

    +
    +

    -Read more about: +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. +

    + + + + + +

    +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 +473,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 ? +

    -
    -

    numbers.png +

    +Here alternative hexadecimal number representation format is devised: +

    + + +
    +

    numbers.png +

    +
    + +

    +Essentially square is split into 4 triangles. Each triangle represents +one bit.

    -

    -Because I can define everything, starting from CPU, why not try also -alternative and unique number representation ? +Fifth uses this hexadecimal format as primary throughout entire +system.

    -Fifth uses its hexdecimal number representation as primary. Numbers -shape is formed by dividing a square into four parts. And manipulating -their color (black or white). +See also: Bibi-binary.

    -
    -

    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

    +
    +
    -+-+-+ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
    offsetlengthdescriptionoffsetlengthdescription
    0~4 KbFifth core0~4 KbFifth core
    4 Kb~32Kbhigh-level boot code4 Kb~32 Kbhigh-level boot code
    37 Kb~65KbFAT37 Kb~65 KbFAT
    101Kb~16MBfilesystem data area101 Kb~16 MBfilesystem data area
    -
    -

    6.2 FAT entry format:

    -
    - +
    +

    8.2 FAT entry format:

    +
    +
    -+-+ - - + + - - + + - - + + - - + +
    codemeaningcodemeaning
    -2last sector-2last sector
    -1empty sector-1empty sector
    0 --.. pointer to next block0 --.. pointer to next block
    -
    -

    6.3 file entry format

    -
    - +
    +

    8.3 File entry format

    +
    +
    -+-+-+ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
    offsetlengthdescriptionoffsetlengthdescription
    04extension04extension
    416name416name
    204entry point204entry point
    244size244size
    284last modification time284last 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 +739,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

    +
    +
    -+-+-+ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
    offsetlengthdescriptionoffsetlengthdescription
    040 < previous entry040 < previous entry
      0 = last  0 = last
      -1 = empty  -1 = empty
    415module name string415module name string
    191entry type191entry type
    204entry data204entry data
    @@ -615,114 +808,603 @@ run through headers backwards and find needed entry.

    -
    -

    7.2 Possible module types

    -
    - +
    +

    9.2 Possible module types

    +
    +
    -+-+-+ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
    typedescription"execute" actiontypedescription"execute" action
    0datacompile "num" instruction0datacompile "num" instruction
      with address to module  with address to module
    1submodulecompile "call" instruction1submodulecompile "call" instruction
      with address to module  with address to module
    2imm. submoduleimmediately call to module2imm. submoduleimmediately call to module
    -
    -

    7.3 Memory map: (average)

    -
    - +
    +

    9.3 Memory map

    +
    +
    -+-+-+ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
    <loc><size><desc>locationsizedescription
    0~4096core0~4096core
    1500000~32000highlevel Fifth boot code1500000~32000highlevel Fifth boot code
    200000h core startup messages area200000h core startup messages area
    5200000 end of dynamic memory space5200000 end of dynamic memory space
    -
    -

    8 Fifth source format

    -
    +
    +

    10 Virtual machine

    +
    +

    +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. +

    + +

    +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). +

    + +

    +Maybe one day similar system will run directly on custom silicon chip :) +

    + + +

    +CPU has following registers: +

    + + + +++ ++ + + + + + + + + + + + + + + + + +
    IPinstruction pointer
    DSPdata stack pointer
    RSPreturn stack pointer
    +
    +
    +

    10.1 instruction set

    +
    +
    +
    +

    10.1.1 overview table

    +
    +

    +Virtual CPU, commands (most of them are avaiable as ordinary commands +in programming language): +

    + + + + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #namestack footprintdescription
    0nop--does nothing
    1halt--halt CPU ( return to DOS on emulator )
    2kbd@– cread scancode of pressed or released key
    3num <dword>– nput immidiate number into datastack
    4jmp <dword>--jump to specified code
    5call <dword> jump to specified code, save return address to return stack
    61+n – n+1 
    71-n – n-1 
    8dupn – n nduplicate top of data stack
    9dropn --drop last element in data stack
    10if <dword>n --jump to addr if top element was 0
    11ret jump to code, specified in return stack.
    12c@addr – nread byte from memory at specified address
    13c!n addr --store byte to specified memory
    14pushDSTK -> RSTKmove top of datastack to returnstack
    15popRSTK -> DSTKmove top of returnstack to datastack
    16<unused>  
    17rotn1 n2 n3 – n2 n3 n1rotate stack elements
    18disk@FromDiskSect ToMem --read 1KB from disk into RAM
    19disk!FromMem ToDiskSect --write 1KB to disk
    20@addr – nread 32 bit number from memory
    21!n addr --store 32 bit number to memory
    22overn1 n2 – n1 n2 n1 
    23swapn1 n2 – n2 n1 
    24+n1 n2 – n1+n2 
    25-n1 n2 – n1-n2 
    26*n1 n2 – n1*n2 
    27/n1 n2 – n1/n2 
    28>n1 n2 – resultis true when n1 > n2
    29<n1 n2 – resultis true when n1 < n2
    30notn1 – not_n1logical not
    31i– ncopies top of return stack into datastack
    32cprt@addr – nread one byte from hardware port
    33cprt!n addr --store one byte to hardware port
    34i2– nlike "i" but takes second top stack element
    35i3– nlike "i" but takes third top stack element.
    36shln amount – nleft bit shift
    37shrn amount – nright bit shift
    38orn1 n2 – nlogical or
    39xorn1 n2 – nexclusive logical or
    40vidmapaddr --copy memory from "addr" to video memory.
    41mouse@– x y buttonread mouse coordinates & buttons
    42vidputaddr1 addr2 x y --put image1 into image2, at location x, y
    43cmoveaddr1 addr2 amountmove memory from addr1 to addr2
    44cfillc addr amount --fill memory starting at "addr" with "c" bytes.
    45tvidputaddr1 addr2 x y --put image with transparency support
    46depth– depthreturns current depth of data stack.
    47charputcolorfg colorbg addrsrc addrdest x ydraw text character
    +
    +
    + +
    +

    10.1.2 kbd@ - read scancode of pressed or released key

    +
    +

    +Returns 0 if no data available. +

    +
    +
    +
    +

    10.1.3 vidput - put image1 into image2, at location x, y

    +
    +

    +Does clipping, so part of a big image can be mapped into smaller one. +

    +
    +
    +
    +

    10.1.4 cmove - copy memory array

    +
    +

    +Move memory from addr1 to addr2. If addr1 is greater than addr2 then +count address foward while moving, elseway starts from end and counts +backwards, so no data loss occurs when memory regions partially +overlap. +

    +
    +
    +
    +

    10.1.5 tvidput - put image with transparency support

    +
    +

    +Stack footprint +

    +
    +addr1 addr2 x y --
    +
    + + +

    +Put image1 into image2, at location x, y with transparency support +

    + +

    +Color 255 in source image is treated as transparent. +

    +
    +
    +
    +

    10.1.6 charput - draw text character

    +
    +

    +Draw character to image buffer located at "addrdest" to specified x & +y location. Decodes 8 bytes from source to bits, used to draw +character. +

    +
    +
    +
    +
    + +
    +

    11 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 @@ -732,109 +1414,785 @@ numeric values. So typical nemric characters "0123…" is treated like ordinary letters.

    -
    -

    8.1 FSCII:

    -
    - +
    +

    11.1 FSCII

    +
    +
    -+-+-+ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
    DECHEXfunctionDECHEXfunction
    0 - 150 - FHEX numbers0 - 150 - FHEX numbers
    252FCbackspace252FCbackspace
    253FDtabulator (TAB)253FDtabulator (TAB)
    254FEcarriage return (CR)254FEcarriage return (CR)
    255FFspace255FFspace
    else ordinary characters, same as in ASCII.else ordinary characters, same as in ASCII.
    -
    -
    -