Page 1 of 1

Loaging GT1 programs to RAM

Posted: 22 May 2019, 08:02
by gesari
Hi,
I'm trying to use the ROM emulator to also load GT1 files directly to RAM and, while programs are actually loaded and run, I got lots of hangs and bad behavior, so there is something wrong.
This is my loading procedure:

- Stop the Gigatron while refreshing the video to be sure the vCPU emulator is not running.
- Copy the GT1 segments to their locations in RAM.
- Copy the starting address at RAM[0x16:0x17] (vPC)
- Reset RAM[0x1C]=0 (vSP)
- Continue the execution.

I guest some other things also need to be initialized (vLR?)... Any hint is welcome.

Re: Loaging GT1 programs to RAM

Posted: 22 May 2019, 09:22
by marcelk
Subtract 2 from the low byte of vPC, because vCPU pre-increments it by 2. Then place the same 16-bit value in vLR in order to be bug-compatible with Loader. That should work. The stack is already initialised after reset:

Code: Select all

              009a 0000  ld   $00
              009b c21c  st   [$1c]
It's simpler to replace Main with your own .gt1, and then build a ROM image with that. Instructions here.

Or just load the .gt1 file with Loader. That's what Loader does :-). Utils/sendFile.py uses that too.

Re: Loaging GT1 programs to RAM

Posted: 22 May 2019, 20:40
by gesari
The (vPC_low-2) was the problem. Thanks a lot!

I'll keep the stack pointer reset because it can have any value when the Gigatron stops and I'd like to get all the possible stack space for the GT1 program.