building own library with include-files?


Results 1 to 26 of 26

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    mischl,

    Well, since you said "what is exactly the definition of a macro...",   this is the way the MPASM.hlp file defines it.
    Macros are user defined sets of instructions and directives that will be evaluated in-line with the assembler source code whenever the macro is invoked.

    Macros consist of sequences of assembler instructions and directives. They can be written to accept arguments, making them quite flexible. Their advantages are:

    Higher levels of abstraction, improving readability and reliability.
    • Consistent solutions to frequently performed functions.
    • Simplified changes.
    • Improved testability.
    Applications might include creating complex tables, frequently used code, and complex operations.
    But that doesn't really do justice to what you can do with them.

    Macro's are simply a way of grouping bits of code together, so that with a single command, you can place many lines of code in your program at the point where the command is used. And, since they can accept "Parameters", they can work a lot like "Functions" in other languages.

    They are strictly assembly language directives, but since PBP converts your Basic code into assembly language before it is compiled, they work quite well with PBP too.   In fact, the entire PicBasic language is built around macro's.

    The biggest thing to remember is that each time you reference a macro, the Entire code contained in the macro is copied into the program. So if you use a macro 10 times in your program, you will use up ten times as much code space. That's not quite as bad as it sound though, because you can create normal subroutines in PBP that are "Called" by the macro (like a GOSUB), and then all the macro needs to do is pass the parameters to it like a "Function".

    If you look at the LCDbar_INC.bas file from the BARgraph example, you can see how that works. The BARgraph macro is only there to pass the parameters to the "ShowBAR:" subroutine.<hr>INCLUDE files are similar in only one respect. They also place a group of code at the location that the INCLUDE statement is placed in your program. But, the similarities end there. INCLUDE files do not have to be Assembly language, they can be 100% PBP statements, or they can be a mix of PBP and ASM. They can NOT accept parameters. Macro's inside of Include files seems to be the most usefull combination though.

    A good place to start might be with the MPASM.HLP file. Assuming you have MPASM installed on you computer.
    On my computer the help file can be found here...C:\WINDOWS\Help\MPASM.HLP but some installations are different.

    After that, start reading the "Instruction Set" section of the datasheet for the PIC you are using. They all have that section.

    It's a little tough to grasp in the beginning, but once you catch on, all those things you thought couldn't be done with PicBasic, are suddenly within reach again.

    HTH,
    &nbsp;&nbsp;&nbsp;Darrel

    PS. Stump, that's a nice use of includes, hadn't thought of that one.
    Last edited by Darrel Taylor; - 21st September 2005 at 19:40.

Similar Threads

  1. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 22:42
  2. Can't seem to add AllDigital to the include files
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th November 2009, 05:21
  3. Missing 16F882 family include files :-(
    By campmdabt in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th December 2007, 02:17
  4. include files 8k limit
    By skimask in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th January 2006, 07:35
  5. Replies: 2
    Last Post: - 13th December 2005, 01:11

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