The Gateway to Computer Science Excellence
+4 votes
382 views

Write short answers to the following:

(i). Which of the following macros can put a macro assembler into an infinite loop?

.MACRO MI,X
.IF EQ,X
M1 X+1
.ENDC
.IF NE,X
.WORD X
.ENDC
.ENDM
.MACRO M2,X
.IF EQ,X
M2 X
.ENDC
.IF NE,X
.WORD X+1
.ENDC
.ENDM 

Give an example call that does so.

in Compiler Design by Veteran (52.2k points) | 382 views
0
plz solve this

1 Answer

+1 vote
Best answer
Macro $M_2$ can put the macro assembler into an infinite loop when called with $M_2(0)$

$(EQ(X)$ is TRUE when $X = 0)$

For $M_1$ the argument $X$ is incremented for the recursive call and so the macro expansion will happen maximum $2$ times.
by Veteran (424k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,458 answers
195,367 comments
100,250 users