[SOLVED !] Help with Macros


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Help with Macros870 days old

  1. #1
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,269
    Thumbs Up
    Received: 78
    Given: 182
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Help with Macros

    In the past I have created a few simple macros with the excellent "Proton Macro Generator" by John Barret.

    Now I need something a little more complex and I'm lost. I want the macro to be used as

    MacroName "a string of characters"

    and to return the address of the first character (in this case "a") an some word variable.

    If it's possible to do this using the generator and if you've time to walk thro the steps that would be great. Otherwise just the macro would be much appreciated.


    Edit. It occurs to me that it might be helpful to explain what I'm trying to do. I'm writing a compile time debugging tool. I currently have two similar macros that the user adds to the source under test and recompiles. Obviously the additional stuff that is added must be simple, quick to type and not likely to introduce even more bugs. For example my existing macro is used

    Dump n (where n is a byte value which is a pointer to the source)

    that value is passed to the PC client and it uses it, the parsed source and a dump of RAM to determine where the dump happened and the values of all variables.

    I think it might be useful for the code under test to display a string. But the need for simplicity precludes a separate CDATA or such.

    Before anyone asks, yes I am aware of the single stepping debugger but sometimes that overkill and anyway I can't get it work (finger trouble on my end I'm sure).

    From reading old posts I suspect it may not be possible to use a quoted string. Any alternatives?

    Further edit. Not sure if this will help or just muddy the water but here's my existing (working) macro
    Code:
      Dump Macro  P1
      #if (Prm_Count > 1)
          #error "Dump - Too many parameters"
      #else
          #if (Prm_Count < 1)
              #error "Dump - Too few parameters"
          #else
              #if(Prm_1 != Byte) && (Prm_1 != Num8) && (Prm_1 != Num16) && (Prm_1 != Num32)
                  #error "Dump - DumpNum(Param1) Should be a Byte variable or number"
              #endif
              #if (Prm_1 == Byte)
                  Byte_Byte P1, D_DumpID
              #endif
              #if (Prm_1 == Num8)
                  Num_Byte P1, D_DumpID
              #endif
              #if (Prm_1 == Num16)
                  Num_Byte P1, D_DumpID
              #endif
              #if (Prm_1 == Num32)
                  Num_Byte P1, D_DumpID
              #endif
          D_WaitFlag = 0                            ' silly billy
              GoSub D_Dump
          #endif
      #endif
      Endm
    Last edited by towlerg; 11th September 2017 at 14:46.
    George.

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,167
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.90 GB

    1 Not allowed!

    Default Re: Help with Macros

    The only vars you can pass with a macro are byte, word, Dword, float and their signed equivalents so I think you are asking the impossible. You can pass the address of an array/string into a macro or get it returned from a macro but I don't believe there is a mechanism in macros to pass a string. You will have to write your string away in memory and reference it in the macro. You could have a table of descriptor text from which you can choose from the index passed to the macro but I don't think that is really what you are after.

    Sorry I cant help any further.
    JohnB

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,269
    Thumbs Up
    Received: 78
    Given: 182
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Help with Macros

    Thanks John, even a positive negative is helpful.
    George.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    688
    Thumbs Up
    Received: 91
    Given: 2
    Total Downloaded
    4.62 GB

    1 Not allowed!

    Default Re: Help with Macros

    Hi George,
    I do not understand what you want to do exactly.
    But in my GPS code demo, I had written a macro with input of a string. I do not know if it will be useful.
    In this case the name & size of the string are already defined.

    Example:
    ' Definition variables: String ,Float, Float

    $define ConvQTHtoLatLong(pString, pLAT, PLON) '
    InpQTHStrg = pString '
    GoSub ConvertLocToCoordinates_Sub '
    pLAT = LATloc_Dd '
    pLON = LONloc_Dd

    Using the macro:
    ConvQTHtoLatLong("JN11BL", Latitude, Longitude)

    Regards
    ALberto
    73's de Alberto ea3agv

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,269
    Thumbs Up
    Received: 78
    Given: 182
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Help with Macros

    Hi Alberto

    seems like thats exactley what I'm tring to do

    To use your example I want to use the macro

    ConvQTHtoLatLong "JN11BL"

    and return a pointer to the J in the string in a variable and I guess I'd also need the length of the string (didn't think of that before). Looks like the string in your examle is fixed.

    Can I omit the brackets? (less typing).

    I didn't know about Pstring.

    Where did you find info about macros? they are barely mentioned in the manual
    George.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,167
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.90 GB

    1 Not allowed!

    Default Re: Help with Macros

    In Alberto's example he used the pre-processor, whereas you were trying to this with an assemble macro. Arguably you could replace all the assembler macros with pre-processor directives which would make it more consistent.
    JohnB

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,479
    Thumbs Up
    Received: 72
    Given: 30
    Total Downloaded
    6.54 GB

    1 Not allowed!

    Default Re: Help with Macros

    George,

    pString is a name that Alberto gave to his routine. I use the same method with variable length of string.
    Regards

    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    688
    Thumbs Up
    Received: 91
    Given: 2
    Total Downloaded
    4.62 GB

    1 Not allowed!

    Default Re: Help with Macros

    Hi George,
    Using the built-in ISIS in the compiler, which is great, you can try some things.
    I've tried writing a macro that could summarize your needs, I expect.
    Brackets define the String, it is mandatory.

    Example:
    Code:
    '    Include "Proton18_4.inc"
    '    Include "Proton18_8.inc"
        Include "Proton18_16.inc"    
        
        Dim MyString As String * 25 ' The string must be large enough for all strings.
        Dim MyStringPointer As Byte ' Or a Word
        Dim LenghtOfString As Byte
        
        '---------------------------------------------------------------------------
        GoTo Main
        ' Place for macros
        $define TestString(pString, pStrgPointer, pStrgLenght) '
        Clear MyString                   '
        MyString = pString               '
        pStrgPointer = VarPtr MyString   '
        pStrgLenght = Len(MyString)
        
        '---------------------------------------------------------------------------    
        Main:
        Cls
    (*
        What the macros does.
        Clear MyString                      ' Write 0's in the string.
        MyString = "Hello World"            ' Load a string into a defined string.
        MyStringPointer = Varptr MyString   ' The pointer is always the same because the string is defined yet.
        LenghtOfString = Len(MyString)      ' Lenght of the loaded string.
    *)    
    
        TestString("Hello World", MyStringPointer, LenghtOfString)
    
        Print At 1,1, "Address: ", Dec MyStringPointer   ' Address in RAM memory
        Print At 2,1, "Lenght: ", Dec LenghtOfString    
    
        ' Another test
        DelayMS 3000
        TestString("Testing a String", MyStringPointer, LenghtOfString)
    
        Print At 1,1, "Address: ", Dec MyStringPointer
        Print At 2,1, "Lenght: ", Dec LenghtOfString 
    
        End
    Regards
    Alberto
    Last edited by AlbertoFS; 12th September 2017 at 19:37.
    73's de Alberto ea3agv

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    688
    Thumbs Up
    Received: 91
    Given: 2
    Total Downloaded
    4.62 GB

    1 Not allowed!

    Default Re: Help with Macros

    Sorry, maybe you wanted it this way.
    Code:
    '    Include "Proton18_4.inc"
    '    Include "Proton18_8.inc"
        Include "Proton18_16.inc"    
        
        Dim MyStringPointer As Byte
        Dim LenghtOfString As Byte
    '    Dim MyString1 As String * 11
    '    Dim MyString2 As String * 16
    '    Dim MyString3 As String * 17
    
        Dim MyString1 As String * 30
        Dim MyString2 As String * 30
        Dim MyString3 As String * 30        
        '---------------------------------------------------------------------------
        GoTo Main
        ' Place for macros
        $define TestString(pString, pStrgPointer, pStrgLenght) '
        pStrgPointer = VarPtr pString                          '
        pStrgLenght = Len(pString)
        
        '---------------------------------------------------------------------------    
        Main:
    (*
        What the macro does.
        MyStringPointer = Varptr MyString1   ' The pointer is always the same because the string is defined yet.
        LenghtOfString = Len(MyString1)      ' Lenght of the loaded string.
    *)    
        MyString1 = "Hello World"
        MyString2 = "Testing a string"
        MyString3 = "Macro for Strings" 
    
        TestString(MyString1, MyStringPointer, LenghtOfString)
        HRSOut "Address String1: ", Dec MyStringPointer,13,10
        HRSOut "Lenght String1:  ", Dec LenghtOfString,13,10    
        HRSOut 13,10
    
        ' Another test
        TestString(MyString2, MyStringPointer, LenghtOfString)
        HRSOut "Address String2: ", Dec MyStringPointer,13,10
        HRSOut "Lenght String2:  ", Dec LenghtOfString,13,10    
        HRSOut 13,10
        
        ' Another test    
        TestString(MyString3, MyStringPointer, LenghtOfString)
        HRSOut "Address String3: ", Dec MyStringPointer,13,10
        HRSOut "Lenght String3:  ", Dec LenghtOfString,13,10    
        
        End
    Regards
    Alberto
    73's de Alberto ea3agv

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,269
    Thumbs Up
    Received: 78
    Given: 182
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Help with Macros

    @Johnb You are working under the delusion that I know the difference between a macro and the preprocessor, which sadly is not the case. The level of confusion re. macros, Proton preprocessor and MPASM # thingies is hard to quantify, so lets just say terminal.

    @Alberto stupid of me to want a string, pointer and length. If I have the string in a variable by default I have a pointer and the length is just LEN. In an earlier post I asked where to got info re. macros. So as we're using the Proton preprocessor not macros let me ask again, where did you get info about Proton preprocessor? in particular passing parameters, there's nothing in the manual.

    Just looked in manual for macro and found a bunch of Amicus macros. Are they macros or are they preprocessor (looks like preprocessor but called macros) for example "Amicus18_ADC.inc" ?
    George.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #11
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    688
    Thumbs Up
    Received: 91
    Given: 2
    Total Downloaded
    4.62 GB

    1 Not allowed!

    Default Re: Help with Macros

    Hi George,
    You can find information about the pre-processor on page 412 of the manual. I know it is not enough to know everything concerning the use of macros by the pre-processor.
    I have had to learn by reading and studying all the macros written by Les. Sometimes you can merge the pre-processor with a macro in assembler to get a particular application. You can find many examples in the Les's libraries or reading my projects/libraries that I wrote on the wiki.

    Sorry for not understanding your request earlier. Sometimes I find it difficult to understand some questions. I do not speak english.
    Regards
    Alberto
    73's de Alberto ea3agv

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #12
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,269
    Thumbs Up
    Received: 78
    Given: 182
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Help with Macros

    Thanks Alberto. No worries about you're English, you seem to manage just fine.
    George.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #13
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,838
    Thumbs Up
    Received: 90
    Given: 34
    Total Downloaded
    4.60 GB

    0 Not allowed!

    Default Re: Help with Macros

    You're not alone George. I'm also totally confused. We really need an article in the WIKI or a new section in the manual. Maybe Les's new book will.
    John

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #14
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,269
    Thumbs Up
    Received: 78
    Given: 182
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Help with Macros

    Right, having dealt with the strings distraction (thanks again Alberto) I return to my "macro" issue.

    So I know now that I can't use an assembler macro (thanks again John).

    The Proton preprocessor will let me copy a parameter into a string variable and run a sub, as in
    Code:
    $define SomeMacroName(NameOfQuotedString) '
        StringVariable= NameOfQuotedString'
        GoSub PerformSomeFunction
    to be used as

    SomeMacroName("arbitrary string of text")

    and the net result will be that StringVariable = arbitrary string of text and PerformSomeFunction is called.

    so far so good

    but what if I don't want to use memory for a temporary buffer. Can I access the string in ROM?

    Looking at the .lst file looks like its not possible. The compiler creates the string/strings inside its runtime, accessed by its/their label.

    BTW Alberto, this is the reason I wanted a pointer and a length.

    Looks like I'm s**t out of luck. Anyone?
    Last edited by towlerg; 14th September 2017 at 14:47.
    George.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #15
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    688
    Thumbs Up
    Received: 91
    Given: 2
    Total Downloaded
    4.62 GB

    0 Not allowed!

    Default Re: Help with Macros

    Hi George,
    Exactly, everything I comented you, the "Strings" were loaded in RAM memory in runtime.

    I began to understand your question and it is not possible because you can not know the Label names in ROM in advance.
    Would not it be easier to write the Strings in ROM with Cdata and then load the Strings Buffers into RAM with the ROM strings?
    It is easy.
    Regards
    Alberto
    P.S. Maybe if you explained the application, we could help you in another way.
    Please send me an e-mail. (possible solution)
    Last edited by AlbertoFS; 14th September 2017 at 16:03.
    73's de Alberto ea3agv

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Help with Macros and the Preprocessor
      By johngb in forum Proton Plus Compiler v3
      Replies: 5
      Last Post: 31st August 2011, 22:18
    2. SPI Macros
      By dmTulsa in forum Proton Plus Compiler v3
      Replies: 4
      Last Post: 14th May 2010, 16:34
    3. [SOLVED !] MACROS - Please be gentle
      By Barry in forum Proton Plus Compiler v3
      Replies: 3
      Last Post: 29th January 2010, 01:14
    4. [SOLVED !] SD Macros
      By Mike B in forum Proton Plus Compiler v3
      Replies: 8
      Last Post: 17th October 2008, 00:53
    5. [SOLVED !] Help with macros
      By the.fox in forum Proton Plus Compiler v3
      Replies: 4
      Last Post: 14th April 2005, 19:55

    Tags for this Thread

    Posting Permissions

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