in Compiler Design edited by
1,973 views
7 votes
7 votes

Write short answers to the following:

  1. Which of the following macros can put a macro assembler into an infinite loop?
.MACRO M1,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 edited by
2.0k views

3 Comments

plz solve this
0
0

Macro M1,x

EndM

that means, M1 is a Macro with x as a parameter, ENDM means Macro end.

 

IF EQ,x

ENDC

that means, if condition. EQ,x ... checking x is equal to Something or not ?

 

what M1(x) is doing ? 

checking x is equal to value in the Accumulator, if so, call M1(x+1)

 

what M2(x) is doing ? 

checking x is equal to value in the Accumulator, if so, call M2(x), So this may lead to Infinite loop when if condtion true.

0
0
Is this in the syllabus still for GATE 2024??
0
0

1 Answer

11 votes
11 votes
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

3 Comments

Source for this???
0
0
Why is   

(EQ(X)  TRUE when X=0)   

why is it true for x=0 not for x=1
0
0
@svas7246, is assembler concept in 2022 syllabus?
0
0

Related questions