This document describes the second pass of a simple assembler. It discusses the data structures used, including an opcode table and symbol table. It outlines the algorithm for pass two, which involves parsing source code lines, looking up opcodes and symbols, calculating addresses, and generating object code. Errors are flagged if issues arise during the assembly process.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
57 views6 pages
Report On Simple Assembler
This document describes the second pass of a simple assembler. It discusses the data structures used, including an opcode table and symbol table. It outlines the algorithm for pass two, which involves parsing source code lines, looking up opcodes and symbols, calculating addresses, and generating object code. Errors are flagged if issues arise during the assembly process.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6
REPORT ON SIMPLE ASSEMBLER
(SECOND PASS)
SUBMITTED BY:
1) ABHILASH S.M
2) ABHISHEK SWAMI
3) VINOD EP
4) FAARAN MOHAMMED
5) DARSHAN VAIDYA Abstract
Assembler is system software used to convert assembly
level language to machine level language. It is used to translate assembly language statements into the target computer's machine code. The assembler performs certain fundamental functions such as translating mnemonic operation codes to their machine language equivalents and assigning machine addresses to symbolic labels used by the programmer. The features and design of an assembler depend heavily upon the source language it translates and the machine language it produces. Simple SIC assembler consists of two passes. The first pass scans the source program for labels and creates a symbol table. The second pass uses the symbol table and opcode table to produce the object code. Simple SIC Assembler
Typically a modern assembler creates object code by
translating assembly instruction mnemonics into opcodes, and by resolving symbolic for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications.
The translation of source program to object code
requires us to accomplish the following functions.
1. Convert mnemonics operation codes to their
machine language equivalents. 2. Convert symbolic operands to their equivalent machine addresses. 3. Build the machine instructions in the proper format. 4. Convert the data constants specified in the source program into their internal machine representations 5. Write the object program and the assembly listings. Data Structures Used Our simple assembler uses two major internal data structures. The Opcode table (OPTAB) and the Symbol Table (SYMTAB). OPTAB is used to look up mnemonic operation codes and translate them to their machine language equivalents. SYMTAB is used to store values (addresses) assigned to labels. Location counter LOCCTR is used to help us in assignment of addresses. LOCCTR is initialized to the beginning address specified in the START statement.
OPTAB is usually organized as a hash tabbe, with
mnemonic operation code as the key. The information in the OPTAB is predefined when the assembler itself is written, rather than being loaded into the table at execution time.
SYMTAB includes the name and value(address) for
each label in the source program, together with flags to indicate error conditions. This table may also contain other information about the data area or instruction label. During pass1 of the assembler the labels are entered into the symbol table and during pass2, symbols used as operand are looked up in the SYMTAB to obtain the address to be inserted in the assembler instructions. SYMTAB is organized as a hash table for efficiency of insertion and retrieval. Algorithm for pass II of the Assembler: BEGIN initialize Scnt, Locctr, Skip, and Errorflag to 0 write assembler report headings WHILE Sourceline[Scnt] is a comment BEGIN append to assembler report increment Scnt END {while} Breakup Sourceline[Scnt] IF Opcode = 'START' THEN BEGIN convert Operand from hex and save in Locctr append to assembler report increment Scnt Breakup Sourceline[Scnt] END ENDIF format and place the load point on object code array format and place ENDval on object code array, index ENDloc WHILE Opcode <> 'END' BEGIN IF Sourceline[Scnt] is not a comment THEN BEGIN Xsearch Opcodetab for Opcode IF found THEN DO CASE 1. Opcode is 'RESW' or 'RESB' BEGIN increment Locctr by Storageincr place '!' on object code array replace the value at index ENDloc with loader address format and place Locctr on object code array format and place ENDval on object code array, index ENDloc set Skip to 1 END 2. Opcode is 'WORD' or 'BYTE' BEGIN increment Locctr by Storageincr Dostorage to get Objline IF error THEN set errors flag in Errors[Scnt] ENDIF END 3. OTHERWISE BEGIN increment Locctr by Opcodeincr Doinstruct to get Objline IF error THEN set errors flag in Errors[Scnt] ENDIF END ENDCASE ELSE set errors flag in Errors[Scnt] ENDIF END ENDIF append to assembler report IF Errors[Scnt] <> 0 THEN BEGIN set Errorflag to 1 append error report to assembler report END ENDIF IF Errorflag = 0 and Skip = 0 THEN BEGIN place Objline on object code array END ENDIF IF Skip = 1 THEN set Skip to 0 ENDIF increment Scnt Breakup Sourceline[Scnt] END {while} place '!' on object code array IF Errorflag = 0 THEN transfer object code array to file ENDIF END {of Pass 2}