I was going through GATE-CS questions, while solving I came across the following question here.

Write short answers to the following:

Which of the following macros can put a macro assembler into an infinite loop?

.IF EQ,X  ;if X=0 then
M1 X+1
.IF NE,X  ;IF X≠0 then
.WORD X   ;address (X) is stored here
M2 X

Give an example call that does so.

The actual question I guess had no explanation of what each line of the macro meant, but here from another site got to know the meaning of the lines apparently.

Please can anyone tell one tell me, what are these types of macros? [I know what are macros in C. Also know that the C processor, substitutes the macros in the actual line of the code. I mean to say that I am not unaware of what macro is but I want to know about it in detail.]

But I want to know what is the syntax of writing these above macros, where are they are used? And the general method/theory of macro expansions. The above question is tagged under "assembler". What is its connection with assembly language? Are these macros written in some assembly language?

Could anyone recommend me a textbook, which shall help me build concepts on these topics? I could not find myself as I do not know what language are these macros are written in, also I do not know their meaning...

  • 2
    $\begingroup$ I doubt you will find a textbook, but there might be a professional book or two. But if you Google "macros in C" you will find some tutorials and such. $\endgroup$
    – Buffy
    Oct 27, 2021 at 16:24
  • $\begingroup$ could you just the professional books $\endgroup$ Oct 27, 2021 at 17:00
  • 1
    $\begingroup$ Sorry, I don't have any to suggest. $\endgroup$
    – Buffy
    Oct 27, 2021 at 18:23
  • $\begingroup$ @Buffy ok now issues $\endgroup$ Oct 27, 2021 at 18:45
  • 1
    $\begingroup$ Re, "What is its connection with assembly language?" Just like how macros are part of the "C" programming language, but not some other programming languages; macros are part of some "assembly" languages (Most famously, Microsoft's MASM language), but not others. Note: I put "assembly" in scare quotes there because MASM somewhat violates the 1:1 correspondence between source code lines and machine instructions that most of us expect from an assembly language. $\endgroup$ Oct 29, 2021 at 16:03


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.