That is what the last patch I made to HuC does, since I was working on the 240p test suite version for system card 1.0.
Hi Artemio, nice to see you here!
I hadn't looked at your 240p test suite on GitHub and so it hadn't clicked that "aurbina" here is the same Artemio Urbina on GitHub with the HuC fork.
Thanks for you hard work on that.
Just out of curiosity, have you thought about adding a seperate optimizer to the tool chain?
Something that could read the compiler output, and look for things to optimze, and then output a new version of the compilers output?
Err ... there's already a simple optimizer built into the HuC code.
It seems to be based upon optimizing the sequence of macros that get used rather than on an individual instruction level.
CC65's optimizer seems to be a more-traditional peephole optimizer at the instruction level.
I'm not sure which is the better approach, but I can certainly see that HuC's approach makes a lot of sense given the simplicity of the code generation, and it's a
huge improvement over the original Small-C code that doesn't seem to include any optimization at all.
Have you looked at HuC's source to see about adding some improvements?
Are there particular sequences of macro output that bother you?
Probably. I think it would be hard enough to get right in a limited case, much less write a macro that handles all the possibilities. (But then, I'm not that good at asm. I have enough trouble with compares when I know the sizes <lol>)
From a code-generation aspect, isn't it mainly a case of having a 2nd set of macros for byte operations?
Then you just have a new macro that zero-extends or sign-extends the 8-bit primary register into 16-bits whenever you do a 16-bit operation with it.
But I suspect that the bigger issue is could be actually having the keep track of the size of all of the variables ... I've not dug into HuC deep enough to see if it's doing that.
CC65 already has all that stuff in place ... which is nice.
Someone should really gather all the patches together, and release an updated HuC.
That's the joy of modern development, Artemio already did gather all the important patches together ...
https://github.com/ArtemioUrbina/hucUnfortunately, Ulrich's changes use a couple of linux functions that aren't available on Windows, and so it looks like HuC must now be compiled under cygwin and use the nasty cygwin dll on Windows.
I don't know if there's a pre-built version somewhere, perhaps on one of the other forums, or on someone's web page.
Fixing the code that he added to make it compile on Windows again would be a nice little project for a C programmer.
The hard-16-bit code generation for comparisons is pretty much what caused slowdown in Atlantean. I was rarely actually comparing 16-bit numbers. Most of it is char based stuff.
On top of doing this, it's use of the X register causes great collisions with arrays that also use the X register.
a simple if(thing[i] > otherthing[i])
comparison is a hot mess.
Are those arrays global, static or local (i.e. stack-based)?
Are they arrays of 8-bit values or 16-bit values or structs?
Since I'm not really familiar with the code that HuC generates, it would be really helpful to have an example to see what it's doing.
Could you send me a ".s" file of the compiler output so that I can see the problem in a real program?
Couldn't array access just use the Y register?
Good question.