CALL @_ vs. JMP @_ issue at compile time?
Steel
Posts: 313
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?·
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
__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
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.
·
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.
·
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
"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.
·
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
Most likely your interrupt routine is pushing the SUB declaration down past the lower half of the memory page.
Do something like this:
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