Shop OBEX P1 Docs P2 Docs Learn Events
slots......was — Parallax Forums

slots......was

ArchiverArchiver Posts: 46,084
edited 2003-08-15 21:46 in General Discussion
I agree with Jon, you can use scratchpad ram to pass data between
slots with the Put and Get commands. I have found however that the
constants and varibles don't necessarily be "exactly" the same
variable. If you have a 'x var BYTE' in slot0 its not the same
variable as the 'x var BYTE' in any other slot. What I have found is
you need to assign the same TYPE of varible in each slot. This means
that if you have 3 words, 5 bytes, 7 bit assigned in slot0 then you
MUST assign 3 words, 5 bytes and 7 bits in each slot. (even if you
don't use them all) The 'view memory map' should look the same for
each slot. I've done this with a couple programs now and haven't had
any 'alaising' problems. Did I just get lucky?

Paul


--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> You don't have to do this unless you're trying to mimic one
contiguous
> space. That said, you can't GOSUB into another program slot. What
I do
> is use extra slots for support routines (displays, etc.) and pass
data
> to them via the ScratchPad RAM. I also store a task pointer for my
main
> slot so that when I return from a support slot, I can pick up where
I
> left off.
>
> This technique is detailed in my N&V article.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: Newzed@a... [noparse][[/noparse]mailto:Newzed@a...]
> Sent: Friday, August 15, 2003 10:09 AM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Re: Full BS2, change to BS2e?
>
>
> [noparse][[/noparse]SNIP]
>
> Tip: ALL of the constants and variables must appear in both files
and
> EXACTLY in the same order. This holds true for any banks you might
add.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-08-15 18:48
    Paul is correct. The compiler maps variables into the Stamp's RAM by
    size. If you do this in slot 0:

    jon VAR Byte
    paul VAR Byte

    jon = 41
    paul = 25

    then this in slot 1

    paul VAR Byte
    jon VAR Byte

    DEBUG DEC ?jon, DEC ?paul

    ...you'll end up with the values reversed because the first byte of RAM
    will be called "jon" in Slot 0 and it will be called "paul" in Slot 1.

    What I think Sid (and Paul) are suggesting is that you copy and paste
    your declarations from Slot 0 into your other program slots if you want
    to maintain those variables when you jump from one place to another.
    Keep in mind that RUN will start the target slot from the top; this is
    why I pass a task pointer variable via the ScratchPad and use BRANCH to
    start the new slot where I want.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: Paul [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=PSBZzbKZD3Enx0itJ1thDd6K8-mKEnZ_r1prLP9sBQfZ5v6FLvG05CKX5ALMtcYy6_X0BTE]prcoy@y...[/url
    Sent: Friday, August 15, 2003 12:35 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] slots......was"Re: Full BS2, change to BS2e?"


    I agree with Jon, you can use scratchpad ram to pass data between
    slots with the Put and Get commands. I have found however that the
    constants and varibles don't necessarily be "exactly" the same
    variable. If you have a 'x var BYTE' in slot0 its not the same
    variable as the 'x var BYTE' in any other slot. What I have found is
    you need to assign the same TYPE of varible in each slot. This means
    that if you have 3 words, 5 bytes, 7 bit assigned in slot0 then you
    MUST assign 3 words, 5 bytes and 7 bits in each slot. (even if you
    don't use them all) The 'view memory map' should look the same for
    each slot. I've done this with a couple programs now and haven't had
    any 'alaising' problems. Did I just get lucky?

    Paul


    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > You don't have to do this unless you're trying to mimic one
    contiguous
    > space. That said, you can't GOSUB into another program slot. What
    I do
    > is use extra slots for support routines (displays, etc.) and pass
    data
    > to them via the ScratchPad RAM. I also store a task pointer for my
    main
    > slot so that when I return from a support slot, I can pick up where
    I
    > left off.
    >
    > This technique is detailed in my N&V article.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: Newzed@a... [noparse][[/noparse]mailto:Newzed@a...]
    > Sent: Friday, August 15, 2003 10:09 AM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] Re: Full BS2, change to BS2e?
    >
    >
    > [noparse][[/noparse]SNIP]
    >
    > Tip: ALL of the constants and variables must appear in both files
    and
    > EXACTLY in the same order. This holds true for any banks you might
    add.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-15 19:22
    In a message dated 8/15/2003 1:37:05 PM Eastern Standard Time,
    prcoy@y... writes:


    > If you have a 'x var BYTE' in slot0 its not the same
    > variable as the 'x var BYTE' in any other slot.


    I respectfully disagree. I have a 5-slot program running my model train, and
    x var byte is the same variable in all slots. If is assign a vlue of "24" to
    x in slot 0, and then jump to slot 3, x still equals 24. Or did I read your
    comment wrong?

    Sid





    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-15 19:32
    In a message dated 8/15/2003 1:50:08 PM Eastern Standard Time,
    jwilliams@p... writes:


    > Keep in mind that RUN will start the target slot from the top; this is
    > why I pass a task pointer variable via the ScratchPad and use BRANCH to
    > start the new slot where I want.
    >

    An alternative to the scratch pad - suppose you have sensor detector in slot
    4. When it trips, yiu want it to stop Train2, but Train2 is halfway down in
    slot 1.

    So at the end of the sensor detector you write:

    x = 243
    run 1

    At the very beginning of slot 1 you write:

    if x = 243 then Train2

    Actually a bit simpler than PUT and GET - besides I think there are only 32
    bytes in the Scratchpad - doesn't take long to use that up.

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-15 21:22
    Yes, that technique works great when your variable definitions are the
    same for all slots. I frequently write "accessory" programs that live
    in a slot by themselves and aren't related to a specific program.

    Correction: The Stamp has 32 bytes of RAM (26 for user variables). The
    BS2e/BS2sx has 64 bytes of ScratchPad RAM, the BS2p/BS2pe has 128 bytes
    of ScratchPad.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: Newzed@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=z6boz8d2efvTVeMYKbmP0zWW1gyhjO_FF1EHcl22tq57o1ecrucd2_V8DDexDKaiCNchtEPO]Newzed@a...[/url
    Sent: Friday, August 15, 2003 1:32 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] slots......was"Re: Full BS2, change to BS2e?"


    In a message dated 8/15/2003 1:50:08 PM Eastern Standard Time,
    jwilliams@p... writes:


    > Keep in mind that RUN will start the target slot from the top; this is

    > why I pass a task pointer variable via the ScratchPad and use BRANCH
    > to start the new slot where I want.
    >

    An alternative to the scratch pad - suppose you have sensor detector in
    slot
    4. When it trips, yiu want it to stop Train2, but Train2 is halfway
    down in
    slot 1.

    So at the end of the sensor detector you write:

    x = 243
    run 1

    At the very beginning of slot 1 you write:

    if x = 243 then Train2

    Actually a bit simpler than PUT and GET - besides I think there are only
    32
    bytes in the Scratchpad - doesn't take long to use that up.

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-15 21:46
    In a message dated 8/15/2003 4:23:32 PM Eastern Standard Time,
    jwilliams@p... writes:


    > Yes, that technique works great when your variable definitions are the
    > same for all slots. I frequently write "accessory" programs that live
    > in a slot by themselves and aren't related to a specific program.
    >

    Never thought of that. What a great way to use otherwise wasted space !!.

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.