macros including assembler directives


+ Reply to Thread
Results 1 to 12 of 12

Thread: macros including assembler directives2109 days old

  1. #1
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default macros including assembler directives

    In Proton 8bit I wrote a number of macros including assembler directives like this:
    aMacro Macro aParameter
    #if (Prm_1 == BYTE)
    Byte_byte aParameter, aVariable
    #endif
    Endm

    When I try this in Proton 24 I get error messages "non-constant expression in ".if" statement.

    Has the syntax been changed, if so, could I get an overview of how to do it for the 16 bit family.

  2. 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. #2
    Senior Member DaveS's Avatar
    Join Date
    Aug 2004
    Posts
    904
    Thumbs Up
    Received: 10
    Given: 3
    Total Downloaded
    1.72 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    As far as I know asm macros are not officially supported in any version

    Might be worth trying
    Preprocessor directives
    $define
    sizeof

    16 bit asm not a clue
    Regards
    Dave

  4. 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. #3
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Hi Dave,

    Maybe you're right about the 'official' part of it.
    If you take a look at John Barrat's P-RTOS project you'll see there's a separate file 'P-RTOS Macros.inc' that's really loaded with stuff like this.

    John has built a macro generator wizard for his libraray manager that does a very nice job.
    Take a look at this one, generated with the wizard:
    Code:
    TestMacro Macro  P1, P2
    #if (Prm_Count > 2)
        #error "TestMacro - Too many parameters"
    #else
        #if (Prm_Count < 1)
            #error "TestMacro - Too few parameters"
        #else
            #if(Prm_1 != Byte) && (Prm_1 != Num8) && (Prm_1 != Num16) && (Prm_1 != Num32) && (Prm_1 != Word) && (Prm_1 != Dword)
                #error "TestMacro - aCommand(Param1) Should be a Byte, Word, DWord, variable or number"
            #endif
            #if (Prm_Count > 1)
                #if(Prm_2 != Byte) && (Prm_2 != Num8) && (Prm_2 != Num16) && (Prm_2 != Num32) && (Prm_2 != Word) && (Prm_2 != Dword)
                    #error "TestMacro - data1(Param2) Should be a Byte, Word, DWord, variable or number"
                #endif
            #endif
            #if (Prm_1 == Byte)
                Byte_Byte P1, vh
            #endif
            #if (Prm_1 == Num8)
                Num_Byte P1, vh
            #endif
            #if (Prm_1 == Num16)
                Num_Byte P1, vh
            #endif
            #if (Prm_1 == Num32)
                Num_Byte P1, vh
            #endif
            #if (Prm_1 == Word)
                Byte_Byte P1, vh
            #endif
            #if (Prm_1 == Dword)
                Byte_Byte P1, vh
            #endif
            #if (Prm_Count > 1)
                #if (Prm_2 == Byte)
                    Byte_Byte P2, vl
                #endif
                #if (Prm_2 == Num8)
                    Num_Byte P2, vl
                #endif
                #if (Prm_2 == Num16)
                    Num_Byte P2, vl
                #endif
                #if (Prm_2 == Num32)
                    Num_Byte P2, vl
                #endif
                #if (Prm_2 == Word)
                    Byte_Byte P2, vl
                #endif
                #if (Prm_2 == Dword)
                    Byte_Byte P2, vl
                #endif
            #endif
            GoSub mycommand
        #endif
    #endif
    Endm
    It compiles without a problem with the 8 bit compiler, but any line containing something like "#if (Prm_1 == Byte)" results in errors in Proton24.
    The line "#if (Prm_Count > 2)" is accepted by P24.
    Must be something with the 'qualifiers' like "Byte" and "Num8". But these are necessary to determine if a parameter is a value or a variable and to perform the correct conversion (Num_Byte or Byte_Byte).
    By the way, you can't find the 'qualifiers' like "Num8" in the protected words in any of the manuals, but I assure you they work with the 8 bit compiler.

    The $define etcetera works ok

    Regards
    Harm
    Last edited by hadv215; 27th August 2014 at 23:19.

  6. 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. #4
    cgriffin
    Guest cgriffin's Avatar

    0 Not allowed!

    Default Re: macros including assembler directives

    The PIC24 compiler uses a different assembler; check here for syntax--I believe this is the one:
    http://ww1.microchip.com/downloads/e...Doc/51317j.pdf

    Here is a sample macro with arguments and conditional compilation:
    Code:
    .macro ADD_CONST_REGint Const, ToReg    
        .if (\Const < 1024)
            add #\Const, w\ToReg
        .else
            Mov #(\Const & 0xFFFF), w0
            add w0, w\ToReg, w\ToReg
        .endif
    .endm
    The hashtag # denotes a constant.
    The backslash \ marks a macro argument for replacement.
    Last edited by cgriffin; 30th August 2014 at 16:50.

  8. 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. #5
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,188
    Thumbs Up
    Received: 98
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Unless Les has put in the support I am not sure you will be able to use these in the same way that I use them in the 8 bit assembler.Without the ability to pass variables to the macros their value would be limited.

    I guess you will give it a go Harm, let me know how you get on, if its a success I will look at adding it to the Macro Generator for PDS
    JohnB

  10. 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. #6
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    @cgriffin: Thank you for the document, surely looks instructive to me and I will definitely try this out.
    @JohnGB: you will hear from me within short. But I did not find an equivalent for "== BYTE". Let's just find out.

    Regards
    Harm

  12. 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. #7
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,188
    Thumbs Up
    Received: 98
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Hopefully Les can give us a definitive answer
    JohnB

  14. 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. #8
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,599
    Thumbs Up
    Received: 341
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    There is very limited support for Asm macros in Proton24, however, they are very much redundant because it is a procedural language. But, as John stated, Proton24 uses a different assembler with a different syntax. I've tried to match the #if, #endif etc... directives, but this will only work if used in BASIC. As soon as anything is wrapped in Asm-EndAsm, the assembler's syntax will need to be used.

    Using procedures and pre-processor macros, will accomplish everything that is required.

  16. 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.

  17. #9
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,188
    Thumbs Up
    Received: 98
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Thanks - that all makes sense.
    JohnB

  18. 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.

  19. #10
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Thanks Les, that's the info I needed.
    I was hoping to use the same syntax for both 8 and 16 bit.

    Regards
    Harm

  20. 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.

  21. #11
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,599
    Thumbs Up
    Received: 341
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Also note that the types of the parameters needed changing because they clashed with the assembler. i.e. Byte, Word etc..

    See the asm file (press F2) and there is a list of variable types (This should always be the first port of call when using macros because they belong to the assembler):

    .set type_prm_empty, 0
    .set type_bit, 1
    .set type_byte, 2
    .set type_word, 3
    .set type_dword, 4
    .set type_sbyte, 2
    .set type_sword, 3
    .set type_sdword, 4
    .set type_float, 5
    .set type_label, 6
    .set type_char, 7
    .set type_string, 9
    .set type_num8, 8
    .set type_num16, 16
    .set type_num32, 32
    .set type_snum8, 10
    .set type_snum16, 15
    .set type_snum32, 31
    .set type_fnum, 33
    .set type_double, 11
    .set type_bytearray_ptr, 22
    .set type_wordarray_ptr, 23
    .set type_dwordarray_ptr, 24
    .set type_floatarray_ptr, 25

    So the original macro in the first post (with correction for the AVariable parameter):

    aMacro Macro aParameter, aVariable
    #if (Prm_1 == Type_Byte)
    Byte_byte aParameter, aVariable
    #endif
    Endm

    Compiles and works as expected.

    But, as stated, macros are not longer required in Proton24, and are not recommended for new programs.

    Native macros in the Asm30 assembler also have some differences to the Mpasm assembler. i.e. a backslash is required for parameters and it doesn't always assemble if labels are used as parameters. All in all, the Asm30 assembler is a pain to use. I've attempted, as much as possible, to make the macros operate the same as the 8-bit types, but this cannot be guaranteed because of the Asm30 assembler differences.
    Last edited by top204; 1st September 2014 at 16:34.

  22. 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.

  23. #12
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: macros including assembler directives

    Thanks for all the help from everybody.
    At hindsight I did not need the macros in this way, but was able to do what I want using the pre-processor option $define to create procedures taking parameters.
    The good thing about this is that I don't need to check the type of parameter because the compiler handles all this.

    And that is really a great feature of the compiler!

  24. 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. New directives
    By towlerg in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 3rd September 2018, 22:24
  2. Assembler Macros
    By johngb in forum Proton 24
    Replies: 0
    Last Post: 22nd January 2015, 19:01
  3. Preprocessor directives or other help
    By Maxi in forum Proton Plus Compiler v3
    Replies: 9
    Last Post: 15th January 2014, 06:52
  4. Macros and assembler directives
    By johngb in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 2nd November 2011, 11:16
  5. [SOLVED !] Including ASM
    By ADLIN SYSTEMS in forum The Lounge
    Replies: 7
    Last Post: 13th January 2011, 22:28

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