News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

How to create a macro?

Started by FiremanTR, Apr 06, 2021, 08:38 PM

Previous topic - Next topic

FiremanTR

I'm not enough about macro, I want to learn this topic. What is the procedure for creating a macro?
The best thing I know is that I know nothing
__SOCRATES__

RGV250

Hi,
Macro's are not really used now since Les has created the brilliant procedures. Have a look in the manual for that, I am not sure if there are any examples.

Bob

m.kaviani

Quote from: FiremanTR on Apr 06, 2021, 08:38 PMI'm not enough about macro, I want to learn this topic. What is the procedure for creating a macro?
we are one step after Assembly language.

top204

#3
Before I created procedures in the compilers, macros were a powerful mechanism for calling a subroutine with parameters and returning a value from a subroutine, and I designed them so I could test the compiler when I was first creating it, but their principle leaked out over time, and other, clever users, started using them as well.

I brought macros in the high-level BASIC command set and they were so flexible another compiler company took the principle I created and used it in their compiler, but without any recognition to me whatsoever. :-(

However, now that the 8-bit compiler has true procedures as well, the original macros are not required anymore in any way, shape or form. They also had some pitfalls because the macros were only ever seen at the assembling stage, so it did not stop the compiler from using library routines that were not required because the macro was not used, because the compiler, by that stage, had created the code inside them, and it was the assembler that did not use them in the code it produced, but it could do nothing about the library subroutines because they are in absolute control of the compiler only. Unlike procedures that will not use any part of their internal code, unless they are used in a program. Making true libraries possible. Even syntax errors and nonsense can be placed in a procedure and they will not be recognised by the compiler unless they are used, then the parser sees them. That's how independent procedures are!