How to generate symbol table?

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
rocky
Posts: 1
Joined: 27 May 2018, 16:57

How to generate symbol table?

Post by rocky »

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.
at67
Posts: 384
Joined: 14 May 2018, 08:29

Re: How to generate symbol table?

Post by at67 »

rocky wrote: 30 May 2018, 02:23 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.
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
You can now build any "gcl" file within the "gcl" directory by typing the following at a command prompt within the
"gcl" directory:

e.g. "make test.gcl" this will build "test.gt1" assuming no errors.
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: How to generate symbol table?

Post by marcelk »

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:

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
--------------------------------
Blinky should be the best entry into GCL hacking:

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]
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.
User avatar
phanyec
Posts: 1
Joined: 25 Aug 2021, 06:07

Re: How to generate symbol table?

Post by phanyec »

There are good programs that allow you to integrate files and translate them into other systems. Every year the amount of data in various databases is growing exponentially - this factor determines the intensive growth of interest in Big Data. Today Google BigQuery cloud database is one of the most popular tools for solving the problem of storing and quickly processing large amounts of data. And to work in the new database I had to connect google sheets to bigquery. I did not succeed the first time, but I am satisfied with the result. I am sure you have some instructions in the integrated system.
Post Reply