0
votes

While studying COMPILER-DESIGN through an online book from Google-Books,referenced as Compiler Design By A.A.Puntambekar, I got stuck across a line. Actually, I am more curious to know the inner-detail.

The assembler converts the assembly-program to low-level machine language using two passes. A pass means one complete scan of the input program. The end of the second pass is the relocatable machine code.

Why the 2 passes for conversion and what are the phases involved like lexical analysis,syntax analysis,etc while conversion from assembly to machine-code??? I have very less/no idea about it.

If someone over here would like to describe those two-passes or link out to some good resources, I'd be thankful to him/her

1
This is not really a programming question. It's asking about how computers work. Maybe cs.stackexchange.com would be a better fit. (Also, not all assemblers are two-pass assemblers.)Raymond Chen
I guess programmers of assembly and machine-code are more likely to be available here rather than on that website. But,I'll post on that too. Any help about the question? @RaymondChenAm_I_Helpful
@RaymondChen-Asking about code conversion,not computer's working!Am_I_Helpful
You are also more likely to find doctors at the golf course, but that doesn't mean it's okay to go to the golf course and ask people for medical advice.Raymond Chen
You are asking how assemblers work, which is off topic for this site. (Conceptual / too broad.) If you have a specific programming problem, like a program that is not working properly, you can post that question here.Raymond Chen

1 Answers

4
votes

The compiler has to replace labels by their offsets. If you use the name of a label in a earlier line than the label itself, the compiler will have to repass the program for inserting the offset.