Big error in last version compiler!


+ Reply to Thread
Results 1 to 8 of 8

Thread: Big error in last version compiler!770 days old

  1. #1
    Junior Member atomix's Avatar
    Join Date
    Jul 2012
    Posts
    48
    Thumbs Up
    Received: 4
    Given: 0
    Total Downloaded
    1.54 GB

    0 Not allowed!

    Default Big error in last version compiler!

    In version 3.6.1.6 - error in many case -> skipped -> movlb 0

    Code:
    Device 18F46K22
    
    Declare Xtal = 64
    
    
    Dim buf[200] As Byte
    Dim Lang     As Byte
    
    
    ANSELC = %00000000  :  LATC = %00000001  :  TRISC = %11000100
    OSCCON = %01111100  :  OSCTUNE.6 = 1           ' PLL Enable
    
    
    DelayMS 1000            ' must be movlb 0
    
    
    Lang = 0
    Lang = Lang + 9
    
    
    HSerOut [Lang, $F1]
    
    
    Movlb 0                    ' inserted to show error
    
    
    HSerOut [Lang, $F2]

  2. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    What is the error?

  4. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    203
    Thumbs Up
    Received: 13
    Given: 15
    Total Downloaded
    3.22 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    Works at my end. Does not skip movlb 0.
    Flosi Guđmundsson
    Reykjavík

  6. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,373
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    must be movlb 0
    What does this comment mean?
    George.

  8. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,687
    Thumbs Up
    Received: 357
    Given: 173
    Total Downloaded
    2.00 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    That's not an error, it is the compiler removing mnemonics that are not needed, when required.

    The snippet you show, keeps the BASIC version of the Movlb mnemonic in the Asm file, but change the Array to an element value that will move Lang out of RAM Bank0, and the Movlb mnemonic will be removed, because it is not needed. This is optimisation.

    For example, Make, buf[200] into buf[260], which will overflow RAM bank 0, then compile and take a look at the Asm code:

    F1_000024 equ $ ; IN [TEST.BAS] MOVLB 0
    F1_000027 equ $ ; IN [TEST.BAS] HSEROUT[LANG, $F2]
    movlb 0X01
    movf Lang,W,1
    rcall __hrsout1__
    movlw 242
    rcall __hrsout1__


    Notice that the comment shows where the Movlb 0 was placed in the BASIC code, then take a look at the Asm mnemonic directly after it.... It is another Movlb mnemonic, that immediately moves to RAM bank 1, so the original Movlb 0 is not required at all, and simply wastes space, so it is removed.

    This is done by examining the assembler produced, and seeing what can be optimised. This is "peephole" optimisation, and looks for patterns in the asm code. Peephole optimisation happens at the very final stage of compiling, and after all the other optimisation processes have been done. This is something that the vast majority of microcontroller compilers do not do, so they produce very large, and very wasteful code. That also means they run the firmware slower than they could.

    With the Proton24 compiler, I took the peephole optimiser to a very high level and the asm code is examined and adjusted to give as good a result as my experience allowed, and it is added too whenever I get the chance, or see a common pattern in the asm code that could be refined.

    This is why I always state that to show a possible anomaly, always produce an exact, compilable, snippet of code that shows it, because any other code may not, as shown above. This is because the compiler is dynamic, and adjusts the code based upon device type, device family, and the surrounding code and RAM usage etc.. This is why Proton and Proton24 produce some of the best asm code out there! Which is very important for smaller, and less expensive, microcontrollers.
    Last edited by top204; 4th July 2018 at 15:43.

  10. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Junior Member atomix's Avatar
    Join Date
    Jul 2012
    Posts
    48
    Thumbs Up
    Received: 4
    Given: 0
    Total Downloaded
    1.54 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    you misunderstood, I'm not talking about optimization. I say that the compiler skips the insertion of the bank selection and this leads to access to the wrong variable.

    Code:
    Device 18F46K22
    
    Declare Xtal = 64
    
    Dim buf[200] As Byte
    Dim Lang     As Byte
    
    ANSELC = 000000  :  LATC = 000001  :  TRISC = 000100
    OSCCON = 111100  :  OSCTUNE.6 = 1           ' PLL Enable
    
    DelayMS 1000            ' must be movlb 0
    
    Lang = 0
    Lang = Lang + 9
    
    HSerOut [Lang, $F1]
    Click image for larger version

Name:	snapshot.jpg
Views:	28
Size:	95.7 KB
ID:	3515
    Last edited by atomix; 5th July 2018 at 11:21.

  12. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,687
    Thumbs Up
    Received: 357
    Given: 173
    Total Downloaded
    2.00 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    Thanks for your determination Atomix. There is an anomaly somewhere in the processing from Access RAM to standard RAM, in some rare circumstances, so I am now inside the compiler to see where it is.

    It is one of those quirks that only shows its head in certain circumstances, and has something to do with the RAM bank switching mechanism within the compiler. A very tricky piece of code, and not something I like to enter into very often. LOL. It was one of those mechanisms that I wrote when I was in a "clever zone" many years ago, which is not always the zone I'm in. :-) Thankfully, I always fully comment my code, regardless of what language it is written in, because, as you know, as programmers, sometimes you get that logical thought time frame, and what you did then, you look back on and think "crickey I couldn't do that now" LOL. So comments are mandatory to see what you did back then, and, hopefully, trigger some clever memories. :-)

    I'll get back to you on it.

    Instead of Movlb, use one of the compiler's internal mechanisms that I created to test code when I was writing the compiler. Add the command Reset_Bank to just before Lang = 0. This will force the compiler to make the RAM bank 0, and all its internal variables holding the previous RAM banks etc.

    Sorry about that!

  14. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,687
    Thumbs Up
    Received: 357
    Given: 173
    Total Downloaded
    2.00 GB

    0 Not allowed!

    Default Re: Big error in last version compiler!

    Got it!!!!!

    It was the changes I had to make for those silly, quirky, 18FxxK42 devices, that have broken most of the rules of 18F devices. I made the mistake of assuming I could leave some of the code changes I made for the 18FxxK42 devices and use it for the standard 18F devices. WRONG!!!!

    It now sets the RAM bank before it accesses the variable Lang, which is what it should do.

    Again... Thanks for your perseverance.

    I'll be uploading a new update installer as soon as I've tested, tested, tested, then retested the changes made to an important part of the compiler, but the changes were very small, and niche.
    Last edited by top204; 5th July 2018 at 19:42.

  16. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 0
    Last Post: 30th June 2016, 16:51
  2. Replies: 0
    Last Post: 29th March 2016, 13:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts