Mail Archives: djgpp/1999/07/22/21:06:09
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
- Raw text -