Assemblers may be implemented using 2 or more passes What is
Assemblers may be implemented using 2 or more \'passes\'. What is a \'pass\'? Why is more than one sometimes required?
Solution
single and multi-pass assemblers work. It also explains the pros and cons of both of them and the differences between the two.It is a kind of Load-and-go type of assembler that generally generates the object code directly in memory for immediate execution! It parses through your source code only once and your done. Forward references! ie while the one-pass assembler is trodding along your source code, it encounters some strangers in the form of undefined data symbols and undefined labels(jump addresses). Your assembler asks these strangers as to who are they? The strangers say \" We\'ll tell you later!\" (Forward reference) Your assembler gets angry and tells you to totally eliminate these strangers. But these strangers are your friends and you cant eliminate them totally. So you enter into a compromise deal with the assembler. You promise to define all your variables before using them. The assembler couldn\'t compromise on this because it cannot even reserve temp storage for the undefined data symbols as it doesn\'t know their size. Data can be of varying sizes
On its part your assembler agrees to compromise on undefined jump labels. As jump labels are nothing but addresses and address sizes can be known apriori so that assembler can reserve some definite space for the undefined symbol.
If its like this
Assembler translates jump AHEAD as 0x45 **0x00 0x00**. 0x45 is the opcode of jump and 4 bytes reserved for AHEAD addressSimple, while on its way, if the assembler encounters an undefined label, it puts it into a symbol table along with the address where the undefined symbol\'s value has to be placed, when the symbol is found in future. It does the same for all undefined labels and as and when it sees the definitions of these undefined symbols, it adds their value, both in the table ( thereby making that label defined ) and in the memory location where it had reserved temp storage earlier.
