Some cc65 compiler questions

Get technical support from the community & developers with specific X16 programs if you can't find the solution elsewhere
(for general non-support related chat about programs please comment directly under the program in the software library)
User avatar
desertfish
Posts: 1098
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Some cc65 compiler questions

Post 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.
Johan Kårlin
Posts: 292
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Re: Some cc65 compiler questions

Post 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?
Microdriver
Posts: 14
Joined: Tue Sep 19, 2023 9:58 pm

Re: Some cc65 compiler questions

Post 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?
Johan Kårlin
Posts: 292
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Re: Some cc65 compiler questions

Post 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.
Microdriver
Posts: 14
Joined: Tue Sep 19, 2023 9:58 pm

Re: Some cc65 compiler questions

Post 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) ?
Johan Kårlin
Posts: 292
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Re: Some cc65 compiler questions

Post 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.
Post Reply