Shop OBEX P1 Docs P2 Docs Learn Events
Jump Problem — Parallax Forums

Jump Problem

NewzedNewzed Posts: 2,503
edited 2005-05-10 00:01 in General Discussion
I'm having a small problem.· If I write:

(lines of code followed by[noparse]:)[/noparse]

put Line1, "RB.6 = ", dis, "· ", chg
gosub @show
goto main

It compiles perfectly.
***********************************

If I write:

put·Line1, "RB.6 = ", dis, "· ", chg
gosub @show
goto @P1_Start
'
' Page 1 Code
'
Page_1:
· ADDRESS $200
P1_Start:
goto @main

I get an error "Unable to·assemble due to errors in source code".

Why?

Sid

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-09 15:07
    Have you installed version 1.2? If yes, you don't need '@' anymore -- it's automatic. See the section on SUB declarations.· Also, look at the demos in the help file to see how subroutines are handled now.· It's much easier, and the SUB declaration actually helps you write code that's less error-prone because it will check the number of parameters required for your subroutine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA


    Post Edited (Jon Williams) : 5/9/2005 3:10:03 PM GMT
  • BeanBean Posts: 8,129
    edited 2005-05-09 15:27
    Sid,
    Please post the complete code that is giving you the error.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "I thought I was wrong once...But I was mistaken [noparse];)[/noparse]"
    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-05-09 16:36
    I downloaded version 1.21 of the compiler and copied it into my compiler directory.· Removed all the "@" formatters and I still get the same error.· I have attached a copy of the whole program.· If I replace 'goto P1_Start'
    with 'goto main' it compiles OK.· Beats me.



    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Need a bezel for your LCD?

    Newzed@aol.com
  • BeanBean Posts: 8,129
    edited 2005-05-09 18:29
    Sid,
    You have too much code in the page zero. And it's running into page 1.
    SX/B now handles all that code page Smile. Just remove all those ADDRESS lines that you had to use in version 1.0. Now you can just keep writing code until the whole chip is full.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "Great people talk about great things, average people talk about average things, small people talk about other people."
    ·
  • PJMontyPJMonty Posts: 983
    edited 2005-05-09 18:51
    Newzed,

    When I try and compile it with either line I get the assembly error. However, you didn't mention the specific error messages that SASM gives you when you compile the SX/B program. It really helps when you provide all the information that is given to you by the IDE when soliciting help. In your program, the SASM error is:

    Overwriting same program counter location

    This is the big clue that tells you what is going on. Your program is too big to fit in the one page of the SX chip. I am guessing that you wrote some smaller section of the code, assembled and tested that, and then did a big cut and paste-a-thon which subsequently refused to assemble.

    BTW, are you using the new 3.1 version of the SX-Key IDE?
      Thanks, PeterM
  • NewzedNewzed Posts: 2,503
    edited 2005-05-09 18:58
    Bean, are you saying delete everything in the template beginning with Page 1 Code and make a new template?

    I am using IDE V2.03.04.· Is that the latest?· Haven't used my SX/B in quite awhile.· Been so busy with other things.

    How can I tell how much memory I have left?

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-05-09 19:02
    PeterM, I have V2.03.04.· Where can I download V3.1?

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-09 19:06
    http://www.parallax.com/sx/downloads.asp

    Since we just updated the SX/B compiler and help file today, you'll need to update it after you install the 3.1 IDE.· You can get the SX/B updates from the sticky at the top of this forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • PJMontyPJMonty Posts: 983
    edited 2005-05-09 19:12
    Newzed,

    2.03.04!!! Yikes! Go, my friend, and download 3.1 pronto! Lots of bug fuxes, inmprovements, etc since the 2.0 series. Jon provided the URL in the post above.
      Thanks, PeterM
  • NewzedNewzed Posts: 2,503
    edited 2005-05-09 23:07
    OK - I've got my little program written and compiled.· If I add one more line of code I get an Overwrite error.· The PBasic part has 222 lines, the .src file has 1236 lines.· Could I have possibly used up 2K of memory??

    How can I tell how much memory I have left.· Per Bean, I deleted all the ADDRESS statements from my template - there is no page 1, no page 2, nothing but my program.· Have I gone astray somewhere.· I've written a lot of PBasic programs and what I have doen't look like 2K to me.

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-09 23:34
    You could have easily used 2K. Remember, SX/B is an inline compiler, so every high-level command you use gets compiled into a bunch of machine instructions. This is why I put "expensive" instructions into subroutines: they only get compiled once.

    You cannot compare SX/B to PBASIC in language use -- it's an apples and oranges comparison; though using subroutines as I've suggested gets you closer. In the BASIC Stamp, the code for RCTIME is in one spot, and the tokens are setup to call it. In your program, you've got the code for RCTIME 16 times -- that's how you blew through 2K of code in such a hurry. What you may have to do is study the RCTIME output and write a custom function that will allow you to pass a pin number to it as the BASIC Stamp version of RCTIME allows.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NewzedNewzed Posts: 2,503
    edited 2005-05-09 23:47
    Jon, I knew that writing 16 RCTimes was going to cost me.· Before I posted anything, I tried every variation I could think of the to write RCTime and cycle through the pins.· I couldn't get anything to work.· I declared:

    rb0 var RB.0
    rb1 var RB.1
    and so on, then wrote:

    for ix = 0 to 7
    HIGH rb(ix)

    That didn't work - I got an error message
    "expecting 0 to 7"

    I just had an idea - what if I wrote:

    pin con RB.0
    gosub time
    pin con RB.1
    gosub time...............................

    time:
    high pin
    pause 8
    rctime pin, 1, dis
    ..........
    return

    Would that work?

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-10 00:01
    I don't know ... does it?· Since you have the hardware setup you should just run a test.

    Looking at your code, though, I did find a place where you can get some code savings: your PUT statements.· For example, you do this:

    · PUT Line1, "RB.5 = ", dis, "· ", chg

    ... 16 times.· I think you could fold that into your Show subroutine by using parameters to pass the port ("B" or "C"), the bit ("0".."7"), and your dis and chg values.· Give this a try:

    Show:
    · temp1 = __PARAM1···· ' port
    · temp2 = __PARAM2···· ' bit
    · temp3 = __PARAM3···· ' dis
    · temp4 = __PARAM4···· ' chg

    · PUT Line1, "RB.0 = ", dis, "· ", chg
    · PUT Line1(1), temp1
    · PUT Line1(3), temp2

    ··FOR ix = 0 to 15
    ····GET Line1(ix), char
    ··· SEROUT So, Baud, char
    · NEXT
    · RETURN

    You would call Show like this:

    · Show "B", "5", dis, chg

    Remember to declare your subroutine so that you can place it anywhere in the code (and drop "GOSUB").

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.