[cc65-devel] Random (funny, hopefully interesting) question
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Mike F. <mik...@pr...> - 2021-03-18 02:00:19
|
Good evening (or morning, or afternoon). :) I've been building my own 8-bit "emulator" (I put "emulator" in quotes because it's not really emulating something that existed in the 80s) and it's been an amazingly fun project! It actually understands 6502 machine code (better than me lol - I found a library :D), and I've compiled programs for it with DASM, ACME, and CBM PRG Studio. 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). 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). Anyway, as I've jumped from assembler to assembler to see how they are different and how my made-up machine reacts to the compiled binaries, I found something funny that I think might explain C programs compiled with c*65 don't work: on asm80.com, when you set the start address (I forget if it was .ORG or *+$wherever), the compiled binary is exactly 64 K and everything before the start address is padded with zeroes (instead of the first 2 bytes specifying the start address). 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). But considering my "computer" runs code built with so many other assemblers, I'm sure I'm missing something super-simple. Anyway, this project has really been just to stick my toes in the water of emulator development and do a really deep-dive into 6502 Assembly (which I've learned a lot better, though I'm still far from an expert lol). So totally no biggy if you don't know how to answer this. On the other hand if you do, hope I gave you a good laugh! :D Seriously tho, any info on the subject would be nice if you have it. For now, I'm just gonna keep studying the docs and see if anything jumps out at me. But regardless, have a nice night/morning/whatever and thanks for reading. :) |