Embedded Strings in your Code Space


Closed Thread
Results 1 to 40 of 50

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    "DA" works fine with anything under 128, so 10,13 isn't a problem.
    Code:
       da  "Danger Will Robinson",13,10,0
    But you're right. Unless you are using an 18F part, if you want 8-bit data, it will take 2x the code space.
    Last edited by Darrel Taylor; - 27th August 2005 at 20:45.
    DT

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm i already tried the above... MIIIIIIIIP doesn't work. GOT YA... for the first time in my life... probably the last too

    We must send a 14 bit pack stuff... as it's suppose to!

    So i just found that
    Code:
    @ da "This is a string....",0x068a,0
    the above will send cr+lf.

    Sounds like
    Code:
    CR con 13
    LF con 10
    CRLF var WORD
    
    CRLF.HighByte=CR
    CRLF=CRLF>>1
    CRLF.LOWBYTE=CRLF.LowByte | LF
    it works... just harder to figure out. BAH could be worst. And BTW, a 18F will be more appropriate for that.

    About the String placement... you're right. As i figure to place all string at the top, it shouldn't be a problem. All the string together. Make it easy if some modification have to be done.
    Last edited by mister_e; - 27th August 2005 at 21:14.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm, another solution...
    Code:
    String1 da "My string",13,10,"blah blah",13,10,125,126,127,0
    Just modify a little bit the StringOut Sub
    Code:
    StringOut:  ' Send the string out via Hserout
        Readcode Addr, TwoChars       ' Get the 14 bit packed characters
        Char = TwoChars >> 7          ' Separate first char
        if Char then                  ' Look for Null char, Stop if found
           hserout [Char]             ' Send first char
           endif
    
        Char = TwoChars & $7F         ' Separate second char
        if Char then                  ' Look for Null char, Stop if found
           hserout [Char]             ' Send the second char
           Addr = Addr + 1            ' Point to next two characters
           goto StringOut	          ' Continue with rest of the string
           endif
    return
    that way it works. BUT it don't take all the advantage of the 14 BIT pack stuff. It's just more readable the the previous.
    Last edited by mister_e; - 27th August 2005 at 21:21.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hmmmpf,

    Apparently, none of them are right.

    With mine, it puts 00's in front of each byte (13,10), that will cause the send routine to terminate early.

    With the 0x068a, if there's an ODD number of characters in the string, it will pad the string with a 00, again causing the send routine to terminate early.

    So there doesn't seem to be a way to add CRLF on the end of a string with "DA".

    Your program seems to have an advantage after all. My apologies.
    <br>
    DT

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    How dare you fix my program while I'm still posting that you were right!

    Ha ha, Good job!
    <br>
    DT

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK as i will probably never happen again, i'll write the date/month/year in my notebook with the note
    once in my life, i beat Mr Darrel Taylor
    THE Canadian 1
    United State 0
    Just kidding Darrel I learn a lot from all of your previous posts.

    Keep up the good work !!!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh shoot,

    Still has that "Padding the string" problem.

    Code:
    010D   26F9 1073 3A72 00255 String1 da "My string",13,10,"blah blah",13,10,125,126,127,0
           34EE 3380 000D
           000A 316C 30E8
           1062 3661 3400
           000D 000A 007D
           007E 007F 0000
    Sendstring still terminates early if the string has an ODD number of charaters.

    Almost there.

    P.S.
    THE Canadian 0.99
    <br>
    Last edited by Darrel Taylor; - 27th August 2005 at 22:02.
    DT

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Maybe this...
    Code:
    StringOut:  ' Send the string out via Hserout
        Readcode Addr, TwoChars       ' Get the 14 bit packed characters
        IF TwoChars <> 0 then
            Char = TwoChars >> 7      ' Separate first char
            if Char then              ' Look for Null char, Don't send if found
               hserout [Char]         ' Send first char
            endif
    
            Char = TwoChars & $7F     ' Separate second char
            if Char then              ' Look for Null char, Don't send if found
               hserout [Char]         ' Send the second char
           endif
           Addr = Addr + 1            ' Point to next two characters
           goto StringOut	          ' Continue with rest of the string
        ENDIF
    return
    DT

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hmmpff... is it me or
    Code:
        IF TwoChars <> 0 then
    is unecesary since we check both character anyway???
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Please help with storing strings in codespace
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th May 2008, 01:02

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts