+++ /dev/null
-<html><head><title>FIFTH</title></head>\r
-<body>\r
-\r
-<pre>\r
-\r
- <h2>Emulator & virtual CPU</h2>\r
-\r
-\r
-\r
-Using CPU emulator slows it down but I shouldn't now\r
-think too mutch about, and waste my time on batteling with problems whitch\r
-results on complex design of PC hardware. Also it allows me to use existing DOS and\r
-resident drivers services in real mode. So I don't need to deal with\r
-hardware too mutch. It also allows me to use all free XMS for flat\r
-code & data storage.\r
-\r
-Current emulator emulates 1 CPU. It has 2 stacks,\r
-~50 instructions, and 4GB flat address space (theoretically).\r
-I'm not sure that DOS 6.22 that I currently prefer can handle more than\r
-64 MB of RAM. While I tried to keep instructionset simple,\r
-I was forced to put in lot of complex instructions to make it's performance\r
-acceptable on emulator. On actual silicon ~20 instructions is enaugh\r
-(I think).\r
-\r
-Maybe one day similar system will run directly on custom silicon chip :)\r
-\r
-\r
-CPU has following registers:\r
-\r
-IP - instruction pointer\r
-DSP - data stack pointer\r
-RSP - return stack pointer\r
-\r
-Virtual CPU, commands (most of them are avaiable as ordinary commands in\r
-programming lanquage):\r
-\r
-code mnemonic description\r
-\r
-0 nop does notheing\r
-1 halt halt CPU ( return to DOS on emulator )\r
-\r
-2 kbd@ ( -- c ) read scancode of pressed or released key.\r
- Returns 0, if no data avaiable. \r
-3 num <dword> ( -- n ) put immidiate number into datastack\r
-\r
-4 jmp <dword> jump to specified code\r
-5 call <dword>jump to specified code, save return address to\r
- return stack.\r
-\r
-6 1+ ( n -- n+1 )\r
-7 1- ( n -- n-1 )\r
-\r
-8 dup ( n -- n n ) duplicate top of data stack\r
-9 drop ( n -- ) drop last element in data stack\r
-\r
-10 if <dword> ( n -- ) jump to addr if top element was 0\r
-11 ret jump to code, specified in return stack.\r
-\r
-12 c@ ( addr -- n ) read byte from memory at specified address\r
-13 c! ( n addr -- ) store byte to specified memory\r
-\r
-14 push ( DSTK -> RSTK ) move top of datastack to returnstack\r
-15 pop ( RSTK -> DSTK ) move top of returnstack to datastack\r
-\r
-16 <unused>\r
-17 rot ( n1 n2 n3 -- n2 n3 n1) rotate stack elements\r
-\r
-18 disk@ ( FromDiskSect ToMem -- ) read 1KB from disk into RAM\r
-19 disk! ( FromMem ToDiskSect -- ) write 1KB to disk\r
-\r
-20 @ ( addr -- n ) read 32 bit number from memory\r
-21 ! ( n addr -- ) store 32 bit number to memory\r
-\r
-22 over ( n1 n2 -- n1 n2 n1 ) self explaining ...\r
-23 swap ( n1 n2 -- n2 n1 ) -,,-\r
-\r
-24 + ( n1 n2 -- n1+n2 ) -,,-\r
-25 - ( n1 n2 -- n1-n2 ) -,,-\r
-\r
-26 * ( n1 n2 -- n1*n2 ) -,,-\r
-27 / ( n1 n2 -- n1/n2 ) -,,-\r
-\r
-28 > ( n1 n2 -- result ) is true when n1 > n2\r
-29 < ( n1 n2 -- result ) is true when n1 < n2\r
-\r
-30 not ( n1 -- not_n1 ) logical not\r
-31 i ( -- n ) copies top of return stack into datastack\r
-\r
-32 cprt@ ( addr -- n ) read one byte from hardware port\r
-33 cprt! ( n addr -- ) store one byte to hardware port\r
-\r
-34 i2 ( -- n ) like "i" but takes socond top stack element.\r
-35 i3 ( -- n ) like "i" but takes third top stack element.\r
-\r
-36 shl ( n amount -- n ) left bit shift\r
-37 shr ( n amount -- n ) right bit shift\r
-\r
-38 or ( n1 n2 -- n ) logical or\r
-39 xor ( n1 n2 -- n ) exclusive logical or\r
- \r
-40 vidmap ( addr -- ) copy memory from "addr" to video memory.\r
-\r
-41 mouse@ ( -- x y button ) read mouse coordinates & buttons\r
-\r
-42 vidput ( addr1 addr2 x y -- ) put image1 into image2, at\r
- location x, y. Does clipping, so part of a big image\r
- can be mapped into smaller one.\r
-\r
-43 cmove ( addr1 addr2 amount ) move memory from addr1 to addr2\r
- if addr1 is greater than addr2 then count address\r
- foward while moving, elseway starts from end and\r
- counts backwards, so no data loss will occure on\r
- overlapping.\r
-\r
-44 cfill ( c addr amount -- ) fill memory starting at "addr"\r
- with "c" bytes.\r
-\r
-45 tvidput ( addr1 addr2 x y -- ) same as "vidput" but treats\r
- color 255 in source image as transparent.\r
-\r
-46 depth ( -- depth ) returns current depth of data stack.\r
-\r
-47 charput ( colorfg colorbg addrsrc addrdest x y )\r
- draw character to image buffer located at "addrdest"\r
- to specified x & y location. Decodes 8 bytes from\r
- source to bits, used to draw character.\r
-\r
-</pre>\r
-</body>\r
-</html>
\ No newline at end of file