single pass assembler in c language.pdf
TRANSCRIPT
1/29/13 Single pass assembler in c language
wiki.answers.com/Q/Single_pass_assembler_in_c_language 1/4
Lost password?
Answers members:
Username
Password
Remember me
Sign inSign in
.NET Programming
Computer Programming
Computers
Technology
Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Programming > CProgramming
Question - Implement a single pass assembler.
Program
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int count[20];
void main()
{
FILE *f1,*f2,*f3,*f4;
int linenumber,locctr,f;
char lbl[10],mne[10],opd[10],ch,mneu1[10],sval[10];
char sadr[10],slbl[10],op1[10],label[10];
void wordcount();
printf("Word count for Input Program:");
wordcount();
printf("\n Output \n");
printf("\n Source Code \t Object code \n\n");
f1=fopen("INPUT.C","r");
f2=fopen("SYMTAB.C","w+");
f4=fopen("INTER.C","w");
fscanf(f1,"%s %s %x\n",lbl,mne,&locctr);
linenumber=2;
while(!feof(f1))
{
if(count[linenumber]==1)
{
fscanf(f1,"%s\n",mne);
fprintf(f4,"%x\t%s",locctr,mne);
}
if(count[linenumber]==2)
{
fscanf(f1,"%s%s\n",mne,opd);
fscanf(f4,"%X \t %s \t %s \n",locctr,mne,opd);
printf("%s\t%s\t",mne,opd);
f3=fopen("OPCODE.C","r");
while(!feof(f3))
{
fscanf(f3,"%s %s \n",mneu1,op1);
if(strcmp(mne,mneu1)==0)
printf("%s\t",op1);
}
fclose(f3);
f=0;
rewind(f2);
while(!feof(f2))
{
fscanf(f2,"%s %s %s \n",sadr,slbl,sval);
if(strcmp(opd,slbl)==0)
{
printf("%s\n\n",sadr);
In: The Difference
Between
In: African-American
History
In: Medication and Drugs
In: Salary and Pay Rates
Rate This Answer »
Help Us Improve
Answer Rating
Recommend this Answer »
Questions that People need Answered
What is the difference between earthingand lightning conductor?
Did Coretta Scott king have brothers?
What happens when a drug partly blocks amembranes potassium channels?
What is a monthly salary for a nurse inTrinidad?
Computer Programming Questions
Best Answer
Ganderton
Trust: 4098Technology SupervisorGoogle Profile »Recommend Supervisor »
Contributors
Supervisors
Like Be the f irst of your friends to like this.
Single pass assembler in clanguage?
ASM Assembler to C ToolsAutomatically convert Assembly to C ASM360ASM370 ASM390 HLASM. Low $.www.mpsinc.com/
Ads
View Slide Show
Ask us anything GO GO
Sign In | Sign Up
1/29/13 Single pass assembler in c language
wiki.answers.com/Q/Single_pass_assembler_in_c_language 2/4
f=1;
}
}
if(f==0)
printf("0000\n");
}
if(count[linenumber]==3)
{
fscanf(f1,"%s %s %s \n",lbl,mne,opd);
fprintf(f4,"%X \t %s \t %s \t %s \n",locctr,lbl,mne,opd);
fprintf(f2,"%X \t %s \t %s \n", locctr, lbl,opd);
if((strcmp(mne,"RESW")==0) || (strcmp(mne,"RESB")==0))
printf("%s \t %s \t 00 \t 000 %s \n\n",lbl,mne,opd);
else
printf("%s \t %s \t 00 \t 000 %s \n\n",lbl,mne,opd);
}
linenumber+=1;
if(strcmp(mne,"WORD")==0)
locctr+=3;
else if(strcmp(mne,"BYTE")==0)
locctr+=strlen(opd);
else if(strcmp(mne,"RESW)==0)
locctr+=3 * (atoi(opd));
else if(strcmp(mne,"RESB")==0)
locctr+=atoi(opd);
else
locctr+=3;
}
fclose(f1);
fclose(f2);
fclose(f4);
getch();
}
void wordcount()
{
FILE *f3;
char c;
int word=0,i=1;
printf("\n Word Count");
f3=fopen("INPUT.C","r");
c=fgetc(f3);
while(c!=EOF)
{
if(c==' ')
word+=1;
if(c=='\n')
{
word+=1;
count[i]=word;
printf("\n No.of words in %d:%d",r,word);
i+=1;
word=0;
}
c=fgetc(f3);
}
fclose(f3);
}
INPUT.c
WC START 1000
FIRST WORD 5
SECOND WORD 6
THIRD RESW 1
LDA FIRST
ADD SECOND
STA THIRD
END
OPCODE.c
LDA 00
ADD 18
SUB 1C
STA 0C
SYMTAB.c
FIRST 1009
SECOND 100C
THIRD 100F
INTER.c
1000 LDA FIRST
1003 ADD SECOND
1006 STA THIRD
1009 FIRST WORD
100C SECOND WORD
100F THIRD RESW
1/29/13 Single pass assembler in c language
wiki.answers.com/Q/Single_pass_assembler_in_c_language 3/4
Single pass assembler?Single Pass Assembler . A single pass
assembler scans the program only once and
creates
In programming language C what ismeant by assembler?an assembler is a program,just like a
compiler.that processes staaements written
in a particular
Related Answers:
What is the Design of single passassembler?A hammer, one pass and you're done
Why c language is called as clanguage?Labs by Key Thompson.\n The C itself is
improvement on the B language
Why c language is called c language?The language it was originally based on was
called B.
Is c language regular language?it is not regular language .it is high level
language
Related Videos:
MORE RECENT UPDATES »
1012 END
1015 ENDL
Related Answers:
Searching for Single pass assembler in c language:
Searching for Single pass assembler in c language:
www.Bankaholic.comToday's Top MMA RatesBrowse Top 25 Money Market Rates. Sort by APY,Reviews, Banks.
www.ApnaPaisa.com/emicalculatorHome Loan EMI CalculatorHow much EMI will you have to pay? Just enter amount, tenure & rate.
http://www.india.com/Your Daily Dose Of FunWith Bollywood Gossip, Pics, Cars, Gadgets & More - On India.com!
A ds by C hitika
Men Sunglasses- 50% Off
Jabong.com/Sunglasses_Sale
Exclusive Collection, Best Price CashOn Delivery - Free Shipping !
EliteMatrimony.comwww.elitematrimony.com/Know_more
Exclusive Matchmaking Service FromBharatMatrimony for Rich & Affluent
How to Use C# - 01 -Introduction
C# - 03 - Compile andRun
C# - 02 - Hello World
Ayumilove HaskellProgramming TutorialPart 3
Recent Answers Activity
How many Canadian players arein the nhl in 2013?
asked 33 seconds ago
What is the correct tyre size fora citroen c3 desire?
asked 36 seconds ago
Aura Lee Joya updated What isthe Lesson of the witch byedilberto tiempo?
updated 39 seconds ago
Where is gold found in Pakistan?
answered 42 seconds ago
Imo pop answered Did WilliamShakespeare have children withAnne Hathaway?
answered 42 seconds ago
Answers
Wiki Answers
Video Answers
Local Answers
Online Answers
Shop Answers
Answers Properties Company
About
Careers
Terms of Use
Community
Guidelines
Reputation
Roles
Updates
Watchlist
RSS
1/29/13 Single pass assembler in c language
wiki.answers.com/Q/Single_pass_assembler_in_c_language 4/4
Guides
Coupons
ResellerRatings
Surveys
Blog
Sitemap
Privacy Policy
IP Issues
Disclaimer
Help
International sites English Deutsch Español Français Italiano
Copyright © 2012 Answers Corporation