Debugging GT1 code

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
Post Reply
wtlprnft
Posts: 2
Joined: 28 Nov 2018, 20:21

Debugging GT1 code

Post by wtlprnft » 07 Dec 2018, 11:53

Hi there,
is there a possibility to debug compiled gtl code, without debugging all the vCPU staff?

thanks,
peter

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

Re: Debugging GT1 code

Post by marcelk » 07 Dec 2018, 17:39

I debug in my head. Sometimes I instrument code, e.g. place values in screen RAM. But Gigatron programs are small and I rarely find a need for such instrumentation. I build them up from small parts that are easy to verify and then modify and extend. I rely heavily on git to checkpoint stable intermediate revisions. Testing is in one of the emulators first.

Having said that, my typical bugs with vCPU code are:
- Forgetting RET at the end of a function block
- Calling functions from a leaf function (so: forgetting PUSH and POP in functions that use CALL)

My typical GCL-specific bugs are:
- Forgetting that all named variables are global, "i" and "j" included...
- Calling a function before having reached the last page, while also using "vLR hopping" as setup mechanism
- Misspelling a variable (Tip: inspect the symbol table output for lookalikes)
- Renaming a function, but not where it is called (this can also be spotted with the symbol table)

There's one common issue that comes back in vASM programs, and that is that they tend to place constants in the top of the zero page. This happens to work in the emulators and when loading GT1 files with the Loader. But it doesn't work anymore when you move the GT1 image in the EPROM and use the ROM loader. The solution is simple: don't put constants in the 0xc0..0xff area. The stack lives there and it must be allowed to breathe...

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

Re: Debugging GT1 code

Post by marcelk » 08 Dec 2018, 11:49

I should add: if anyone has some code that doesn't work as expected, please don't hesitate to share it here on the forum!

Post Reply