From: Rainbow Warrior Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: HELP-General Protection Exception Date: Wed, 21 Jul 1999 19:18:22 +0000 Content-Transfer-Encoding: 7bit References: <3794EC05 DOT 3461D8A2 AT earthlink DOT net> <3795E8BB DOT 657B78AA AT ix DOT netcom DOT com> X-Posted-Path-Was: not-for-mail X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-ELN-Date: 21 Jul 1999 23:10:17 GMT X-ELN-Insert-Date: Wed Jul 21 16:15:10 1999 Organization: EarthLink Network, Inc. Lines: 64 Mime-Version: 1.0 NNTP-Posting-Host: 1cust241.tnt16.orlando.fl.da.uu.net Message-ID: <7n5k0p$h8q$1@fir.prod.itd.earthlink.net> X-Mailer: Mozilla 4.51 [en] (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Brian MacBride wrote: > Rainbow Warrior wrote: > > > > Hello, > > > > This has been stumping me for days. The program compiles OK but > > during execution it gives me a general protection exception. I cannot > > see why. This program simulates pass 2 of an assembler. The function > > which trips it up is supposed to get tokens from a line of text read in > > from an input file. > > > > Any help would be greatly appreciated > > > > Juan Sanmiguel > > > > Consider... > > #define HT_SIZE 109 /* number of entries in the hash table */ > > struct st_entry { > char st_name[NAME_LENGTH + 1]; > char st_type; /* R (Relocatable), A (Absolute), > E (Exported - external definition), > I (Imported - external reference), > C (Control section), N (Not applicable) */ > int st_value; > }; > struct st_entry symtbl[HT_SIZE]; > > void init() > { ... > > /* You have... > for (counter=0; counter <= HT_SIZE; counter++) > strcpy(symtbl[counter].st_name," "); > */ > > /* Consider... */ > > for (counter=0; counter < HT_SIZE; counter++) > strcpy(symtbl[counter].st_name," "); > > ... > } > > With this change your program runs (correctly??) with no GPF. > > Regards > > Brian Did it. Still get a GPF. The fault is somewhere in the pass2 or get tokens procedure. At least, the program worked until I added those functions. As for running correctly, the program is in its early stages. At this point it should load the operation and symbol tables and read the source code and seperate into individual tokens for processing. What compilier did you use? I have tried both Borland 4.52 and Djgpp. Again any help would be greatly appreciated. Juan Sanmiguel