Page 32 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 32

Introduction to Microprocessors


                  Notes          .END

                                 .END tells the assembler where the program ends. Any characters that come after .END will not
                                 be utilized by the assembler.





                                          .END does not stop the program during execution. In fact, .END does not even exist
                                    at the time of execution. It is simply a delimiter it marks the end of the source program.


                                                Sometimes there is no ambiguity, such as in the case 3F0A, which is a hex
                                                number, then, we write it as x3F0A.


                                 2.2 The Assembly Process

                                 Before an LC-3b assembly language program can be executed, it must first be translated into a
                                 machine language program, that is, one in which each instruction is in the LC-3b ISA. It is the job
                                 of the LC-3b assembler to perform that translation.
                                 A Two-Pass Process
                                 In this section, we will see how the assembler goes through the process of translating an assembly
                                 language program into a machine language program. You remember that there is in general a
                                 one-to-one correspondence between instructions in an assembly language program and
                                 instructions in the final machine language program. We could attempt to perform this translation
                                 in one pass through the assembly language program, the assembler discards lines 01 to 09, since
                                 they contain only comments. Comments are strictly for human consumption; they have no bearing
                                 on the translation process. The assembler then moves on to line 0A. Line 0A is a pseudo-op; it
                                 tells the assembler that the machine language program is to start a location x3000. The assembler
                                 then moves on to line 0B, which it can easily translate into LC-3b machine code. At this point, we
                                 have
                                 X3000: 0101010010100000
                                 The LC-3b assembler moves on to translate the next instruction (line 0C). Unfortunately, it is
                                 unable to do so, since it does not know the meaning of the symbolic address, PTR. At this point
                                 the assembler is stuck, and the assembly process fails.
                                 To prevent the above problem from occurring, the assembly process is done in two complete
                                 passes (from beginning to .END) through the entire assembly language program. The objective
                                 of the first pass is to identify the actual binary addresses corresponding to the symbolic names
                                 (or labels). This set of correspondences is known as the symbol table. In pass one, we construct the
                                 symbol table. In pass two, we translate the individual assembly language instructions into their
                                 corresponding machine language instructions.
                                 Thus, when the assembler examines line 0C for the purpose of translating LEA R3, PTR during
                                 the second pass, it already knows the correspondence between PTR and x3028 (from the first
                                 pass). Thus it can easily translate line 0C to x3002: 1110011000010011
                                 The problem of not knowing the 16-bit address corresponding to PTR no longer exists.

                                 The First Pass: Creating the Symbol Table
                                 For our purposes, the symbol table is simply a correspondence of symbolic names with their 16-
                                 bit memory addresses. We obtain these correspondences by passing through the assembly
                                 language program once, noting which instruction is assigned to which address, and identifying
                                 each label with the address of its assigned entry. Recall that we provide labels in those cases



        26                               LOVELY PROFESSIONAL UNIVERSITY
   27   28   29   30   31   32   33   34   35   36   37