65VM02
Posted: Sun May 07, 2017 9:42 pm
Well, I've given some more thought to the subject of an upgrade on the 65c02. I've come up with a design for an upgraded 65c02 that accesses 128KB of memory and is specifically designed to support running a VM and a multi-tasking OS. Of course, I'm thinking of running Forth on the VM, but it should also support other languages, such as C, Pascal, etc.. Only the primitives would be written in assembly-language, and maybe some user-written CODE words, but most of the code would be in written in a high-level language. The byte-code is pretty compact, so I'm expecting maybe 16KB of byte-code and 8KB of machine-code to support the Forth system, the OS, and the application code, and the rest would all be RAM for the application data. That seems like a lot of RAM to me!
I told one engineer about this, and he said this:
"For current processors a sobering thought is to look at bill of materials cost for [what] a Cortex M0/M1 based systems would cost and what it would offer in terms of functionality."
That is a good point!
It is unclear who would be interested in an 8-bit processor in the 21st century, given the low cost of 32-bit processors with megabytes of memory --- William D. Mensch said that the original purpose of the 65c816 was to be low-power enough that it could run inside a human body, but I never heard of it actually being used for that --- I have read that the MSP430 is used in pacemakers.
Anyway, if anybody wants to read my document, I attached it. Here is a snippet:
--------------------------------------------------------------------------------------------
I told one engineer about this, and he said this:
"For current processors a sobering thought is to look at bill of materials cost for [what] a Cortex M0/M1 based systems would cost and what it would offer in terms of functionality."
That is a good point!
It is unclear who would be interested in an 8-bit processor in the 21st century, given the low cost of 32-bit processors with megabytes of memory --- William D. Mensch said that the original purpose of the 65c816 was to be low-power enough that it could run inside a human body, but I never heard of it actually being used for that --- I have read that the MSP430 is used in pacemakers.
Anyway, if anybody wants to read my document, I attached it. Here is a snippet:
--------------------------------------------------------------------------------------------
Code: Select all
This would be a full-sized configuration:
1.) The main-bank would have 8KB of non-volatile memory (upper memory) and 56KB of RAM.
2.) The alternate-bank would have 16KB of non-volatile memory and 48KB of RAM.
Most of the code would be byte-code generated by a compiler (Forth, C, Pascal, etc.) and stored in the alternate-bank.
There would not be very much machine-code --- all of this would be hand-written assembly-language --- 8KB is more than enough.
The RAM in the alternate-bank can be used for compiling byte-code at run-time, such as done in an interactive Forth system.
The RAM in the alternate-bank can also be used as a RAM-disk, such as for storing a file that comes in from a desktop-computer.
Having 56KB of application data in the main-bank allows programs to be big without the need for complicated bank-switching.
The 65VM02 does have bank-switching, but this is for the byte-code not the application data, so the user isn't really exposed to it.
All told, the worse thing about the 1980s was bank-switching application data on 65c02 and Z80 processors. Ugh!
The 65VM02 has these new registers:
IP 16-bit used by INA and OTA instructions for accessing the alternate-bank
D 8-bit page where the direct-page is located --- must be even --- set to $0 on start-up
T 1-bit this is the 65c02's empty niche in the P register now put to use as a task-switch flag
YA 16-bit this isn't a new register --- this is just the Y and A registers used as a pair (Y is low, A is high)
The direct-page and the return-stack are both relative to the D register page (in the 65c02 they were fixed at page zero and page one).
In a multi-tasking OS each task has its own direct-page and return-stack, determined by D.
It is worthwhile to rely heavily on the multi-tasker, rather than write a typical 65c02 program with one big complicated main program.
Most of the tasks will have all of their data in the direct-page, which is fast. Also, pointers have to be in the direct-page.
The tasks can communicate with each other using data-structures such as linked-lists that are in the heap.
These are the new instructions (none affect the flags unless explicitly described as doing so):
JVM page jump through the pointer located at (page*$100+A)
INA load A with (IP) in the alternate-bank, then increment IP
OTA store A into (IP) in the alternate-bank, then increment IP
EXIP exchange IP with YA
AIP #value add the signed value to IP
LLYA load YA with the address of the bottom value of the return-stack
AAS add A to S
BTC offset branch if the T flag is clear
EXCT exchange C and T flags
EXA adr exchange A with an 8-bit variable (at an absolute address, not a direct-page address)
EXAD exchange A and D
MUL multiply A by Y unsigned, leaving the product in YA
SGN sign-extend A into YA (set A to -1 or 0), setting the N and Z flags for the 16-bit result
TST test YA, setting the N and Z flags
EXX direct exchange X with the direct-page variable
ADY #value add the value to Y, setting the N Z V and C flags (in the same way as ADC does)