Thank you for your answer, I'll have a look at the existing ports and try to understand the existing ports. Their code is quite long and complex, so it'll be a pretty big project.
Of course lots of 6502 assemblers and linkers already exists, I just don't know if specific ones needs to be made for a proper SDCC port. Anyways the hardest part is of course generating assembly from C and optimizing it so it's almost as good as hand-written assembly. This could probably be done without actually assembling/linking the result for the testing phase. Just like any other architecture, the 6502 is only limited to the RAM/ROM and clock rate it gets attached to on hardware. It is true it has only 3 8-bit registers, and only one of them (the accumulator) can handle mathematical operations, while the other two (X and Y) are used for indexing or temporary storage. However, most mathematical operations can also be done directly on memory, therefore memory can be used as additional registers. The stack is up to 256 bytes long, I'm not sure if that's considered "small" but I never came close to using all of it in my (assembly) programs. Now when you need to have a really optimized program the only way is usually to write down several variants of it, count the bytes/cycles of every variant, and retain the shortest or fastest one. I've done this many times. This process could probably be automated easily though, which would make a very good compiler ! The existing 6502 compiler, CC65, creates a software stack for the argument stack, and access it using a complex addressing mode. Another shareware compiler whom I've tried the trial version seemed to use a similar strategy. Unfortunately this is very slow and unoptimal. I've already contacted the authors begging them to change this strategy but they replied they wouldn't do it, and that I could always use static variables to avoid using an argument stack. Unfortunately this affects the readability of the C code. I am under the impression this is exactly what SDCC does - not using an argument stack for maximal code optimisation - at the cost to not being able to write re-entrant functions. But this is a very small price to pay for something that can result in code which is 2x faster and smaller too. The other alternative would be to make an unofficial version of CC65 implementing what I'd like to, the problem would be that when they update the real CC65 it'll be hard to update the unofficial version as well. A proper SDCC port would be more work, but in the end it would end up more maintainable. Well, I'm sorry for the very long message. Hopefully someone can point me to the "official" procedure to make a SDCC port while I'm studying the internals of SDCC. Regards. Le 03.09.2012 06:33, Philipp Klaus Krause a écrit : > On 03.09.2012 06:24, Masur Jonathan wrote: > > I suggest you have a look at the sdcc source code, in particular > exisiting ports. I would recommend the hc08 port, since that seems to be > an architecture that is mroe similar to the 6502 than others supported > by sdcc. > > A port consists of a few main components and some glue code. > > 1) Assembler > 2) Linker > 3) Simulator > 5) Code generator > 6) Peephole optimizer. > > For 1 and 2 there probably are exisiting ones that can be used. 3 is > probably best to write based on ucsim, as most sdcc simulators are. 5 is > most of the work. 6 should be postponed until after the port passes > regression tests. > You also need to think about how to do things. The 6502 unfortunately > seems to be a very limited architecture (awkward stack access, small stack). > > Philipp > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user