Re: [cc65-devel] Random (funny, hopefully interesting) question
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Oliver S. <ol...@we...> - 2021-03-18 12:41:52
|
Hi, I can also run cc65, strip out some C-specific labels like booleq and > pushax (which I'm still learning about from the docs and in-code comments) > and compile with a different assembler (and so far it always runs exactly > how I expect it to). > booleq and pushax are assembler functions which the code generated by cc65 implies to be present. They are located in what is called a 'runtime library'. It doesn't makes sense to use cc65 without such a runtime library. In general the output of cc65 should be fed into ca65. And the ourtput of ca65 should be fed into ld65 (together with the runtime libary). See https://cc65.github.io/doc/intro.html#ss1.3. I've read the page about targeting systems that cc65 doesn't support "out > of the box", and I'm starting to get a better rudimentary understanding of > cc65's config language. > :-) > But if I take a basic program that only uses peekpoke.h, and try to just > compile and assemble with the complete c*65 toolset, my "emulator" doesn't > know what to make of it (I'm using -tnone btw). > Nobody can comment on that without knowledge of your "emulator". > Which begs the question: what does the binary format of programs compiled > with c*65 look like? I thought I read something about a BASIC stub being > set at the start (which of course would break my code cuz I don't have > BASIC yet, lol). I also see the ".fopt "compiled with cc65 version x.x.x" > or whatever it was in the .s files - does that go in the binary? These are > just thoughts; I really have no idea (looking at hex dumps doesn't seem to > help lol). > As mentioned, it doesn't makes sense to look at any intermediate files. The only relevant file is the one produced by ld65. And what ld65 produces depends on the configuration you use. > But considering my "computer" runs code built with so many other > assemblers, I'm sure I'm missing something super-simple. > >From my POV you're missing to tell how you want to make code available to your "computer". And you're missing to tell what your expecatations regarding that code are. To which 6502 address do you want it to load, at which 6502 address do oyu want it to start, what is your method of setting the 6502 program counter (PC) to that address. So whithout of any such knowledge: If you create a file named test.c with the content void main() { } and compile it with the command line cl65 -t none test.c you'll get a binary program that is supposed to be placed/loaded at $1000, started from $1000 and having RAM from $1000 to $8000. The binary program created doesn't have any header whatsoever. The first byte of the program is the byte supposed to be placed/loaded at $1000. Additionally it used the zero page locations $80-$9A. All those values stem from the file https://github.com/cc65/cc65/blob/master/cfg/none.cfg - you can override those default values with specific command line options. Regards, Oliver |