Page 3 of 3

Re: Some cc65 compiler questions

Posted: Thu Nov 16, 2023 5:56 pm
by desertfish
ahenry3068 wrote: Thu Nov 16, 2023 12:17 pm Prog8 [...] It's very much a moving target
This is true in a sense, but I'm trying to keep it moving very little nowadays to avoid breaking existing code.

Re: Some cc65 compiler questions

Posted: Fri Nov 17, 2023 8:13 am
by Johan Kårlin
In the context, I want to say that I think Prog8 is an extraordinary achievement. I am very impressed and think it is a fantastic contribution to the community even if I am right now focusing on C and cc65.

I would like to return to one of my original questions. It seems that you can change the BASIC stub. As I have mentioned before, I found this done in the demo for ZSMKit. In the config, segments are defined like this:

Code: Select all

SEGMENTS {
    ZEROPAGE:   load = ZP,       type = zp;
    EXTZP:      load = ZP2,      type = zp, optional = yes;
    GOLDEN:     load = GOLDEN,   type = bss, optional = yes;
    LOADADDR:   load = LOADADDR, type = ro;
    BASICSTUB:  load = MAIN,     type = ro;
    STARTUP:    load = MAIN,     type = ro;
    CODE:       load = MAIN,     type = to;
    ...
And in the code:

Code: Select all

.segment "BASICSTUB"
.word entry-2
.byte $00,$00,$9e
.byte "2061"
.byte $00,$00,$00
.proc entry
	jmp main
.endproc
How do I write the same code in C?

Re: Some cc65 compiler questions

Posted: Fri Nov 17, 2023 12:47 pm
by Microdriver
Johan Kårlin wrote: Fri Nov 17, 2023 8:13 amI found this done in the demo for ZSMKit.
I guess, first thing would be to run the demo to see what it does (before changing things).
I can compile it, and load "DEMO.PRG" into the emulator, but after "RUN", nothing happens. What is supposed to be done?

Re: Some cc65 compiler questions

Posted: Fri Nov 17, 2023 2:05 pm
by Johan Kårlin
The demo loads some ZSM songs and plays them. But, actually, what the program does is not relevant in this particular case. I am just interested in how the one row in BASIC is generated. I can see exactly how it is done in assembly language and I think I understand how it works, but I don't know how to translate it to C.

Re: Some cc65 compiler questions

Posted: Fri Nov 17, 2023 2:23 pm
by Microdriver
Johan Kårlin wrote: Fri Nov 17, 2023 2:05 pmThe demo loads some ZSM songs and plays them. But, actually, what the program does is not relevant in this particular case. I am just interested in how the one row in BASIC is generated. I can see exactly how it is done in assembly language and I think I understand how it works, but I don't know how to translate it to C.
If you understand the assembly, couldn't you just use it to glue it to your C-program (as a startup-sequence)?

So when you type "RUN", the demo does something like playing songs on your system (I know, that's not the main-topic, but if the program is supposed to be the base for tinkering, it should at least work first, I think) ?

Re: Some cc65 compiler questions

Posted: Fri Nov 17, 2023 7:28 pm
by Johan Kårlin
I guess that is the problem, I don’t know how to connect the solution to my C program even if I know assembler. But sure it can be a start to see that the demo works and see where I can take it from there.