 Today, we are going to discuss the topic single-pass and two-pass assemblers. At the end of this session, students will be able to distinguish the steps to be performed to develop a single-pass and a two-pass assembler. Let us see the background, language processing involves analysis of a source program plus synthesis of a target program. An assembler, as we know, is a language processor. The source program used by the assembler as input is in assembly language. And the target program, which is synthesized by an assembler, is in the machine language. Therefore, assembler converts an assembly language program to a machine language program. Let us think now on what steps are used to convert a source program in assembly language to a target program in machine language. Let us now understand a particular approach to develop a design specification for an assembler. We follow the steps of identifying the information needed to perform the task or the output. And then we design a suitable data structure for recording the information. We then determine the processing needed for obtaining and maintaining the information and then determine the processing needed to perform the task, that is the output, by using the recorded information, which we have collected before going to actually understand what is the output. We would like to understand what is required in this particular output and the output is the synthesis of the target program. So, for synthesizing a machine instruction corresponding to a source statement, the assembler must know the address of memory words with which symbols are associated and the numeric operation code of the computer that corresponds to the mnemonic. Then we require to have data structures which are going to be defined and generated in previous phases and then used in the synthesis phase. Such two data structures are a symbol table where each entry has a name and an address and a mnemonic's table where each entry field contains a mnemonic, an opcode and the length. Now that we go for the requirements of what has to be done in the analysis phase which precedes the synthesis phase, we determine information from the source program which is in assembly language and record it in the symbol table. We determine the memory addresses with which each symbolic name used in the program is associated. This we do after memory allocation and memory allocation is the function performed by the data structure called as a location counter. A location counter contains the address that the next memory word in the target program should have. It is a pointer to the next memory word and it collects its start address from the start statement which is given as an assembly directive to the assembler. The requirements of the analysis phase involves first the assembler checking for the label in the assembly program and making an entry in the symbol table. It finds out how many memory words are needed for the instruction or data by assembly statement. It updates the address in the location counter. The now location counter contains updated addresses. It takes the length from the mnemonic table. Now what are the tasks to be performed by the analysis phase? First of all, we separate the tokens which are contents of the source program which are the label, the mnemonic opcode and the operand fields of the statement. If a symbol is present in the label field enter the pair which is symbol and the location counter address in the new entry of the symbol table. Check this validity of the mnemonic opcode through the lookup in the mnemonic table and perform location counter processing which involves updating addresses in location counter constring opcodes and operands of the statements. Now what are the tasks which we perform in the synthesis phase? Everything is now captured by the analysis phase and is stored. We obtain now the machine opcode corresponding to the mnemonics from the mnemonic table and the address of each memory operand from the symbol table. These two mnemonic table and symbolic table are created after the analysis phase and now we synthesize the machine instruction or the correct representation of the constant. We first go to the first type of assembler which is a two-pass assembler translation. It consists of two passes, pass 1 and pass 2. In the pass 1, we first pass, we perform analysis of source program and create intermediate representation of this source program for the use by the second pass. We perform the location counter processing which we have explained just before this and we perform the creation of intermediate representations of two data structures. One is the symbol table and the process form of the source program which is also termed as intermediate code. In the second pass, we synthesize the target program by using the address information found in the symbol table. It performs synthesis of the target program finally. Here we note that the forward references are handled naturally because the addresses of each symbol would be known before the program synthesis begins. Therefore, all the symbols are defined and then they are used. Second type of assembler translation which we call as a single-pass assembler, both analysis and synthesis are performed in the same pass whereas in the two passes, in pass 1, we were doing analysis and in pass 2, we are doing synthesis. Here, the location counter processing and the construction of symbol table is done as we were doing in the pass 2 assemblers. The target program constructed in the same pass is then evaluated and the problem occurs of forward references. Now these forward references happen because many of the symbols are used before they are defined. Therefore, we require a technique to then deal with these forward references and that technique is termed as backpatching. Backpatching has a very simple logic. The assembler leaves the operand field of the instruction blank if it contains a forward reference to that symbol. Address of the symbol is put in the operand field sometimes after the definition of the symbol is encountered in the program. It builds a table of incomplete instructions. Each entry which consists of instruction address and a symbol. By the time the end statement is processed, the symbol table contains all addresses of symbols and each entry in a table of incomplete instructions is processed by the assembler. Under understanding the single pass assembler and a two pass assembler, still there are misinterpretations in the minds of students. The pass 1 is the first phase of a two pass assembler and one pass or a single pass assembler is in which passing is done in only a single pass. Pass 1 is the first pass of a two pass translated assembler and one or single pass assembler indicates that translation from source program in assembly language is done to a target code generation in machine language in only a single pass. For our references we have used thank you.