in Compiler Design recategorized by
2,375 views
18 votes
18 votes
State whether the following statements are True or False with reasons for your answer

A subroutine cannot always be used to replace a macro in an assembly language program.
in Compiler Design recategorized by
2.4k views

1 comment

can someone explain in detail ????
0
0

2 Answers

3 votes
3 votes
Best answer

$\textsf{TRUE}.$

A macro is evaluated at compile time whereas a function call happens at runtime. So, we can write a macro to rename any symbol which is not possible to be replaced by a simple subroutine call. For example consider the following $C$ code.

#define type int
type foo (type arg1)
{
    ...
}
#undef type

In the above code a macro is used to define a type which is used as the return and argument types for the function $\textsf{foo}.$ This is not possible to be implemented as a simple subroutine call (but can be done using $\textsf{typedef}$ is the language supports it).

selected by

1 comment

Nice eg.
0
0
22 votes
22 votes
This is true. We can not replace macro entirely using a subroutine. Ex: Macro constant used for renaming.
edited by

4 Comments

@Ayush

by tp what do u mean?

I cannot understand
1
1
#include<stdio.h>

#define ch char

int main()

{

   ch a,b;

   return 0;

}

 

There is No function which can do this work instead of macro

ASSEMBLY ==> SUB-Routine

High-Level ===> Function
0
0
so means we must require coroutine here
0
0
Answer:

Related questions