Trinity-11 / FoenixIDE

Development and Debugging Suite for the C256 Foenix Family of Computers
GNU General Public License v3.0
48 stars 14 forks source link

Unable to reliably run compiled code in Foenix IDE #20

Closed cratuki closed 2 years ago

cratuki commented 3 years ago

I think there is a bug in the current version of Foenix IDE 0.5.5.7, but I do not know enough of the internals to speculate what might be causing it. Below, I will describe a scenario that I run through. The usage below is pieced together from a combination of the c256 wiki and youtube videos.

// System setup

On Windows, I have the wdc compiler installed to c:\wdc.

This is the code I am running: https://pastebin.com/RZApyKRP

The pastebin above shows (1) source of the fxloader.asm; (2) a main.c which is taken from the wiki; (3) a build script b.bat.

// Use-case

These are the steps I follow, (1) In windows cmd, run b.bat. This produces main.hex (2) Start a fresh instance of Foenix IDE 0.5.5.7, which has "Settings > Autorun Emulator" enabled. (3) Press enter to go to the FMX repl/prompt. (4) In the Foenix IDE Debug window, press pause (5) In the Foenix IDE Display window, use "File > Open Hex File" and select the main.hex just created (6) In the Foenix IDE Debug window, enter 010000 to the jump address and press jump (7) In the Foenix IDE Debug, press run.

What I expect to happen: (1) I should get the letters HELLO printed out on the display. (2) Uncertainty about what should happen after the C code finishes (see note below, "Further query")

What happens on my system: (1) After I press run (once), it does not keep running but pauses again. (2) If I press Run a second time, it keeps running. In both cases, I see nothing show to the display. (3) When I press "Reset > Restart" in the Foenix IDE, the display changes, and I see HELLO in red at the top, with the vertical parts of the border gone. At this point, the debug system pauses again.

Further query: after the C program is finished, should the user be returned to a working REPL? I read somewhere that if you finish an assembly program with BRK/BRK, then this happens. What would need to happen in the C sample program that would deliver the same result?

cratuki commented 3 years ago

Further note, if anyone reading this issue has write access to the c256 wiki, I recommend changing the page at https://wiki.c256foenix.com/index.php?title=C-compiler_use to refer to the fxloader.asm code at https://wiki.c256foenix.com/index.php?title=Startup_code

dtremblay commented 2 years ago

Thanks for your bug report. Could you share the .hex file that you attempted to use?

Reading your report, you may have interrupts enabled - or a Software Interrupt is processed on a BRK command.

After the program has executed, the machine doesn't know where to go. So the Program Counter keeps incrementing. I'll have to ask our kernel developer is there's a kernel function to do this. But since you've used the Jump To IDE feature, the kernel is definitely not aware of this. You could explore using the PGX or PGZ file formats, which most likely have a "re-entrant" kernel call when the application is done.

dtremblay commented 2 years ago

Without the .hex and .lst files, it is difficult to help you.