vCPU from ROM (or chained SYS functions)

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
Post Reply
User avatar
DavidHK
Posts: 28
Joined: 25 Aug 2019, 12:59

vCPU from ROM (or chained SYS functions)

Post by DavidHK » 20 Sep 2019, 16:40

I stumbled over this issue on Github for running vCPU programs directly from ROM: https://github.com/kervinck/gigatron-rom/issues/83

I was pondering about it a while now and I've had questions as to how to handle the program counter and such. One solution might be to add another interpreter, but I was looking for other solutions.

One idea I had was to build chained application specific SYS functions. You would need an assembler that enforces that each block of native code takes a constant amount of cycles (so only very special jump instructions would be allowed). Each of such fixed blocks would be an application specific SYS function and they can chain to the next one by putting its address in the "sysFn" variable. In theory this should only require the RAM for the single syscall instruction. To be able to call "normal" SYS functions a bit more RAM would be needed, maybe something like this in vCPU assembler code (9 bytes if I counted correctly):

Code: Select all

SYS [external fn time]
LDWI [next chain fn address]
STW $22 ; set "sysFn"
SYS [next chained time]
This vCPU code would be modified each time a regular SYS function is called.

This would not allow directly using existing vCPU code, but I am not sure that is possible anyway as the memory map would be completely different between RAM and ROM.

But so far these are just wild thoughts that I wanted to pin down publicly, not something I intend to use very soon.

User avatar
marcelk
Posts: 349
Joined: 13 May 2018, 08:26

Re: vCPU from ROM (or chained SYS functions)

Post by marcelk » 21 Sep 2019, 06:24

I haven't figured it out yet either. A good application for such a capability will be to host the set of functions for SDC/MMC card loading: for it to load GT1 files anywhere in RAM without true restrictions. On the other hand, with 64K or 128K RAM, this may not be much of an issue. In 32K such a loader tends to get in the way.

Post Reply