Code:
#define EM_NONE 0 /* No machine */
#define EM_816 1 /* 65C816 */
#define EM_C02 2 /* 65C02 */
#define EM_02 3 /* NMOS 6502 */
#define EM_RC02 4 /* Rockwell 65C02 */
#define EM_RC19 5 /* Rockwell C19 */
#define EM_NUM 6
Hmm, if you're defining e_machine then I think those values are not compatible with the current ELF standard. My understanding is that there should be a single value for everything under the MOS umbrella (EM_MOS, let's say) and there should be architecture-specific e_flags values for each of the various instruction sets. So, for example, there should be exactly one e_machine value for everything related to MOS (shall we say 6502?), and there should be e_flags that look something like:
Code:
EF_MOS_ARCH_6502 = 0x10,
EF_MOS_ARCH_6502X = 0x20,
EF_MOS_ARCH_65SC02 = 0x30,
EF_MOS_ARCH_65C02 = 0x40,
EF_MOS_ARCH_SWEET16 = 0x50,
EF_MOS_ARCH_65816 = 0x60
Here is how I'm currently doing it:
https://github.com/johnwbyrd/llvm-mos/blob/mos/master/llvm/include/llvm/BinaryFormat/ELF.hQuote:
I have these (future) OS definitions. If there was such a thing as standard calling conventions we could use these constants to identify the calling convention standards.
I do have some ideas about how a calling convention will behave with LLVM, but of course nothing is set in stone. Please feel free to review and comment on
https://github.com/johnwbyrd/llvm-mos/wiki/To-do, specifically the Calling Convention section.
Code:
/* Legal values for e_type (object file type). */
#define EI_OSABI 7 /* OS ABI identification */
#define ELFOSABI_OS16 66 /* OS 16 */
#define ELFOSABI_OS8 65 /* OS 8 */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
I'm not sure how an eabi even makes sense for 6502. I'm not aware of an "OS 16", are you? It's not like it's Linux versus Win32 out there for 6502. I suggest just using eabi-none, unless you can think of a compelling reason not to.
Quote:
I have used Direct Page as a name in my code instead of Zero Page as it's more generalised. If you are working on 6502 output for llvm then targeting the 65C816 would be worthwhile as well as it should generate significantly better code.
At the moment I'm simply referring to it as 8-bit addressing. "Direct page" to me implies that the other 16 bit memory addresses are accessed indirectly, and indirect addressing has another meaning on the 65xx.
I certainly want to leave the door open to '816 compatible output in the future, so yes, we might as well get those constants solidified early on.