Shop OBEX P1 Docs P2 Docs Learn Events
BS2P Alternate Bank Labels — Parallax Forums

BS2P Alternate Bank Labels

ArchiverArchiver Posts: 46,084
edited 2004-07-10 00:40 in General Discussion
In a message dated 7/9/2004 3:08:22 PM Eastern Daylight Time,
knight_designs@y... writes:


> My problem, is now that I moved the DATA statements to BANK 1 I ca't
> use DispAdd = [noparse][[/noparse]DATA Label]
>
> If I specify the exact address in the BANK 1 area, everything works,
> but I can't think how to simplify this. Jon? =) Anyone??
>
>

Do your have all the variables and constants in Bank 0 also in Bank 1 in
EXACTLY the same physical order?

Sid


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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 20:06
    I think I've been working too long and hard today, because I just
    did something that should be simple, and my brains are fried and I
    can't think of what I am supposed to do. I'll explain...

    Using the BS2P40, I had code with text defined in data statements:

    Disp01 DATA "Text Label One"
    Disp02 DATA "Text Label Two"
    Disp03 DATA "Text Label Three"
    etc.

    I recently moved these to another bank to conserve code space,
    however, the way I wrote my print routine (Which is similar to all
    my previous code) is:

    First set the address to the DATA address:

    DispAdd = Disp01

    Then call the Display Subroutine:

    Display:
    READ DispAdd, Disp
    IF Disp = 0 THEN DispExit
    LCDOUT 0, DisplayOn, [noparse][[/noparse]Disp]
    DispAdd = DispAdd + 1
    goto Display
    DispExit:
    RETURN

    My problem, is now that I moved the DATA statements to BANK 1 I ca't
    use DispAdd = [noparse][[/noparse]DATA Label]

    If I specify the exact address in the BANK 1 area, everything works,
    but I can't think how to simplify this. Jon? =) Anyone??

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 20:23
    You're right, Chris, you can't use DATA labels in another bank. Here's
    how I've solved that problem in my projects.

    1) Decide on a maximum length message -- if you're using a 16-character
    LCD, for example, you don't to have messages any long than that.

    2) Structure your external DATA labels so they fall on even boundaries.
    What I do, just because it's easy, is this:

    Disp01 DATA @$00, "Text Label One", 0
    Disp02 DATA @$10, "Text Label Two", 0
    Disp03 DATA $$20, "Text Label Three", 0

    With this setup, the first message is at address 0, the second at
    address $10 (16), etc.

    3) Instead of using a direct Label, you'll now use a message number and
    the max length to calculate the address:

    msgAddr = msgNum * MsgLen

    4) Adjust your print routine as follows:

    Print_Msg:
    msgAddr = msgNum * MsgLen
    STORE msgBank
    chOffset = 0
    DO
    READ (msgAddr + chOffset), char
    chOffset = chOffset + 1
    IF (char = 0) THEN EXIT
    LCDOUT 0, DisplayOn, [noparse][[/noparse]char]
    LOOP UNTIL (chOffset = MsgLen)
    RETURN


    This may, perhaps, look more sophisticated that it needs to be, but
    there are reasons for my madness: the way this code works it will point
    to the bank that has your messages (this is a great technique for
    multilingual apps), then read characters from the string you've pointed
    to. The loop will run until it hits a zero in the stream or hits the
    maximum message length.

    You can still use constants to make this code readable, for example:

    Msg1 CON 0

    Then....

    msgNum = Msg1
    GOSUB Print_Msg

    I hope this helps.

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



    Original Message
    From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=gdj1yjzhQDyeHLQ5N9Yx4aink8TGBfnZk_E_556k-dEjmstkvChW6crq-hcxs6CxH8mmqFug3qV8GxEtlTqz]knight_designs@y...[/url
    Sent: Friday, July 09, 2004 2:07 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] BS2P Alternate Bank Labels


    I think I've been working too long and hard today, because I just
    did something that should be simple, and my brains are fried and I
    can't think of what I am supposed to do. I'll explain...

    Using the BS2P40, I had code with text defined in data statements:

    Disp01 DATA "Text Label One"
    Disp02 DATA "Text Label Two"
    Disp03 DATA "Text Label Three"
    etc.

    I recently moved these to another bank to conserve code space,
    however, the way I wrote my print routine (Which is similar to all
    my previous code) is:

    First set the address to the DATA address:

    DispAdd = Disp01

    Then call the Display Subroutine:

    Display:
    READ DispAdd, Disp
    IF Disp = 0 THEN DispExit
    LCDOUT 0, DisplayOn, [noparse][[/noparse]Disp]
    DispAdd = DispAdd + 1
    goto Display
    DispExit:
    RETURN

    My problem, is now that I moved the DATA statements to BANK 1 I ca't
    use DispAdd = [noparse][[/noparse]DATA Label]

    If I specify the exact address in the BANK 1 area, everything works,
    but I can't think how to simplify this. Jon? =) Anyone??

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 20:29
    Point of clarification: you can't reference DATA labels that are in
    another bank. You can certainly use labels in any bank, but they're
    only visible to code that lives in the same bank.

    Sorry for any confusion.

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


    Original Message
    From: Jon Williams
    Sent: Friday, July 09, 2004 2:23 PM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] BS2P Alternate Bank Labels


    You're right, Chris, you can't use DATA labels in another bank. Here's
    how I've solved that problem in my projects.

    1) Decide on a maximum length message -- if you're using a 16-character
    LCD, for example, you don't to have messages any long than that.

    2) Structure your external DATA labels so they fall on even boundaries.
    What I do, just because it's easy, is this:

    Disp01 DATA @$00, "Text Label One", 0
    Disp02 DATA @$10, "Text Label Two", 0
    Disp03 DATA $$20, "Text Label Three", 0

    With this setup, the first message is at address 0, the second at
    address $10 (16), etc.

    3) Instead of using a direct Label, you'll now use a message number and
    the max length to calculate the address:

    msgAddr = msgNum * MsgLen

    4) Adjust your print routine as follows:

    Print_Msg:
    msgAddr = msgNum * MsgLen
    STORE msgBank
    chOffset = 0
    DO
    READ (msgAddr + chOffset), char
    chOffset = chOffset + 1
    IF (char = 0) THEN EXIT
    LCDOUT 0, DisplayOn, [noparse][[/noparse]char]
    LOOP UNTIL (chOffset = MsgLen)
    RETURN


    This may, perhaps, look more sophisticated that it needs to be, but
    there are reasons for my madness: the way this code works it will point
    to the bank that has your messages (this is a great technique for
    multilingual apps), then read characters from the string you've pointed
    to. The loop will run until it hits a zero in the stream or hits the
    maximum message length.

    You can still use constants to make this code readable, for example:

    Msg1 CON 0

    Then....

    msgNum = Msg1
    GOSUB Print_Msg

    I hope this helps.

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



    Original Message
    From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=DBJc0izYn7gfxQBm4o5QdKn7TWeY6yDLNLB66TEDeFd5iKhWta6VCcPz5P136IQ1sKHQROXLramyNHIN4B6q3A]knight_designs@y...[/url
    Sent: Friday, July 09, 2004 2:07 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] BS2P Alternate Bank Labels


    I think I've been working too long and hard today, because I just
    did something that should be simple, and my brains are fried and I
    can't think of what I am supposed to do. I'll explain...

    Using the BS2P40, I had code with text defined in data statements:

    Disp01 DATA "Text Label One"
    Disp02 DATA "Text Label Two"
    Disp03 DATA "Text Label Three"
    etc.

    I recently moved these to another bank to conserve code space,
    however, the way I wrote my print routine (Which is similar to all
    my previous code) is:

    First set the address to the DATA address:

    DispAdd = Disp01

    Then call the Display Subroutine:

    Display:
    READ DispAdd, Disp
    IF Disp = 0 THEN DispExit
    LCDOUT 0, DisplayOn, [noparse][[/noparse]Disp]
    DispAdd = DispAdd + 1
    goto Display
    DispExit:
    RETURN

    My problem, is now that I moved the DATA statements to BANK 1 I ca't
    use DispAdd = [noparse][[/noparse]DATA Label]

    If I specify the exact address in the BANK 1 area, everything works,
    but I can't think how to simplify this. Jon? =) Anyone??

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 20:40
    --- In basicstamps@yahoogroups.com, Newzed@a... wrote:
    > Do your have all the variables and constants in Bank 0 also in
    Bank 1 in
    > EXACTLY the same physical order?
    > Sid

    Well, everything's in Bank 0 EXCEPT the DATA statements. For some
    reason I thought I was missing something that would let me use my
    Labels as pointers (Addresses), but from the next message, I see Jon
    has a solution to simplify what I am already doing, which is
    specifying absolute addresses.

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 20:44
    The reason you can't reference labels in another banks is that they are
    resolved at compile time, and the compiler can only handle one file at a
    time.

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


    Original Message
    From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=_dOpnR718wIQhIOUq_hdGdGHZmftlyDl8cw6JBQSphFcRdgdMG1OrGFOaTg0pnhRd-aIWQ-cQ8ZDkIGpdRClOaWAlA]knight_designs@y...[/url
    Sent: Friday, July 09, 2004 2:41 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: BS2P Alternate Bank Labels


    --- In basicstamps@yahoogroups.com, Newzed@a... wrote:
    > Do your have all the variables and constants in Bank 0 also in
    Bank 1 in
    > EXACTLY the same physical order?
    > Sid

    Well, everything's in Bank 0 EXCEPT the DATA statements. For some
    reason I thought I was missing something that would let me use my
    Labels as pointers (Addresses), but from the next message, I see Jon
    has a solution to simplify what I am already doing, which is
    specifying absolute addresses.

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 20:50
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > You're right, Chris, you can't use DATA labels in another bank.
    Here's
    > how I've solved that problem in my projects.
    > 1) Decide on a maximum length message -- if you're using a 16-
    character
    > LCD, for example, you don't to have messages any long than that.
    > 2) Structure your external DATA labels so they fall on even
    boundaries.
    > What I do, just because it's easy, is this:
    > Disp01 DATA @$00, "Text Label One", 0
    > Disp02 DATA @$10, "Text Label Two", 0
    > Disp03 DATA $$20, "Text Label Three", 0
    > With this setup, the first message is at address 0, the second at
    > address $10 (16), etc.

    --- TRIMMED ---

    Okay Jon, I get the idea...I don't think I will end up having so
    much text/data that I can't afford to do that. For some reason I
    was just sure I was "missing" something. Even boundries for the
    text sounds great. Since I am using a 20 X 4 LCD Display, then I
    would be using a maximum of 20 characters per data statement, plus
    the 0 terminator byte. SO I could go @$00, @$20, etc. giving me 32
    bytes per statement.

    Anyway, thanks for the help. Just got everything ported over to a
    new Laptop, and had to turn around and get a USB2Serial from you
    guys (Parallax) since THIS Laptop doesn't have a Serial Port.

    Speaking of the FTDI USB2232 converter, regardless of what the
    instructions on the Website say, this thing is Plug & Play under
    Windows XP. At least if you have SP1 or hgiher. No need to
    download the drivers from the site. And no messing around with FIFO
    settings to get things to work on the laptop. Not to mention, the
    LEDs give good feedback that there's activity on the serial lines.

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 21:07
    There is a way to compress messages in the external bank:

    Msg1 DATA "Short message", 0
    Msg2 DATA "This is a long message and doesn't play nice with
    boundaries.", 0
    Msg3 DATA "Another shorty", 0

    Back in the main program bank you can add this:

    Find_Msg:
    STORE msgBank
    IF (msgNum > 0) THEN
    msgAddr = 0
    zCount = 0
    DO
    READ msgAddr, char
    msgAddr = msgAddr + 1
    IF (char = 0) THEN zCount = zCount + 1
    LOOP UNTIL (zCount = msgNum)
    END

    ...

    At this point msgAddr holds the address of the first character of the
    selected message and you can print it as before.

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


    Original Message
    From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IyKfwEF_oUFLCe8hRBbTvsN5tKDmZzh-VtGecIO4y2n2XmxZ3W9WqIDGR4r6ZsV0NwWsmlbMdZBfnuw_nsbDnw]knight_designs@y...[/url
    Sent: Friday, July 09, 2004 2:51 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: BS2P Alternate Bank Labels


    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > You're right, Chris, you can't use DATA labels in another bank.
    Here's
    > how I've solved that problem in my projects.
    > 1) Decide on a maximum length message -- if you're using a 16-
    character
    > LCD, for example, you don't to have messages any long than that.
    > 2) Structure your external DATA labels so they fall on even
    boundaries.
    > What I do, just because it's easy, is this:
    > Disp01 DATA @$00, "Text Label One", 0
    > Disp02 DATA @$10, "Text Label Two", 0
    > Disp03 DATA $$20, "Text Label Three", 0
    > With this setup, the first message is at address 0, the second at
    > address $10 (16), etc.

    --- TRIMMED ---

    Okay Jon, I get the idea...I don't think I will end up having so
    much text/data that I can't afford to do that. For some reason I
    was just sure I was "missing" something. Even boundries for the
    text sounds great. Since I am using a 20 X 4 LCD Display, then I
    would be using a maximum of 20 characters per data statement, plus
    the 0 terminator byte. SO I could go @$00, @$20, etc. giving me 32
    bytes per statement.

    Anyway, thanks for the help. Just got everything ported over to a
    new Laptop, and had to turn around and get a USB2Serial from you
    guys (Parallax) since THIS Laptop doesn't have a Serial Port.

    Speaking of the FTDI USB2232 converter, regardless of what the
    instructions on the Website say, this thing is Plug & Play under
    Windows XP. At least if you have SP1 or hgiher. No need to
    download the drivers from the site. And no messing around with FIFO
    settings to get things to work on the laptop. Not to mention, the
    LEDs give good feedback that there's activity on the serial lines.

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-09 21:31
    Hi Chris,

    Another method is to to store the DATA in one bank and also declare
    the same labels as constants in the bank where the routine is:

    Disp01 CON 0 ' 15 "Text Label One",0
    Disp02 CON 15 ' 15 "Text Label Two",0
    Disp03 CON 15+15 ' 17 "Text Label Three",0
    Disp03 CON 15+15+17 ' 16 "Text Label four",0

    Don't forget to count the null delimiter. The advantage is that you
    get to refer to your messages by name, the disadvantage is that you
    have to count the characters and update the constants if you change
    the DATA.

    Another solution is to move the small routine that displays the data
    to the other bank along with the DATA. Then use a cross-bank call
    for the display. That would probably involve an indexing scheme like
    Jon suggested to pick the message to be displayed.

    -- Tracy



    >I think I've been working too long and hard today, because I just
    >did something that should be simple, and my brains are fried and I
    >can't think of what I am supposed to do. I'll explain...
    >
    >Using the BS2P40, I had code with text defined in data statements:
    >
    >Disp01 DATA "Text Label One"
    >Disp02 DATA "Text Label Two"
    >Disp03 DATA "Text Label Three"
    >etc.
    >
    >I recently moved these to another bank to conserve code space,
    >however, the way I wrote my print routine (Which is similar to all
    >my previous code) is:
    >
    >First set the address to the DATA address:
    >
    >DispAdd = Disp01
    >
    >Then call the Display Subroutine:
    >
    >Display:
    > READ DispAdd, Disp
    > IF Disp = 0 THEN DispExit
    > LCDOUT 0, DisplayOn, [noparse][[/noparse]Disp]
    > DispAdd = DispAdd + 1
    > goto Display
    >DispExit:
    > RETURN
    >
    >My problem, is now that I moved the DATA statements to BANK 1 I ca't
    >use DispAdd = [noparse][[/noparse]DATA Label]
    >
    >If I specify the exact address in the BANK 1 area, everything works,
    >but I can't think how to simplify this. Jon? =) Anyone??
    >
    >Chris Savage
    >Knight Designs
    >
    >
    >
    >
    >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.
    >
    >Yahoo! Groups Links
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-10 00:17
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > There is a way to compress messages in the external bank:
    > Msg1 DATA "Short message", 0
    > Msg2 DATA "This is a long message and doesn't play nice with
    > boundaries.", 0
    > Msg3 DATA "Another shorty", 0
    > Back in the main program bank you can add this:

    ---TRIMMED---

    Jon,

    I tried to reply to this when you wrote it, but Yahoo was acting
    up again. Anyway I'm home now, but what I was going to say was, to
    show you how burned out I was at work today, I had to read your
    message twice to see what you were doing, and how. =) Ah well...

    Tomorrow's another day...Thanks again for the help.

    Chris Savage
    Knight Designs
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-10 00:40
    --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
    > Hi Chris,
    > Another method is to to store the DATA in one bank and also
    declare
    > the same labels as constants in the bank where the routine is:
    > Disp01 CON 0 ' 15 "Text Label One",0
    > Disp02 CON 15 ' 15 "Text Label Two",0
    > Disp03 CON 15+15 ' 17 "Text Label Three",0
    > Disp03 CON 15+15+17 ' 16 "Text Label four",0
    > Don't forget to count the null delimiter. The advantage is that
    you
    > get to refer to your messages by name, the disadvantage is that
    you
    > have to count the characters and update the constants if you
    change
    > the DATA.

    Hi Tracy,

    Before I tried anything I read Jon's article on Multi-bank
    programming, then read the one on your website. Having programmed
    for almost 20 years, I find it hard to change my style, so the stack
    pushing/pulling thing wasn't for me (YET!)...However, I did try
    something similar to what you posted, but ultimately went with Jon's
    original idea, which just simplified my own code, which is what I
    culdn't think of at the time.

    > Another solution is to move the small routine that displays the
    data
    > to the other bank along with the DATA. Then use a cross-bank call
    > for the display. That would probably involve an indexing scheme
    like
    > Jon suggested to pick the message to be displayed.

    One of these days I am going to have to actually break yours and
    Jon's multi-bank stuff down and see what really works for me. Seems
    not to long ago someone mentioned doing something similar, and the
    list got on the subject, and I can't remember exactly, but do you
    need to save the variables, or do they remain intact if you simply
    switch banks, and the program has all the exact same declarations &
    variables? Seems to me that would be another option for someone
    like me who uses modular programming using an "overlay" of sub-
    routines.

    Chris Savage
    Knight Designs
Sign In or Register to comment.