When I write inline assembly code in C with cc65 (__asm__("LDA %v", variable)), then the code will get optimized just like the rest of the C code and I can see the optimization in the generated .s file.
Is there a way to run the same optimizer over a hand-written .s file and to generate a second .s file out of it?
I know, I could simply turn the whole file into a C file with inline assembly. But is there also a simpler way? A way that allows me two write my assemy code in an actual *.s file, but where I can generate a copy of it that I then put into the compile process, so that the ROM always automatically has the optimized code.
Optimization of assembly code of cc65 possible?
Moderator: Moderators
Optimization of assembly code of cc65 possible?
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Re: Optimization of assembly code of cc65 possible?
No, that's not possible. The optimizer is part of the C compiler, the assembler has nothing of the sort.
Re: Optimization of assembly code of cc65 possible?
Maybe this would be a good feature in the future. It shouldn't require that much programming logic: The assembler simply needs to convert the assembly file into a C file with inline assembly. And then, it lets the C compiler run over it to produce another assembly file.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Re: Optimization of assembly code of cc65 possible?
Is it useful though? Even a newbie to asm can easily write better code than what cc65 does.
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Optimization of assembly code of cc65 possible?
If you want an optimising assembler, tass64 has a build in optimiser, but it only provides you with hints on what can be optimised. As sometimes doing an optimisation will undo the ability to optimise. It won't rearrange your code, but it will find shortcuts and dead opcodes like doing a clc after a bcs for example.
Re: Optimization of assembly code of cc65 possible?
You can surely write better Assembly code than what the cc65 compiler turns into Assembly out of C.calima wrote:Is it useful though? Even a newbie to asm can easily write better code than what cc65 does.
But my idea is about writing hand-written Assembly code and getting that one optimized by the compiler.
I assume that hand-written assembly code is better than the same hand-written assembly code + optimizations on it, don't you?
Can it work with the ca65 syntax? My idea was to check my existing code without much hazzle and with the same or better optimizing quality that cc65 uses for inline assembly blocks.Oziphantom wrote:If you want an optimising assembler, tass64 has a build in optimiser
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
- FrankenGraphics
- Formerly WheelInventor
- Posts: 2064
- Joined: Thu Apr 14, 2016 2:55 am
- Location: Gothenburg, Sweden
- Contact:
Re: Optimization of assembly code of cc65 possible?
That [tass64-style tips] would be an interesting feature for ca65. Maybe it could output all optimisation tips in a separate list; rather than cluttering the console (the cc65 suite already has all kinds of notes, warnings and error notices).
With 1)a command line option to activate optimisation tips, and 2) a directive to ignore generating tips for certain blocks, it'd be effective.
With 1)a command line option to activate optimisation tips, and 2) a directive to ignore generating tips for certain blocks, it'd be effective.
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Optimization of assembly code of cc65 possible?
It depends on how deeply you use CA65s features, both use the dot directive format, so .byte .word .segment etc. Tass64 has a build in linker rather than an external one, so they conceptually do the same things, just with different levels of abstraction. The macro format is not compatible. A better question might be, What does CA65 do that you need, and can Tass64 do it as well? Then if it can/or you like the idea of the optimizer more, do a small test with the optimizer to see if it will does enough to switch.DRW wrote:Can it work with the ca65 syntax? My idea was to check my existing code without much hazzle and with the same or better optimizing quality that cc65 uses for inline assembly blocks.Oziphantom wrote:If you want an optimising assembler, tass64 has a build in optimiser