Menu

What options to optimise a routine

Help
2024-07-28
2024-07-29
  • Fabrice Engel

    Fabrice Engel - 2024-07-28

    Hello Community,

    I am working on a project, (that I will share with you and community very soon), but I need little help. Nothing bad, every thing is working as expected, code is completed (was a portage from C and PIC12F683 to GCBASIC and PIC16F1825) and all run well including on test board.

    The PCB will arrive this week, so I can hopefully complete all together, hardware and software.

    I have one routine to display different information on a LED bargraph with 6 leds. My question is, why sometimes this routine need 466 bytes and sometimes 488 bytes. Comparing both asm files show me the compiler need to select first another page.

    Is this happen because when I make some changes somewhere else, the compiler move the code differently in the memory bank?

    Please find attached the comparaison of both compiled ASM files (as screenshot), as well as the GCBASIC procedure in GCB file.

    Also, and maybe this is a hint, but I not understand why, this sub procedure short way is not displayed in the outline of GCSTUDIO.

    May I can ask more help. If you have a good idea to create a good routine making the same as I do in a much more elegant way, please let me know. I really appreciate any experience feedback. So I can make improvements :)

    Thank a lot for your help.

     
  • Anobium

    Anobium - 2024-07-28

    What an interesting question.

    The HTML file may help you.

    The compiler ( not GCCODE ) makes all the decisions on the final location of a sub in terms of page. If you make a change to the code the automatic system will move the subs about to ensure they fit. This means on page orientated chips then page selects may be added ( as required ).

    You have no control over the page location of the sub.

    What you can do.. is make subs small then you may get more consistent results.


    Any display error in GCODE needs to be resolved. Post two versions of the GCB that shows this happening.


    I hope this helps.

     
  • Angel Mier

    Angel Mier - 2024-07-28

    Hi namesake 😊 It’s good to see that a power user of GC Studio is using the compare function of the IDE.

    Re: Not displayed in the outline
    I found the cause and a temporary work around is to put the comment on the previous line, instead of in front of the sub.

    Further explanation:
    The Symbol provider (a portion of code that is responsible of the outline) uses a regex to test if a comment is present on the line or if it is part of a comment block. The issue is that the current regex can’t know if it is in front of the sub, so the whole line is treated as a comment line. I need to find a fix for this.

    Note: this bug only affects the outlines, it doesn’t change the behavior of the compiler or any other thing.

    Here is the portion of the code (TypeScript language) that needs fixing:

                for (var i = 0; i < document.lineCount; i++) {
                    var line = document.lineAt(i);
                    var regex = new RegExp("(?:\\bsub\\s+)(\\S+)","i");
                    var remregex = new RegExp("(?:[';]|rem|//).*sub","i");
                    var startremblockregex = new RegExp("[/][*]","i");
                    var endremblockregex = new RegExp("[*][/]","i");
                    var stringremblockregex = new RegExp("(?:['\";]|/|rem|//).*[/][*]","i");
                    if (startremblockregex.test(line.text))
                    {
                      if (!stringremblockregex.test(line.text))
                      {
                        remblock = true;
                      }
                    }
                    if (endremblockregex.test(line.text))
                    {
                        remblock = false;
                    }
    
                    if (!remregex.test(line.text) && !remblock)
                    {
                        if (regex.test(line.text)) {                  
                            var symname = regex.exec(line.text);
                            symbols.push({
                                name: symname![1],
                                kind: vscode.SymbolKind.Method,
                                location: new vscode.Location(document.uri, line.range)
                            });
                        }
                    }
                }
    

    Cheers.

    Angel

     
    👍
    1

    Related

    Bugs: *

  • Fabrice Engel

    Fabrice Engel - 2024-07-29

    Hi Evan, Hi Angel,

    thank for your feedbacks, it is more clear for me now.
    I cannot wait anymore the PCB delivery to complete and share the whole project :)
    That I guess can be helpfull for makers like us for fixing electronics!

    @++++

    Fabrice

     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.