R.V. College of Engineering
R.V. College of Engineering
R.V. College of Engineering
COLLEGE OF ENGINEERING
Chapter 1
Introduction
Page
Page
Generally for
such multiple passes and for handling aggressive optimization of target code lot of time is required.
Page
In case of dynamic web applications where we download applets and expect them to update in real time
multiple passes is not an option. Similarly in handheld web enabled devices both space and time
limitations have to be considered.
intermediate file and no multiple passes, load directly into memory or create an object module. This is
1.5 Overview
An assembler program is a language processor. It simply translates statements of a
source program into their machine language counterparts. Source programs are created
as c files (.c) and then submitted assembly process.
This document describes the characteristics and usage conventions of a one-pass
assembler that executes on the assembly language program (ALP) written for SIC
Machine Architecture and assembles object code into a object code, as in case of a
STORE and GO assembler, different form a LOAD and GO assembler which
assembles code directly into memory directly.
1.6 Objective
The intention of our project is to implement a simple single-pass Assembler for SIC
Machine Architecture. It is intended to perform basic functions mentioned below. They
are as follows:
1) Translating mnemonic operation codes to their machine language equivalents.
2) Assigning machine addresses to symbolic labels used by the programmer.
3) Including handling of forward and backward references in one pass over the
source program.
1.7 Methodology:
The system after careful analysis has been identified to be presented with the following
data structure modules:
Department of Information Science and Engineering
Page
Page
Chapter 2
Chapter 2
Basic Requirements Specifications
Page
Purpose
The purpose of this software requirements specification (SRS) is to establish the
ten major requirements necessary to develop the Software Systems Software.
Platform (technology/tools)
In computing, C is a general-purpose computer programming language originally
developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the
Unix operating system.
Although C was designed for writing architecturally independent system Software, it is
also widely used for developing application software.
Worldwide, C one among the most popular language in terms of number of developer
positions or publically available code. It is widely used on many different software
platforms, and there are few computer architectures for which a C compiler does not
exist. C has greatly influenced many other popular programming languages, most notably
C++, which originally began as an extension to C, and JAVA and C# .
Page
Hardware requirements:
MAIN PROCESSOR : Pentium IV (500MHz)
RAM SIZE : 128 MB
CACHE MEMORY:256KB
DISKETTE DRIVE:1.FFMB,3.5inches
OPTICAL DRIVE:4X CD-ROM DRIVE
Page
Chapter 3
System Architecture and Data Flow Diagram
Page
Chapter 3
System Architecture and Data Flow Diagram
Data flow diagram
The DFD (bubble chart) is a hierarchical graphical model of a system that shows
the different processing activities or functions that the system performs and the data
interchange among these functions. Each function is considered as a processing station
(process) that consumes some input data and produces some output. The system is
represented in terms of the input to the system, various processing carried out on it and
the output generated by the system. A DFD model uses a very limited number of
primitive symbols to represent the functions performed by the system and the data flow.
External Entity
Process
Output
Page
Data flow
Data Store
Fig. 3.1
The main reason why the DFD technique is so popular is probably because of the
fact that DFD is a very simple formalism. It is simple to understand and use. Starting with
a set of high-level functions that a system performs, a DFD model hierarchically
represents various sub functions. In fact, any hierarchical model is simple to understand
because in a hierarchical model of a system, different details are slowly introduced
through different hierarchies. This technique also follows a very simple set of intuitive
concepts and rules. DFD is an elegant modeling that turn out to be useful not only to
represent the results of the structured analysis of a software problem, but also for several
other applications such as showing the flow of items or control in an organization.
Source Code
Single
Pass
Assemble
Object code
Fig: 3.2
LEVEL-1 DFD
Source code
CodeSource
Creating
SYMTAB
Symbol
Table
OP Table
Page
Error
messages
Fig: 3.3
LEVEL-2 DFD
Source Code
Main program
Parser Routine
Lexical Analyser
Fig: 3.4
Assembler
listing
Creating SYMTAB
Error message
Fig 3.4
Page
Chapter 4
Implementation
Page
Chapter 4
Implementation
4.1 Implementation of Single Pass Assembler:
Implementation Details
If One-Pass needs to generate object code and following situation occurs:
1) If the operand contains an undefined symbol, use 0 as the address and write the Text
record to the object program.
2) Forward references are entered into lists as in the load-and-go assembler.
3) When the definition of a symbol is encountered, the assembler generates another Text
record with the correct operand address of each entry in the reference list.
4) When loaded, the incorrect address 0 will be updated by the latter Text record
containing the symbol definition.
Thus in this way it is handled.
Page
Page
Page
Chapter 5
Testing
Page
Chapter 5
Testing
5.1 Testing Process
Single pass assembler performs basic functions like translating mnemonic operation
codes to their machine language equivalents and assigning machine addresses to
symbolic labels used by the programmer.
Thus it also includes handling of forward and backward references in one pass over the
source program. It also generates where the error is occurring through error text file.
1
Test_case_1
Test case to check source code with no error
Input file with no error
Object program with no error
Object program with no error
Test case No
Name of the test case
Description
Input
Expected output
2
Test_case_2
Test case to check source code with error
Input file with error
Error message to be generated in error file
Page
Test case No
Name of the test case
Description
3
Test_case_3
Test case to check source code with invalid
Input
Expected output
opcode
Input file with error
Error message to be generated in error file with
Actual output
no object program
Error message to be generated in error file with
no object program
Page
Chapter 6
Page
Chapter 6
Results and Inference
6.1 Results:
Page
Page
Page
6.2 Inference
Thus the single pass assembler generates the symbol table as well as the object code. It
also generates the error if any present.
It all happens through single pass and also it eliminates forward references.
Page
Chapter 7
Page
Page
Page
Source Code
#include<stdio.h>
#include<string.h>
#define q 11 //no. of mnemonics in the array A
void main()
{
int lc,ad,address,err=0;
int s,num,l,i=0,j,n=0,line=1,f=0,f1=0,t=0,ni=0,m=0,t1;
FILE *fp1,*fp2,*fp3,*fp4;
char lab[10],op[10],val[10],code[10];
char a[20]
[15]={"STA","STL","LDA","LDB","J","JEQ","J","SUB","COMP","STCH","ADD","SU
B"};
char b[20][15]={"14","32","03","69","34","30","48","28","24","16","0C"};
char sym[15][10];
int symadd[15];
fp1=fopen("INPUT.DAT","r");
fp2=fopen("OBJFILE.DAT","w");
fp3=fopen("ERROR.DAT","w");
fp4=fopen("SYMTAB.DAT","w");
while((!feof(fp1)))
{
fscanf(fp1,"%s\t%s\t%s",lab,op,val);
t++;
m++;
if(strcmp(op,".")==0)
Department of Information Science and Engineering
Page
Page
Page
Page
Page
Page
Page