What is an assembler? A language translator which takes assembly language programming as i/p and produces a m/c equivalent code and information to the loader.Types• Two pass assembler• Single pass assembler
SINGLE PASS ASSEMBLER A single pass assembler scans the program onlyonce and creates the equivalent binary program.The assembler substitute all of the symbolicinstruction with machine code in one pass.
FORWARD REFERENCE PROBLEM• Rules for an assembly program states that the symbol should be defined somewhere in the program.• But in some cases a symbol may be used prior to its definition. Such a reference is called forward reference.• Due to this assembler cannot assemble the instructions and such a problem is called forward reference problem .
ASSEMBLER DIRECTIVES ORG: Manipulating L.C. SEGMENT: start of segment ENDS: end of segment ASSUME: tells the assembler it can ‘assume’ the address of the indicated segment
FORMAT OF DATABASES• Machine opcode tableMNEUMONIC MACHINE FORMAT INFO ROUTINE IDOPCODE OPCODE
FORMAT OF DATABASES• Segment register table SEGMENT SEGMENT NAME REGISTER
FORMAT OF DATABASES• Stored segment register table SEGMENT SEGMENT NAME REGISTER
FORMAT OF DATABASES • Symbol Table Symbol Owner segment EQU Length Segment name Size Defined Source statement Type Pointer to first FRT Offset in segment Pointer to first CRT Pointer to last CRT
FORMAT OF DATABASES• Forward reference tablePOINTER SRTAB # INSTRUCTION USAGE CODE SOURCE ADDRESS STATEMENT
FORMAT OF DATABASES• Cross reference table POINTER SOURCE STATEMENT #
DifferenceTwo pass assembler Single pass assembler• Performs two passes. • Performs single pass.• In first pass it collects the • In first pass itself its labels and symbols and collects the symbols and in second pass it labels and assemblels the assemblels the instruction. instruction.• It stores mneumonics and • It stores all mneumonics pseudocodes separately and pseudocodes in a i.e. MOT and POT single table MOT itself. respectively. • All entries for symbols• Literals and symbols are and literals are entered stored in symbol and into symbol table only. literal table respectively.