• AVR Freaks

Hot!Call row address wrong

Author
Airborne
New Users
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2018/02/12 05:13:02
  • Location: Italy
  • Status: offline
2020/05/14 07:16:41 (permalink)
0

Call row address wrong

Hi, the situation is:

 MPLAB X IDE v5.30
 mpasm (v5.86)
 PIC16F19156
the problem is (in listing.disasm):
...
07B9  2081     CALL 0x81                          1959:    CALL addba64
...
                                                               2198:  addba64
0881 0836 MOVF 0xC36, W                       2199:    MOVFW REGB64 + 0
...
When I call addba64 the PC goes to the beginning of the program, any suggestions please?
Thanks
Hal
#1

17 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3850
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Call row address wrong 2020/05/14 07:31:22 (permalink)
    0
    Suggest to provide the whole project - no just some fancy snippets.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 07:40:18 (permalink)
    5 (1)
    Use:
            pagesel addba64
            call    addba64

     
    #3
    Airborne
    New Users
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2018/02/12 05:13:02
    • Location: Italy
    • Status: offline
    Re: Call row address wrong 2020/05/14 07:44:09 (permalink)
    0
    The project is too big to post ...
    I refine the question: in what cases can the compiler make a mistake in assigning the address of a line to a label?
    #4
    Airborne
    New Users
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2018/02/12 05:13:02
    • Location: Italy
    • Status: offline
    Re: Call row address wrong 2020/05/14 07:49:31 (permalink)
    0
    Use:
            pagesel addba64
            call    addba64
     THANKS 1and0!!!!
    #5
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 07:49:59 (permalink)
    0
    airborne
    I refine the question: in what cases can the compiler make a mistake in assigning the address of a line to a label?

    No, it is not a compiler, and the assembler did not make a mistake. It does what you told it to do. Read my previous post and the "PCL and PCLATH" section in your PIC datasheet. ;)
    #6
    Airborne
    New Users
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2018/02/12 05:13:02
    • Location: Italy
    • Status: offline
    Re: Call row address wrong 2020/05/14 07:56:42 (permalink)
    0
    Smile: Smile yes, of course, thanks
    #7
    ric
    Super Member
    • Total Posts : 28006
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Call row address wrong 2020/05/14 13:24:03 (permalink)
    0
    airborne
    The project is too big to post ...
    I refine the question: in what cases can the compiler make a mistake in assigning the address of a line to a label?

    Didn't the ASSEMBLER output a warning that your code crossed over a "page boundary" ?
    On PIC16F devices, it is your job to partition your code into 2k pages, and manage jumps/calls between pages.
    This is much easier to do in the more modern "relocatable" mode. You appear to be using the assembler in the older "absolute" mode.
    All of this is managed for you when you program in C.
     
    post edited by ric - 2020/05/14 13:25:36

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 14:17:05 (permalink)
    0
    ric
     
    Didn't the ASSEMBLER output a warning that your code crossed over a "page boundary" ?

    Not for relocatable mode. It will generate a "crossing page boundary" message for absolute mode.
     
    #9
    NorthGuy
    Super Member
    • Total Posts : 6228
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Call row address wrong 2020/05/14 14:44:39 (permalink)
    5 (1)
    ric
    This is much easier to do in the more modern "relocatable" mode.



    Debatable :)
    #10
    ric
    Super Member
    • Total Posts : 28006
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Call row address wrong 2020/05/14 14:52:59 (permalink)
    0
    1and0
    ric
     
    Didn't the ASSEMBLER output a warning that your code crossed over a "page boundary" ?

    Not for relocatable mode. It will generate a "crossing page boundary" message for absolute mode.

    The standard linker files won't allow a code segment bigger than a page so you could never get that warning anyway. :)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 16:00:05 (permalink)
    0
    ric
    The standard linker files won't allow a code segment bigger than a page so you could never get that warning anyway. :)

    ... however, it will allow this in relocatable mode
    rst    code    0x0000
           call    Fubar

    pg1    code    0x0881
    Fubar  movf    foo,w
           return

    and generate NO "page boundary" message. :(
    post edited by 1and0 - 2020/05/14 16:02:34
    #12
    ric
    Super Member
    • Total Posts : 28006
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Call row address wrong 2020/05/14 16:07:05 (permalink)
    0
    There's limits to how far you can go to protect people from themselves! ;)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 16:12:36 (permalink)
    5 (1)
    This will generate a "page boundary" message in absolute mode. :)
    rst     org     0x0000
            call    Fubar
           
    pg1     org     0x0881
    Fubar   movf    foo,w
            return

    #14
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 16:35:27 (permalink)
    0
    ric
     
    This is much easier to do in the more modern "relocatable" mode. 


    In relocatable mode, the linker will not allocate a code section across page boundary.
     
    In absolute mode, it is easy to partition your code into pages; like this
    rst     org     0x0000
            ; insert page 0 code here
           
    page1   org     0x0800
            ; insert page 1 code here
           
    page2   org     0x1000
            ; insert page 2 code here
           
    page3   org     0x1800
            ; insert page 3 code here
    #15
    ric
    Super Member
    • Total Posts : 28006
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Call row address wrong 2020/05/14 16:40:36 (permalink)
    0
    I guess the bottom line is, in assembler the programmer must be aware of the page limitation, and work around it.
    Putting pagesel before every CALL and GOTO is not a good solution.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #16
    1and0
    Access is Denied
    • Total Posts : 10999
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Call row address wrong 2020/05/14 18:09:01 (permalink)
    0
    ric
    Putting pagesel before every CALL and GOTO is not a good solution.

    Agree. In assembly, the programmer will be best to group and allocate code to minimize PAGESEL as well as BANKSEL.
     
    #17
    Airborne
    New Users
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2018/02/12 05:13:02
    • Location: Italy
    • Status: offline
    Re: Call row address wrong 2020/05/14 23:15:10 (permalink)
    0
    Thank you, you have opened up a new world for me LoL: LoL
    #18
    Jump to:
    © 2020 APG vNext Commercial Version 4.5