Textbook recommendation for macros and assembler

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?

.MACRO M1,X
.IF EQ,X  ;if X=0 then
M1 X+1
.ENDC
.IF NE,X  ;IF X≠0 then
.WORD X   ;address (X) is stored here
.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.

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...

• 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. Oct 27, 2021 at 16:24
• could you just the professional books Oct 27, 2021 at 17:00
• Sorry, I don't have any to suggest. Oct 27, 2021 at 18:23
• @Buffy ok now issues Oct 27, 2021 at 18:45
• 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. Oct 29, 2021 at 16:03