I'm struggling a bit to get started writing code for the vCPU. I think it would go a long way to show a small example of how a small GCL program is written and built to produce the gt1 file perhaps as a bash script.
Edit:
OK, I poked around a bit more and realized I somehow missed the Makefile in the root. I guess I was too caught up looking at stuff in Contrib and Core only. oops. I think I'm good now.
How to generate symbol table?
Forum rules
Be nice. No drama.
Be nice. No drama.
Re: How to generate symbol table?
Under windows I struggled with this for a while as well, I was going to write a quick howto, but instead of doing that I'll just add what I did to this thread if you don't mind.
Code: Select all
This assumes that you have already cloned or downloaded the gigatron-rom repo.
1) You must install a 2.7 version of Python, (I used 2.7.13), any of the 3.x versions will not work and you will need to
modify the build/compile Python source, (not recommended as it is constantly being updated).
2) Do NOT do any of this under the Windows PowerShell, it won't work and you will get nonsensical errors, (I don't
know why and I am really not interested, this one had me stumped for a few hours), use a normal command prompt.
3) I created a new directory named "gcl" within "gigatron-rom" and then a "build" directory within "gcl"; the reason
for this is that Python seems to go a little silly with the creation of temporary/random directories.
4) I copied "asm.py", "compilegcl.py" and "gcl0x.py" into the new "gcl\build" directory.
5) I then created the ROM Symbol Table, change directory to your main gigatron-rom installation and either
"make theloop.2.rom" or run the following command line:
- python Core/theloop.py Apps/Snake.gcl Apps/Racer.gcl Apps/Mandelbrot.gcl Apps/Pictures.gcl
Apps/Credits.gcl Apps/Loader.gcl Apps/Screen.gcl Apps/Main.gcl Core/Reset.gcl
- copy "theloop.sym" into "gcl\build"
- "gcl\build" should now contain "asm.py", "compilegcl.py", "gcl0x.py" and "theloop.sym"; if any of these .py files
are modified and you want your GCL build system to stay up to date, then you need to re-copy the new .py files.
6) Create a batch file "make.bat", (call it whatever you like as long as it has the bat extension), inside the "gcl"
directory and type/paste the following into the batch file:
- py build/compilegcl.py %1 build/theloop.sym
"gcl" directory:
e.g. "make test.gcl" this will build "test.gt1" assuming no errors.
Re: How to generate symbol table?
As another step towards disentanglement I've just retired the old symbol table (theloop.sym), which was created as a side-effect of building the ROM files. Instead, there is now a checked-in file, interface.json, that takes over its job. With this it should be easier to compile GCL programs directly to GT1. It should also make it a lot easier to identify potential compatibility problems when we make future ROM versions.
From the commit notes:
Blinky should be the best entry into GCL hacking:
As usual, I'm only able to test on my Mac. All Python is for version 2.7, not 3.x. I expect Linux to work practically the same. I'm completely blind for what has to happen in Windowsland.
From the commit notes:
Code: Select all
Introduce interface.json as bindings interface to ROM kernel
Programs that can be compiled this way:
- Apps/Blinky.gcl
- Apps/HelloWorld.gcl
- Apps/Snake.gcl
- Apps/Mandelbrot.gcl
- Apps/Credits.gcl
- Apps/Terminal.gcl
[ The other GCL programs have references that are not part of the
bindings interface, and they have to be compiled from within the ROM.]
Compiling a program:
--------------------------------
$ Core/compilegcl.py Apps/Blinky.gcl
Compiling file Apps/Blinky.gcl
Segment at 7f00 size 256 used 11 unused 245
Variables count 1 bytes 2 end 0032
Symbols p
Execute at 7f00
Create file Blinky.gt1
OK size 17
--------------------------------
Sending it to Gigatron:
--------------------------------
$ Utils/sendGt1.py Blinky.gt1
Connecting to /dev/tty.usbmodem1411
Resetting Gigatron
Starting Loader
Sending program 'Blinky.gt1'
...
Finished
--------------------------------
Code: Select all
{ Declare which GCL version we are using }
gcl0x
{
Set $7f00 as code destination (default is $0200)
This loads Blinky at the bottom of screen memory so we
can see the program after it has loaded
}
$7f00:
{
Setup a pointer to a pixel in the middle of the screen:
$4450 Loads a 16-bit value in the accumulator (vAC)
p= Writes vAC to variable p
Note: The pointer p is a 16-bit integer variable
The GCL compiler allocates an address for it in zero-page
}
$4450 p=
{
Execute the main loop:
[do Mark the beginning of a loop
p. Write vAC's low byte to the memory pointed by p
1+ Increment vAC by 1
loop] Loop forever
}
[do p. 1+ loop]