Page 1 of 1

Debugging GT1 code

Posted: 07 Dec 2018, 11:53
by wtlprnft
Hi there,
is there a possibility to debug compiled gtl code, without debugging all the vCPU staff?

thanks,
peter

Re: Debugging GT1 code

Posted: 07 Dec 2018, 17:39
by marcelk
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...

Re: Debugging GT1 code

Posted: 08 Dec 2018, 11:49
by marcelk
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!