Assembly Compiler Using "C": (For The Fulfillment of Three-Year BCA Course)
Assembly Compiler Using "C": (For The Fulfillment of Three-Year BCA Course)
Assembly Compiler Using "C": (For The Fulfillment of Three-Year BCA Course)
ON
ASSEMBLY COMPILER USING “C”
At the onset, I wish to convey my sincere thanks and gratitude to Mr.*******, who
helped in innumerable ways and without his constant help and inspiration the idea of
I am so much grateful to Mr. ******** who helped and keeps out moral high, which
enabled to complete the assigned project. My heartiest thanks to all those who
Your Name
The matter embodied in this project is a genuine work done by the student and has
not been submitted whether to this University or to any other University/ Institute
for the fulfillment of the requirement of any course of study.
Date:
1. INTRODUCTION
2. OBJECTIVE
3. TOOLS & ENVIRONMENT USED
4. COST ESTIMATION
5. ANALYSIS &DESIGN
6. PROGRAM STRUCTURE
7. SECURITY
8. CODING
9. TESTING
10. OUTPUT
11. LIMITATION OF PROJECT
12. FUTURE APPLICATION OF PROJECT
13. BIBLIOGRAPHY
There are various applications which provide facility to run a program developed in one
programming language and run on the compiler of different language e.g. COBRA.
Inspired from cobra the project “Assembly compiler using C” is software that enables the user
to run a program developed in assembly language on a c compiler and get the required out put.
An assembly language is a low level language .the greatest disadvantage of assembly language
is the machine dependency i.e. a program developed on one machine cannot run on another
machine there fore their always need for a software through which a user can a assembly
The “Assembly compiler using C “is a software developed in ‘c’ language that takes a
assembly language program as input and display the out put of the program . Hence we can
run an assembly language program on c compiler with out nee of any assembler
Ans :To develop any software project, Selection of a suitable language is very important. In
selection of the language we adopt few criteria keeping in view the “Aim of Project”. It should
be considered those features which the project needs while designing, whether the chosen
language incorporates such facilities to implement the features or certain criteria like:
1. The programming should offer Simple data structure & control structure
3. The program should be portable i.e. it should be run on other computers & Its
Together with these feature ‘C’ also provide some more facility which make
The main objective of this project is to compile or get output of the assembly language
programs by using the “C” compiler. So that the it becomes easier to work with assembly
language
Hardware requirements
On hardware side this programs does not need some thing extra i.e it will run on minimum
configuration
Like
IBM/PC/ XT/AT
RAM 80Kb
C++ compiler
Editor
While cost is a factor in some cases the driving force behind the development of any s/w but cost
alone cannot determine our plan. Our plan must include requirement, functionality, construction,
implementation and maintenance.
To guess the cost without the idea of the overall design will surely start our project on the
road to failure.
Design an project or s/w will cost in different ways like testing cost analysis cost, design
cost, etc. the cost analysis will the highest.
The total cost estimation for “Assembly compiler using ‘C’” is Rs 5500.
The main problem with assembly language programs is that they can run on the assembly language
compilers to over come this disadvantage’ this project is design i.e. the main function of “assembly
compiler using “C” ” is that it take assembly language program as source and run the code on’ c’
compiler and give the required out put of the program in a separate file
In this project
• First the program code or the assembly language programs is stored in a particular file
named code.1
• The data stored in the file code.1 is the source code for the c compiler that runs the
program
An assembly language consists 0f mnemonic and operands .the mnemonic may contain 0,1 or 2
operands. There are limited no of mnemonics in assembly language. Generally registers are used
as operand. To run the program on a ’C’ compiler first of all the program is converted into such a
Following is the strategy to convert a assembly language program into a ‘C’ compiler understand
able form
Extract statement are one by one followed by the assembly language program
• Check if the statement contains label .if yes perform the appropriate operations
• Read the operands and create variables and constants corresponding to the operand in ‘C’
language.
• Convert all statements into ‘C’ understandable form and store it into a file.
Now run this code and produce the result of the program
Two data base files are required for this conversion. The first data file contains list of the entire
mnemonic along with possible operand they can have. It also contains hexadecimal code
The second file contains list of mnemonic along with possible list of operands It can take the
By the use of these two data files the ‘C’ compiler generates a hexadecimal file corresponding to
The hexadecimal file acts as an intermediate file between assembly and ‘C’ compiler
4.3.1. Design:
The design process translates requirements into a representation of the software that
This step translates the design into a machine-readable form. If design is performed in
4.3.3 Testing:
intervals of the software, assuring that all statements have been tested, and on the
functional externals-that is conducting tests to uncover errors and ensure that defined
input will produce actual results that agree with required results..
4.3.4 Maintenance:
Change occurs because of the errors encountered, because software must be adapted
each of the preceding phases to an exiting program rather than new one.
The Flow chart’s and the DFD’s for the design are included in the coming
Sections.
FIG : 1
ASM.C
ASM.C TEST.C
C++
COMPILE
R
CALCULATE
TEST.HEX
HEX CODE
TEST.ASM
STEP.DAT
GENERATE STATUS OF
EACH REGISTER
THROUGH HEX FILE
&STORE IT IN RESULT
FILE
FIG: 2
TEST.ASM
C++COMPILER
DFD -2-LEVEL
GENERATE
HEXTABLE & STORE
IT IN RESULT . HEX
www.solutioncab.com (This is a sample project For BCA Students)
RESULT.DAT
FIG :3
IF
MNEMO LABEL COPY
NIC IS
CALL LABELCOPY( )
RESET NEXT
INSTRUCTION
FIG: 4
SEARCH CODE( )
GENERATE C FILE
CFILE( )
IS EOF( )
STOP
FIG:5
READING PROGRAM
COUNTER
A
IS EOF STO
P
CHECK
SEARCH THE MNEMONIC FOR
FOR A SYMBOL SEMICOLO
N
IS
SEMICO SKIP WHOLE LINE
LON = 2
IS
SEMICOLON= READ NEXT
2 INSTRUCTION
UP DATE PROGRAM
COUNTER
FORMAT
IS !
=NONE
IS IS
READ OPERAND SEMICOL CCODE==’
ON==2 C’
address ( ) :Print 2nd and/or 3rd byte in *.hex file if the length of the instruction is not one
Search Label ( ) : Returns 1if the label is a call instruction operand (Subroutine Handling).
Separate ( ) : if the operand format contains a comma then the operand is divided in two
SearchCode( ) : Search into code.dat for length, format and c code (cfile generation).
Overwrite ( ) : Avoid any overwritten *.c file if it is already exist (security option)
dec2hex( ) : Converts a decimal into hex(Program counter printing into hex file) -
SearchHex( ) : Searching the hex code of instruction into code2.dat (hex file generation).
SymbolCopy( ) : Copy the label of label field into Symbol table(Symbol table generation).
Main ( ) : The Function From, Which Execution Starts. main( ) Calls some of functions
described above. Generates *.c and *.hex file with the help of *.asm. code.dat &
code2.dat.
dec2hex( ) : Convert decimal number into hexadecimal(Printing into result.dat & step.dat).
stepresult( ) : Prints status of registers and flags into step.dat (Intermediate result file
generation)
result( ) : Prints status of resisters, flags and memory locations into result.dat (Final
Auxiliary( ) : Set the state of auxiliary flag depending on the operation (Processing of
mnemonic)
legal( ): Set the state of sign, zero and parity flag depending on the register contents
(Processing of mnemonic)
store( ) : Adds a new node into memory list, which contains location and its
content&(Memory Handling).
load( ) : Loads the contents of given memory location from the memory list (Memory Handling)
value( ) : Prompting for the contents of memory location which is refrenced but not
Check( ) : Returns 1 if the location is not into the Memory list (Memory Handling).
7. CODING
www.solutioncab.com (This is a sample project For BCA Students)
#include<iostream.h>
#include<dos.h>
#include<alloc.h>
#include<graphics.h>
#include<conio.h>/#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
#include<stdlib.h>
#include<math.h>
#define CLIP_ON 1 /* activates clipping in viewport */
#include "shape.h"
#include "triangle.h"
#include "rect.h"
#include"polygon.h"
#include "circle.h"
#include "ellipse.h"
#include "text.h"
#include "brsh.h"
#include "plane.h"
class shape *s1;
Gstring gs;
triangle t1;
rect r1;
pol p1;
circ c;
int col = 1;
unsigned int initmouse();
void getmousepos(int *button, int *x, int *y);
void getmouseposll(int *button,int *x, int *y);
void restrictmouseptr(int x1, int y1, int x2, int y2);
void showmouseptr ();
void view_menu6();
void select_shapes ();
void select_settings ();
void select_operations ();
void select_text ();
void select_file ();
void select_view();
void shapes ();
void display();
void set();
void disp_set();
void opr();
void disp_opr();
void txt ();
void disp_txt ();
maxx=getmaxx ();
maxy=getmaxy();
rectangle (0,0,maxx,maxy);
setviewport(1,1,maxx-1,maxy-1,1);
gotoxy(26, 1);
printf(" OBJECT ORIENTED GKS PROGRAMME");
if(initmouse()==0)
{
closegraph ();
restorecrtmode();
printf("\n MOUSE DRIVE NOT LOADED:");
exit(1);
}
restrictmouseptr(1 1,maxx-1,maxy-1);
showmouseptr();
setcolor (RED); outtextxy(35,50, "SHAPES");
setcolor(BROWN); outtextxy(135, 50, "SETTINGS");
setcolor (GREEN); outtextxy(235,50, "OPARATIONS");
setcolor (YELLOW); outtextxy(335, 50, "TEXT");
setcolor (MAGENTA); outtextxy(425,50, "FILE");
setcolor(RED); outtextxy(490,50, "BRUSH");
setcolor (BLUE); outtextxy(550,50, "VIEW");
gotoxy(25,3); printf("PRESS ANY KEY TO EXIT:");
while ( ! kbhit ())
{
getmousepos(&button, &x, &y);
if( (x>30&&x<110) && (y>50&&y<55))
{
if( (button &1) ==1)
{
opt= 1;
setcolor(1);
select_shapes ();
}
}
if( (x>125&&x<210) && (y>50&&y<55))
void view_menu6()
{
setviewport(1,100,getmaxx()-1,getmaxy()-1,CLIP_ON);
if (opt == 1)
{
switch (shape)
{
case 1: s1=&r1;break;
case 2: s1= = &t1;break;
case 3: s1 = &p1;break;
case 4: s1 = &c;break;
case 5: s1 = &e;
}
switch (oparation)
{
case 1: s1->reset();break;
case 2: s1->scaling();break;
case 3: s1->translate();break;
case 4: s1->rotate();
}
s1->draw();
if (oparation)
{
s1->reset();
s1->draw();
}
}
// endof if
if (opt == 2)
{
gs.DrawText ();
gs.reset();
}
opt=0;
getch();
clearviewport ();
}
unsigned int initmouse()
i.x.ax=0;
int86(0x33,&i,&o);
return (o.x.ax) ;
void showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
}
void getmousepos(int *button,int *x,int *y)
{
i.x.ax=3;
int86 (0x33, &i, &o);
*button = o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
void getmousepos11(int *button,int *x,int *y)
{
i.x.ax=3;
int86(0x33, &i, &o);
*button=o.x.bx;
*x= o.x.cx;
*y= o.x.dx;
}
void display()
{
setviewport(30, 60, 125, 190, CLIP_ON);
rectangle(0, 0,95,120);
outtextxy(5,5,"Rectangle");
outtextxy(5,25,"Triangle");
outtextxy(5,45,"Polygon");
outtextxy(5,65,"Circle");
outtextxy(5,85, "Ellipse");
outtextxy(5,100, "Exit");
}
void select_shapes()
{
void disp_opr()
void select_operations()
{
while(1)
{
getmousepos11(&button, &x, &y);
if( (button= &1)==1)
{
if( (x>236&&x<286) && (y>65&&y<85))
{
oparation-1;//s->reset();
col = (++col % 15);
setcolor(col+1);
outtextxy(5,5,"Normal");
}
if((x>236&&x<286) && (y>86&&y<95))
{
operation=2;//s->scalling();
col =(++col % 15);
setcolor(col+1);
outtextxy(5,25,"Scaling");
}
if((x>236&&x<286) && (y>100&&y<110))
{
oparation = 3;//sl->translate();
col = (++col%15);
setcolor(col+1);
outtextxy(5,45,"Translation");
}
if((x>236&&x<286) && (y>120&&y<130))
{
oparation = 4;//sl->rotate();
col (++col % 15);
setcolor(col+1);
outtextxy(5, 65,"Rotation");
}
if((x>236&&x<286) && (y>140&&y<150))
{
void disp_txt()
{
setviewport(330, 60, 425, 175, CLIP_ON);
rectangle(0,0,95,110);
outtextxy(5,5,"Text");
outtextxy(5,25,"Font");
outtextxy(5,45, "Size");
outtextxy(5, 65,"Orientation");
outtextxy(5,85, "Exit");
settextstyle (DEFAULT_FONT,HORIZ_DIR, 1);
settextjustify(LEFT_TEXT,TOP_TEXT);
setusercharsize(1, 1,1,1);
}
void select_text()
{
char string[20];
int font = 0;
int size = 1;
int dir = 0;
while(1)
{
getmousepos11(&button, &x, &y);
if( (button &1) ==1)
{
if( (x>336&&x<386) && (y>65&&y<85))
{
col = (++col % 15);
setcolor(col+1);
outtextxy(5,5,"Text");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("\tenter the text ");
scanf("%s",string);
gotoxy(5, 17);
printf(" ");
gotoxy(1,1);
gs.setText (string);
void disp_fil()
{
setviewport(430, 60, 525, 175, CLIP_ON);
rectangle (0, 0, 95, 110) ;
outtextxy(5,5,"Save");
outtextxy(5,25,"Open");
outtextxy(5,45,"Close");
outtextxy(5,65,"Exit");
}
void select_file ()
{
while (1)
{
getmousepos11(&button, &x, &y);
if( (button &1) ==1)
{
if( (x>436&&x<486) && (y>65&&y<85))
{
col = (++col % 15);
setcolor(col+1);
outtextxy(5,5,"Save");
}
if( (x>436&&x<486) && (y>86&&y<95))
{
col = (++col%15);
setcolor(col+1);
outtextxy(5,25, "Open");
}
if( (x>436&&x<486) && (y>100&&110))
{
col = (++col % 15);
setcolor(col+1);
outtextxy(5,45,"Close");
FUNCTION.C
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
struct mem
{
unsigned int location;
unsigned int contents;
struct mem *link;
};
struct mem *memory;
struct regp
{
unsigned int psw,b,d,h,sp;
};
struct reg
{
unsigned char f,a,c,b,e,d,i,h;
};
union REG
{
struct regp x;
struct reg h;
};
union REG r;
FILE *fpstep;
unsigned int pc=0;
unsigned char temp=0;
unsigned int temp1=0;
char str[5],str1[5],ch;
int i=0;
void dec2hex(unsigned char dec,char *str)
CODE.DAT
CODE2.DAT
8. SECURITY
Security Policies
Security policies have probably been around since the accumulation of the first valuables that
needed guarding. They usually encompass procedures and processes that specify
Additional limitations, such as restricting database queries about too large or too small sets,
can be imposed to reduce the danger of deducing data by statistical inference. Security policies are
often guided by the age-old principles of:
• Least privilege. Each subject should be allowed access only to the information essential for
completing the tasks that the subject is authorized to. For example, hospital accountants need not
have access to the patient's medical records, and doctors do not have to be allowed access to the
accounting data.
Regarding the project or s/w “Assembly compiler using C” security is not an important topic to
concern. The only damage that one may cause is that of change in the code of the project. As the
code is not hidden from the user we may count it is a limitation of this project. Unauthorized
access of others data are taken by this program must be stored in a unique file (it is compulsory) as
it cannot take input directly. Even time to compile a new program the old dates are to be removed
and the current data’s are to be entered same in the case of output.
Password security or the login check makes will eliminate the user friendliness of the
project. As every one have code to run but not the password to enter.
9. TESTING
Location:2501
Contents?EB
SAMPLE RUN 2
SAMPLE2.ASM
ORG8800:
LXI H, 2501:largest of two number
MOV A,M
INX H
CPM M
JNC AHEAD
MOV A,M
AHEAD: STA 2503
10.OUTPUT
www.solutioncab.com (This is a sample project For BCA Students)
FINAL RESULT OUTPUT FILE:
RESULT.DAT
STATUS OF REGISTERS:
STATUS OF FLAGS:
Location:2502 Contents: EB
Location:2503 Contents:EB
• C compiler is must
• Assembly language program or the source program must be stored in a particular file
This project is very useful for education purpose as well as for writing an Assembly language
program(8085) for an 8085 Microprocessor Based System. One can save his\her time by running
an Assembly Language Program using this package. If it run correctly than he\she can code and
LET US C
BY YASHWANT KANITKAR
UNDERSTANGING POINTERS IN C
BY YASHWANT KANITKAR
WITH 8085/8080A
BY RAMESH S. GAONKAR
BY B.RAM
C PROJECTS
BY YASHWANT KANITKAR