jamestn529 wrote:
An NMOS 6502 target should still be available, though, for people compiling for retrocomputers and consoles.
CC65 is good for that purpose. My opinion is that the time to be expended in developing a new compiler should be focused on the present state of 65xx technology.
Quote:
For example, you want to prefer 8-bit operations compiling for the 65C02, but you want to prefer 16-bit operations for the '816 to avoid having to SEP/REP.
Generally speaking that is true. Where it would get interesting would be in the standard I/O library, in which eight byte operation would be needed to access hardware. Also, that is when the
XBA instruction becomes very useful. You also have to be careful about 16 bit loads and stores on memory that is adjacent to hardware, lest you accidentally touch a hardware register when the MSB is fetched or stored.
One thing to consider is that a 16 bit memory access uses an extra clock cycle to load or store the MSB. In the case of an R-M-W instruction, such as
INC <addr>, two extra clock cycles get used, since a load and store occur in the same instruction. So there are performance implications to consider, especially inside of loops. In any case,
REP and
SEP are inexpensive instructions.
Quote:
Emulation-mode '816 could be targeted as a super-65C02, and full '816 support added later. I don't know how much code could be shared between the two, though.
You might as well just compile for the 65C02 if the system is going to run in emulation mode. The '816 doesn't offer that much over the 'C02 when running in emulation mode, but can cause development headaches due to subtle differences in instruction behavior, e,g.,
MVN and
MVP can only access zero page in emulation mode.
Quote:
EDIT: What language is the best to implement the compiler in? OCaml, or another ML-family language, would be my choice. Pattern matching and ADT's are extremely useful in compiler construction.
That would depend on the machine on which the compiler is to be used. Most of us cross-develop 65xx code on Linux or Micro$oft systems. What would be an achievement would be to develop a compiler that would efficiently run on an actual 65C02 or 65C816 system, such as my POC unit, which is native mode '816.