Shop OBEX P1 Docs P2 Docs Learn Events
question about template — Parallax Forums

question about template

basicstampedebasicstampede Posts: 214
edited 2008-08-31 15:40 in General Discussion
I noticed that the following statements are at the bottom of the template.· What purpose do they serve?

What is Page 1 code, page 2 code etc.?

'
' Page 1 Code
'
Page_1:
· ADDRESS $200
P1_Start:
· GOTO P1_Start································ ' error if Pg0 overruns Pg1

'
' Page 2 Code
'
Page_2:
· ADDRESS $400
P2_Start:
· GOTO P2_Start································ ' error if Pg1 overruns Pg2

'
' Page 3 Code
'
Page_3:
· ADDRESS $600
P3_Start:
· GOTO P3_Start································ ' error if Pg3 overruns Pg4

Comments

  • ZootZoot Posts: 2,227
    edited 2008-08-31 00:42
    The SX has "pages" of code divided into blocks of 512 bytes. JMPs (GOTO in SX/B) only work on 512 bytes (JMPs are 9bit addresses). In order to actually "goto" an address (instruction) higher than 512, the PAGE must be set first.

    If you are using SX/B only, this template is a little old-fashioned, as the current release of SX/B automatically uses @ with assembly JMPs (what does this mean to you -- that it doesn't matter what code the page is on, and the automatic setup of subs and functions also means you are not required to carefully place subs where they can be called).

    However if you are mixing ASM and Pbasic, there is something to be said for organizing by pages (blocks of 512 instructions) because you do NOT need the @ if you are JMPing to a label within the same page. This saves huge amount of code space if you have a lot of jmps. You would only need the JMP @label if you are jumping to a label on another page.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • basicstampedebasicstampede Posts: 214
    edited 2008-08-31 00:48
    Thanks Zoot.· So I guess I don't need to be concerned since I program with SX/B.·
  • ZootZoot Posts: 2,227
    edited 2008-08-31 00:54
    No. In fact, you may want to remove the PAGE/ORG statements in your template as you will get assembler errors if you try to compile+assemble and have "filled" a page past the ORG statement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-31 15:40
    You're using a REALLY OLD template; I've attached an up-to-date template to your other post. Keep in mind that SX/B has changed since it's release and templates and coding approaches have changed with it. This is one of the cool things about SX/B: as more people use it and make suggestions it improves.
Sign In or Register to comment.