Shop OBEX P1 Docs P2 Docs Learn Events
CALL @_ vs. JMP @_ issue at compile time? — Parallax Forums

CALL @_ vs. JMP @_ issue at compile time?

SteelSteel Posts: 313
edited 2006-08-05 20:22 in General Discussion
I have a sub routine.· It is called "OUTPUT_LEDS".

I have this sub routine declared in subroutines..."OUTPUT_LEDS SUB".

When I compile my SXB code, I get the following error:
"Address 353 is not within lower half of memory page".

When I go to the location in the .SRC File, it says "CALL @__OUTPUT_LEDS".· I was reading the manual, and I was under the impression that the command should be JMP if the subroutine ends up on a different 'page'.·

I switched the "CALL" with "JMP", and it compiled the SRC File fine.

...But, whenever I make any changes to the .SXB file and compile, I have to go back and fix all of the spots where I call the subroutine.

Is there a way to change this?·

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2006-07-25 16:36
    The "OUTPUT_LEDS SUB" statement will generate the following two assembly instructions:

    __OUTPUT_LEDS:
    jmp @OUTPUT_LEDS

    This should be placed near the beginning of your program to ensure that it is in the first half of the page. The call instruction contains only 8 address bits. This is why the call instruction is only capable of jumping to an address within the first half of a page.

    Move the statement to the beginning of your program and it should work.

    Dave
  • BeanBean Posts: 8,129
    edited 2006-07-25 16:36
    Please post your code and LST file if you can.
    Are you using ON GOSUB ? There are some issues with it that are fixed in version 1.51.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "The meaning of life, is to give life meaning" Unknown.
    ·
  • SteelSteel Posts: 313
    edited 2006-07-25 18:41
    Unfortunately, because of NDA, I cannot post the code...but I think I figured it out. I have a pretty large Interrupt Vector, and I think that was knocking my Sub declarations down too far in the code. When I shorten up my interrupt Vector, it seems to be ok.
  • BeanBean Posts: 8,129
    edited 2006-07-25 19:34
    Steel,
    Yup that will do it...

    When that happens I simply make the interrupt routine a GOTO to a label that is located after the SUBs.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "The meaning of life, is to give life meaning" Unknown.
    ·
  • VinnieVinnie Posts: 15
    edited 2006-07-26 18:17
    I·studied on what seems a related problem·this morning.

    I had the following case:

    definition:
    SUBROUTINE SUB 0

    and the call was in an if

    IF x THEN SUBROUTINE

    I discovered this compiled to a conditional jmp instruction, resulting in a runtime error - retp without call or something like that (because the stack was empty).

    I also found that changing this in

    IF X THEN
    ····· SUBROUTINE
    ENDIF

    compiled ok, resulting in a call to a jump·(which sx normally does to work around the paging problem)·instead of a jump

    At least, I found it strange, but maybe I understand the compiler wrong, or is it even in the manual. Can't remember everything there..

    Maybe this helps a bit..


    Post Edited (Vinnie) : 7/26/2006 6:25:22 PM GMT
  • BeanBean Posts: 8,129
    edited 2006-07-26 18:26
    Vinnie,
    "IF x THEN SUBROUTINE" is not a valid form of "IF".
    You found the solution, put the SUBROUTINE on the next line.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "The meaning of life, is to give life meaning" Unknown.
    ·
  • giurogiuro Posts: 1
    edited 2006-08-05 18:00
    hi·
    I am a new consumer of sx/b.·
    I have realized with simplicity different small programs with sx/b, but·
    a more complex program (I am using interrupt and SUBs) the code of error· returns me " error44, pass 2: address 347 ises not within lower half of memory page."·
    The suggestions on the forum have not helped me. can you clarify better thing do?·
    thanks. giuro
  • BeanBean Posts: 8,129
    edited 2006-08-05 20:22
    Giuro,
    Most likely your interrupt routine is pushing the SUB declaration down past the lower half of the memory page.

    Do something like this:
    INTERRUPT
      GOTO Handle_Int
    
    MySub1 SUB
    MySub2 SUB
    
    Handle_Int:
      ' Put the actually interrupt code here
      RETURNINT
    
    


    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh


    Post Edited (Bean (Hitt Consulting)) : 8/5/2006 8:25:41 PM GMT
Sign In or Register to comment.