Shop OBEX P1 Docs P2 Docs Learn Events
How to GOTO or GOSUB across 2Kx8 ROM pages on BS2e — Parallax Forums

How to GOTO or GOSUB across 2Kx8 ROM pages on BS2e

dashuangdashuang Posts: 4
edited 2005-04-21 19:50 in BASIC Stamp
I want to use more than one 2K ROM page with BS2e for a single application.· I've set up the compiler directive and successfully tokenized a second file·with some code in it, including label "P1:".· When I attempt to GOTO P1 from the "file0" page, I get a compiler error - label not found.· Does anyone know how to GOTO or GOSUB etc. across 2K pages on a BS2e?· I've been unable to find an answer in the Parallax docs.· freaked.gif

Comments

  • kb2hapkb2hap Posts: 218
    edited 2005-04-21 16:54
    Run 1

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    dtq
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-21 16:58
    Hello,

    ·· You cannot GOTO or GOSUB across banks like that.· You must use the RUN command as mentioned above.· Bear in mind though that in each bank you must also declare all of your variables and in the same order and sizes or you will have problems with them between programs.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • NewzedNewzed Posts: 2,503
    edited 2005-04-21 17:14
    This is very easy.· In bank 0, when ever you want to go to P1, enter a flag like this:

    com = 1
    run 1

    Then in P1, at the very beginning of the P1 program, write:

    if com = 1 then do something

    When do something finishes, and you want to go back to bank 0, enter the following:

    com = 1
    run 0

    At the very beginning of the bank 0 program, enter"

    if com = 1 then something new.

    It is important that the flags be entered at the very beginning of each program.· Stamp must read those lines before it reads anything else.· If you need more help, just holler.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    NEW! 4 MB EEPROM

    http://hometown.aol.com/newzed/page4.html
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-21 19:23
    I wrote an article for N&V that shows a method for managing multiple banks.

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • dashuangdashuang Posts: 4
    edited 2005-04-21 19:42
    Chris, Sid & DTQ:

    Thanks so much for the RUN # solution -- and use of a flag to facilitate a pseudo return.

    Chris @ Parallax: FYI, it would have been helpful for me to see a short note about the RUN # command added to the "Compiler Directives" section of Help under:

    {$STAMP BS2e, file2, file3, ..., file8}

    There is nothing mentioned there about how to actually RUN the code compiled in the various "program slots" (file#'s).

    I did several Help searches -- which did not yield info about RUN # command.

    Thanks again. Problem solved!
  • dashuangdashuang Posts: 4
    edited 2005-04-21 19:50
    Hi, Jon,

    Your N&V article is super.

    Thanks!
Sign In or Register to comment.