Embedded strings in code mpasm error


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    My chip is a 18f4620.

    This is basically the code (Below) I am trying to use. It did work just a few days ago but now is compiling with the error I had listed.
    Really I am only posting the part of the code that is failing to compile. Problem with "Wout".

    Code:
    '****************************************************************
    '*  Name    : STRINGS-16.PBP                                    *
    '*  Author  : Darrel Taylor                                     *
    '*  Date    : 6/12/2005                                         *
    '*  Note:  Strings must be NULL Terminated                      *
    '****************************************************************
    DEFINE LOADER_USED 1       ' If using bootloader
    DEFINE OSC 4
    DEFINE HSER_TXSTA  24h     ' Use this for Higher Baud Rates
    DEFINE HSER_SPBRG  25      ' 9600 Baud at 4mhz
    
    Addr        var word
    Char        var byte
    
    Clear
    
    goto StartLoop ' Required
    
    String1:
    @ da "This is a string",0
    
    AnotherString:
    @ da "Here is another string",0
    
    '------------GetAddress Macro - Location insensitive -------------------------
    ASM
    GetAddress macro Label, Wout       ; Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    
    
    StartLoop  ' This loop repeats continuously just as a test.
       @ GetAddress _String1, _Addr        ' Get address of String
       gosub StringOut                     ' Send the String
       hserout [13,10]                     ' New Line
    
       @ GetAddress _AnotherString, _Addr  ' Get address of String
       gosub StringOut                     ' Send the String
       hserout [13,10]                     ' New Line
       pause 500
    goto StartLoop                         ' Repeat
    
    
    StringOut:  ' Send the string out via Hserout
        Readcode Addr, Char           ' Get a character
        if Char  = 0 then StringDone  ' Look for Null char, Stop if found
        hserout [Char]                ' Send char
        Addr = Addr + 1               ' Point to next character
        goto StringOut                ' Continue with rest of the string
      StringDone:
    return
    
    
    end
    Last edited by BrianS; - 23rd August 2010 at 18:24.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Is Wout defined as a VAR?
    In the ASM part
    _Wout
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2010
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    It is used in C:\PBP\PBPPI18L.LIB but does not seem to be declared as a var in that file.


    Quote Originally Posted by mackrackit View Post
    Is Wout defined as a VAR?
    In the ASM part
    _Wout

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi, Brian

    Darrel's code compiles without any problem, either with MPLAB 8.56 or MCS
    PBP is 2.60 a

    soooo ... error is elsewhere ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    It compiles fine on my laptop too, and did compile on my work computer also. But not today. Now it is giving those stated errors and I'm trying to track down what is causing it. I am trying to figure out why "wout" is showing up as not defined on my work computer.

    Brian

    Quote Originally Posted by Acetronics View Post
    Hi, Brian

    Darrel's code compiles without any problem, either with MPLAB 8.56 or MCS
    PBP is 2.60 a

    soooo ... error is elsewhere ...

    Alain

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Wout doesn't get defined as a variable. It's an argument passed to the macro at the time the macro is invoked.

    Example: @ GetAddress _String1, _Addr

    The address of String1 gets passed to the macro as the Label argument. The address of your word variable Addr gets passed to the macro as the Wout argument.

    You most likely have wout somewhere VS Wout and have case sensitivity turned ON in MPASM. Start MPASMWIN.EXE and uncheck the case sensitivity option.

    The error from the library file is where the CHK?RP macro can't find Wout either.

    Your code as posted above compiles fine here.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Jul 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Found the problem. Also sorry for the confusion and appreciate all your help. The cause of the problem was bad commenting in the inline assembly. It is not apparent in my posted code as I copied that from my backup code. Seems I was sticking to the PBP way of commenting even in inline assembly.

    Here is why it wouldn't compile.

    Code:
    Bad Code
    
    ASM
    GetAddress macro Label, Wout       'Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    
    Good Code
    
    ASM
    GetAddress macro Label, Wout       ;Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    Once again thanks for for help. Didn't catch this to easily as it looked normal to me to use a ' instead of a ;
    Maybe something for others to watch out for too.
    Thanks,
    Bryan

Members who have read this thread : 0

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