However, I did some internal improvements to support SjASMPlus alternative syntax and fake instructions, and I think that code can be used to support simple user-defined macros.
If re-defining those macros in your settings.json is acceptable (like this line, for example), please open a github issue (or this thread, or an email, etc.) with a couple example macros and I'll take a look at it!
Nice :-) Very interesting. I typically have a set of standard macros, so, for me, this is nothing that necessarily needs to be dynamically/automatically added. I would benefit from a little custom section in such a file :)
sounds good!! detecting a "function" is tricky (as some times blocks of code have more than one "ret" statement), but I'll just add some heuristic to try to detect functions automatically as well as possible. I'll try to have it for the next version
Nice \o/
In the context of assembly code generated by SDCC, it is very easy to detect functions because their label ends with a double "::
".
For the code written directly in assembler, it is certainly much more complicated.
However, I did some internal improvements to support SjASMPlus alternative syntax and fake instructions, and I think that code can be used to support simple user-defined macros.
If re-defining those macros in your settings.json is acceptable (like this line, for example), please open a github issue (or this thread, or an email, etc.) with a couple example macros and I'll take a look at it!
Nice :-) Very interesting. I typically have a set of standard macros, so, for me, this is nothing that necessarily needs to be dynamically/automatically added. I would benefit from a little custom section in such a file :)
Please send me a couple of macros and a short fragment of code using them so I can envision how to incorporate them and do some tests ^_^
As I was saying before, I think that for small functions, an editor plugin might be easier. But if you want to count function timings for all functions in your code-base. I just added a new flag to MDL that expands the source file table summaries. Before, it would only print size/timing info at the source-file level, but I just added a flag to try to autodetect functions (very simple for now) and output info for them.
The latest development version is here: https://github.com/santiontanon/mdlz80optimizer/releases/tag...
And you can try this doing:
java -jar mdl.jar my-assembler-main.asm -sft-functions -sft timing.tsv
Also, if you are using a particular assembler that has extensions beyond standard z80 syntax (sjasm, sjasmplus, aasmxs, tniasm, pasmo, sdasz, etc.) remember to add the "-dialect" flag (e.g. "-dialect sdcc", or "-dialect tniasm"), or MDL will not parse the code correctly. Without the "-sft-functions", it will only give you information at the individual source-file level (plus included binaries if you also use the "+bin" flag). But anyway, that's enough, MDL has 1 million flags, and some times even I don't remember them all hahaha
I tried java -jar mdl.jar mycode.asm -sft-functions -sft timing.tsv -cpu z80msx -dialect sdasz80
with your new version but the generated timing.tsv
only contain 1 function while my code contain 7.
Any idea?
Here is the timing.tsv
content:
source file (.function name) self size total size accum t-states game_pawn.asm 2392 2392 15753/15598 game_pawn.asm.s__INITIALIZED 1972 12959/12824 game_pawn.asm._GamePawn_Draw 331 2221/2201
Thanks for checking it out!
And yeah, that can happen. As I mentioned, "function identification" is very simple right now (it just looks for a block of code that starts in a label, and ends in a "ret" or an unconditional jump to a label in another file). It needs to be improved, but it's a start haha. Would you mind sharing an example of one of the functions that was not detected? that would help me improve the function identification code
Here is my test code: https://wtools.io/paste-code/b92D
The functions are:
_GamePawn_Initialize _GamePawn_SetPosition _GamePawn_SetAction _GamePawn_Update _GamePawn_Draw _GamePawn_SetTargetPosition _GamePawn_InitializePhysics
As I said, for the SDCC case, the function detection could be very simple because function label are the only global label (with double "::").
Great! thanks! I'll take a closer look at this example and see if I can improve the detection! Indeed, in the SDCC case, it should be easy, I'll add a special case for that!