What Is a Macro Instruction?
A macro is a pseudo-instruction in an assembly language program.
- Chinese name
- Macro
- Macro
- A pseudo-instruction in an assembly language program
- The format is
- [Macro name] MACRO [Formal parameter]
- Macro call format
- [Macro name] [Actual parameters]
- Attributes
- Pseudo-instruction
- Field
- computer
- A macro is a pseudo-instruction in an assembly language program.
- A macro is a piece of source program that represents a function.
- Its format is
- [Macro name] MACRO [Formal parameter]
- ...
- Snippet
- ...
- ENDM
- E.g:
- MOV_ macro f1, f2
- mvl f1, w, acce; put the data in f1 address into W register, the data in f1 is unchanged
- mvf f2, w, acce; put data in W register to f2 address
- ENDM; this instruction is equivalent to assigning the data in f1 to f2, and the data in f1 is unchanged
- "Formal parameters" are used and they are replaced by names or values (real parameters) given when referring to the macro. The use of formal parameters gives great flexibility to macros.
- Macro call format
- [Macro name] [Actual parameters]
- The real parameter item will correspond to the formal parameter in the replacement macro instruction. If the formal parameter is a label, then in the macro call, the actual parameter should also be a label, and the actual parameter is required to be unique. If the macro definition has its own label, the assembler automatically turns the label into a unique label when the macro is called.