Your Ad Here

Tuesday, August 25, 2009

Two Pass Assembler

#include< stdio.h>
#include< conio.h>
#include< string.h>
#define lines_in_program 9
void print(char *p,int loc,int len,char ra)
{printf("%s\t%d\t%d\t%c\n",p,loc,len,ra);}
void main()
{
char *p[9][4] = {{"PRG1","START","",""},{"","USING","*","15"},
{"","L","1","FIVE"}, {"","A","1","FOUR"},
{"","ST","1","TEMP"}, {"FOUR","DC","F'4'",""},
{"FIVE","DC","F'5'",""}, {"TEMP","DS","1F",""},
{"","END","",""}};
int i,j=0,location_counter=0;
clrscr();
for (i=0;i< 9;i++)
{ for(j=0;j< 4;j++)
printf("%s\t",p[i][j]);
printf("\n");
}
printf("\n\n\n\n Symbol ");
printf("Table:\nSYMBOL\tVALUE\tLENGTH\tRelocatable/Absolute\n");
printf("---------------------------------------------\n");
for(i=0;i< 9;i++)
{ if(strcmp(p[i][1],"START")==0)
print(p[i][0],location_counter,1,'R');
else if(strcmp(p[i][0],"")!=0)
{
print(p[i][0],location_counter,4,'R');
location_counter=4+location_counter;
}
else if(strcmp(p[i][1],"USING")==0){}
else{location_counter=4+location_counter;}
}
getch();
}


/*OUTPUT:
PRG1 START
USING * 15
L 1 FIVE
A 1 FOUR
ST 1 TEMP
FOUR DC F'4'
FIVE DC F'5'
TEMP DS 1F
END

Symbol Table:
SYMBOL VALUE LENGTH Relocatable/Absolute
---------------------------------------------
PRG1 0 1 R
FOUR 12 4 R
FIVE 16 4 R
TEMP 20 4 R */

7 comments:

Anonymous said...
This comment has been removed by a blog administrator.
C Programs with output said...

Free C programs with output, c programming language, object oriented programming, c programs codes, c program shortcuts, history of c programming language, c programming compilers

MAKE IN INDIA said...

Can you have a code for elliptic curve cryptography algorithm for key generation......in c++.

Anonymous said...

can u have cpp code for elliptic curve cryptography algorithm with explanation..........

Anonymous said...

Great beat ! I wish to apprentice while you amend your web site, how could i subscribe for a blog web site?
The account helped me a acceptable deal. I had been tiny
bit acquainted of this your broadcast offered bright clear idea

Here is my webpage; summer internship

Anonymous said...

I personally didn't buy an organic bassinet mattress because my model came with the non-organic variety. This allows your babies to sleep close to each other without clobbering or rolling over each other. Though this article might be of great help in your decision to buy a baby bassinet, try to find out more on baby bassinets by reading reviews and other articles on the internet.

Feel free to surf to my web site: stroller

Anonymous said...

Nice post. I learn something new and challenging on blogs I stumbleupon
on a daily basis. It's always exciting to read content from other writers and practice something from their web sites.

Here is my web page - Nike air max billig *www.siouxlandsinglemingle.com*

Your Ad Here