An assembler is a program that converts assembly language code into machine language code. It has two passes: in the first pass, it scans the program and builds a symbol table with label addresses; in the second pass, it converts instructions to machine language using the symbol table and builds the executable image. The assembler converts mnemonics to operation codes, symbolic operands to addresses, builds instructions, converts data, and writes the object program and listing. The linker then resolves symbols between object files before the loader copies the executable into memory and relocates it as needed. The assembler uses symbol tables from both passes and databases to perform its functions of translating and building the executable.
WHAT IS ASSEMBLER?An assembler is a program that converts an assembly level language code (also called as mnemonic code) into machine language code and provides necessary information for the loader to load the programme.
3.
Assembler languages-structure Labelsymbolic labeling of an assembler address (command address at Machine level) Mnemomic Symbolic description of an operation Operands Contains of variables or addresse if necessary Comments ignored by assembler used by humans to document/understand programs tips for useful comments: avoid restating the obvious, as “decrement R1” provide additional insight, as in “accumulate product in R6” <Mnemomic> <Operand> Comments <Label>
ASSEMBLER PROCESS ASSEMBLYLANGUAGE PROGRAM PASS1 PASS2 EXECUTABLE IMAGE SYMBOL TABLE First Pass: scan program file find all labels and calculate the corresponding addresses; this is called the symbol table Second Pass: convert instructions to machine language, using information from symbol table
Assembler’s functions Convertmnemonic operation codes to their machine language equivalents Convert symbolic operands to their equivalent machine addresses . Build the machine instructions in the proper format Convert the data constants to internal machine representations Write the object program and the assembly listing
9.
Linking and LoadingLoading is the process of copying an executable image into memory. more sophisticated loaders are able to relocate images to fit into available memory must readjust branch targets, load/store addresses Linking is the process of resolving symbols between independent object files. suppose we define a symbol in one module, and want to use it in another some notation, such as . EXTERNAL , is used to tell assembler that a symbol is defined in another module linker will search symbol tables of other modules to resolve symbols and complete code generation before loading
ADVANTAGES It usedmnemonics instead used bits. Address are symbolic not absolute. Reading / understand program easily. Introduction to data is easier.
12.
DISADVANTAGES Workingwith assembler takes a little more time, through not as much as people are wont to think. Assembler offers more facilities for structuring, even though lacking craftsmanship will bring on maintenance problems more easily. In assembler one has more possibilities for solving or preventing performance problems. It takes some extra effort to find or train professionals.