0% found this document useful (0 votes)
8 views2 pages

Easy Macros With Examples

The document explains three types of macros: Nested, Conditional, and Unconditional. Nested macros call other macros within their body, allowing for reusable code; Conditional macros expand based on specific conditions using commands like AIF and AGO; Unconditional macros expand the same way regardless of input, simplifying repetitive tasks. Each type is illustrated with examples to demonstrate their functionality.

Uploaded by

billybutcherdyw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Easy Macros With Examples

The document explains three types of macros: Nested, Conditional, and Unconditional. Nested macros call other macros within their body, allowing for reusable code; Conditional macros expand based on specific conditions using commands like AIF and AGO; Unconditional macros expand the same way regardless of input, simplifying repetitive tasks. Each type is illustrated with examples to demonstrate their functionality.

Uploaded by

billybutcherdyw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Q. Explain Nested, Conditional, and Unconditional Macros.

(10 Marks)

1. Nested Macros

1. A nested macro is a macro that calls another macro inside its body.

2. The macro that calls is the outer macro; the one being called is the inner macro.

3. When expanded, the inner macro expands first, then the outer macro completes.

4. It uses the Last In First Out (LIFO) method to expand the macros.

5. It helps in writing reusable and structured code.

6. Nested macros are helpful in situations where repeated operations are required within other

operations.

7. Example:

MACRO INNER X

ADD AREG, X

MEND

MACRO OUTER A, B

MOVER AREG, A

INNER B

MEND

OUTER DATA1, DATA2

2. Conditional Macros

1. Conditional macros expand differently depending on the condition given.

2. They use commands like AIF (Arithmetic IF) and AGO (Arithmetic Go To) to control the flow.

3. AIF checks a condition, and if true, it jumps to a label.

4. AGO always jumps to a given label without checking anything.

5. These macros are useful when we want to perform different tasks based on input values.

6. You can also use IF-ELSE-ENDIF and WHILE-ENDW structures for more complex conditions.
7. Example:

MACRO TEST BA, BB, &C

AIF (BB EQ BA).ONLY

MOVER AREG, BA

SUB AREG, BB

ADD AREG, &C

AGO .OVER

.ONLY MOVER AREG, &C

.OVER MEND

TEST 5, 5, VALUE

3. Unconditional Macros

1. Unconditional macros always expand the same way no matter what the input is.

2. They do not check any condition or perform any branching.

3. They are useful for repeating a fixed set of instructions.

4. These macros save time and reduce writing the same code again and again.

5. Unconditional macros are very simple and easy to use.

6. Every time you call them, the exact same instructions are inserted.

7. Example:

MACRO LOADREG X

MOVER AREG, X

ADD AREG, B

MEND

LOADREG DATA1

You might also like