Message-ID: <37970E9A.F3A06961@ix.netcom.com> From: Brian MacBride Organization: Signal Computing Service Ltd. X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: HELP-General Protection Exception References: <3794EC05 DOT 3461D8A2 AT earthlink DOT net> <3795E8BB DOT 657B78AA AT ix DOT netcom DOT com> <7n5k0p$h8q$1 AT fir DOT prod DOT itd DOT earthlink DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 90 Date: Thu, 22 Jul 1999 06:29:14 -0600 NNTP-Posting-Host: 207.181.69.80 X-Complaints-To: abuse AT netcom DOT ca X-Trace: tor-nn1.netcom.ca 932646720 207.181.69.80 (Thu, 22 Jul 1999 08:32:00 EDT) NNTP-Posting-Date: Thu, 22 Jul 1999 08:32:00 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Rainbow Warrior wrote: > > 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 Your program runs (correctly??) without a GPF when compiled with VC++. The program compiled with Builder C++ creates a GPF... void get_tokens (char *line_ptr, char *label_ptr, char *oper_ptr, char *opnd_ptr, int *opi_ptr, int *len_ptr) { /* You had... char temp[4]; */ /* Consider... */ char temp[5]; ... } No GPF with either VC++ or Builder C++. HTH Regards Brian