Directory Image
This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Privacy Policy.

Define Macros? Use of macros in I/C instructions ||

Author: Sushil Sharma
by Sushil Sharma
Posted: Jan 06, 2019

Many assemblers support predefined macros, and other support programmer-defined (and repeatedly re-definable) macros involving sequence of text line in which variables and constants are embedded. this sequence of text lines may include opcodes or directives. Once a macro has been defined its name may be used in place of a mnemonic. When the assembler processes such a statement, it replaces the statement with the text lines associated with that macros, and then processes them as if the existed in the source code file (including, in some assemblers, expansion of any macros existing in the replacement text).

Note that this definition of "macro" is slightly different from the use of the term in other contexts, like the C programming language. C macros created though the #define directive typically are just one line or a few lines at most. Assembler macro instructions can be lengthy "programs" by themselves, executed by interpretation by the assembler during assembly.

Since macros can have 'short' names but expand to several or indeed many lines of code, they can be used to make assembly language programs appear to be far shorter, requiring fewer lines of source code, as with higher level languages. They can also be used to add higher levels of structure to assembly programs, optionally introduce embedded debugging code via parameters and other similar features.

Many assemblers have built-in (or predefined) macros for system calls and other special code sequences, such as the generation and storage of data realized through advanced bitwise and boolean operations used in gaming, software security, data management and cryptography.

Macro assemblers often allow macros to take parameters. Some assemblers include quite sophisticated macro languages, incorporating such high-level language element as optional parameters, symbolic variables, conditionals, string manipulation and arithmetic operations all usable during the execution of a given macro and allowing macros to save context or exchange information.

Thus a macro might generate a large number of assembly language instructions or data definitions, based on the macro arguments. This could be used to generate record-style data structure or "unrolled" loops, for example or could generate entire algorithms based on complex parameters. An organization using assembly language that has been heavily extended using such a macro suite can be considered to be working in a higher-level languages, since such programmers are not working with a computer's lowest-level conceptual elements.

Despite the power of macro processing, it fell into disuse in many high level languages (major exceptions being C/C++ and PL/I) while remaining a perennial for assemblers. Macro parameter substitution is strictly by name: at macro processing time, the value of a parameter is textually substituted for its name. The most famous class of bugs resulting was the use of a parameter that itself was an expression and not a simple name when the macro writer expected a name.

In the macro: foo: macro a load a*b the intention was that the caller would provide the name of variable, and the "global" variable or constant b would be used to multiply "a". If foo is called with the parameter a-c, the macro expansion of load a-c*b occurs. To avoid any possible ambiguity, user of macro processors can parenthesize formal parameters inside macro definitions, or caller can parenthesize the input parameters.

Fore more... https://savageboyss.blogspot.com/2019/01/define-macros-use-of-macros-in-ic.html

About the Author

I.m studying of Computer Application. I thick you should you know about the All types of Hackers are in our world. It's is a educational article.

Rate this Article
Leave a Comment
Author Thumbnail
I Agree:
Comment 
Pictures
Author: Sushil Sharma

Sushil Sharma

Member since: Dec 23, 2018
Published articles: 15

Related Articles