0% found this document useful (0 votes)
57 views2 pages

Ex 1

This program implements a symbol table to read in symbols and their addresses from an input file and write them to an output file. It opens the input and output files, reads in symbols until it finds a number which is used as the starting address, then reads and writes each subsequent symbol and the assigned address to both files, incrementing the address each time.

Uploaded by

soundar23
Copyright
© Attribution Non-Commercial (BY-NC)
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% found this document useful (0 votes)
57 views2 pages

Ex 1

This program implements a symbol table to read in symbols and their addresses from an input file and write them to an output file. It opens the input and output files, reads in symbols until it finds a number which is used as the starting address, then reads and writes each subsequent symbol and the assigned address to both files, incrementing the address each time.

Uploaded by

soundar23
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 2

IMPLEMENTATION OF SYMBOL TABLE

PROGRAM
#include<stdio.h> void main() { char c[20],d[20]; FILE *f,*of; int start,i=0; clrscr(); f=fopen("input.txt","r"); of=fopen("output.txt","w"); while(!feof(f)) { fscanf(f,"%s",d); if(atoi(d)!=0) { start=atoi(d); break; } } fprintf(of,"S.No\tSYMBOL\tADDRESS\n"); printf("S.No\tSYMBOL\tADDRESS\n"); while(!feof(f)) { fscanf(f,"%s",d); fgets(c,60,f); if(strcmp(d,"*")) { i++; fprintf(of,"%d\t%s\t%d\n",i,d,start); printf("%d\t%s\t%d\n",i,d,start); } start++; } getch(); }

OUTPUT
INPUT.TXT * * MOVECH * * * STR1 STR2 ZERO ELEVEN * START LDX LDCH STCH TIX JLT BYTE RESB WORD WORD END 1000 ZERO STR1,X STR2,X ELEVEN MOVECH C'TEST' 4 0 4 *

OUTPUT.TXT S.No 1 2 3 4 5 SYMBOL MOVECH STR1 STR2 ZERO ELEVEN ADDRESS 1001 1005 1006 1007 1008

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy