Stuck? Need help? Ask questions on our forums.
*/
*/

View \MFWD.C

68Hc11 Cross-assembler

Submitted By: WEBMASTER
Rating: starstarstar (Rate It)


/*
 *      in memory version of forward ref handler
 */

 
#define MAXFWD  500
 
struct fref{
 int     f_fno;  /* file number */
 int     f_line; /* line number */
 };
 
struct fref *Fbase = NULL;
struct fref *Fnext = NULL;
int Fleft = 0;
 
/*
 *      fwdinit --- initialize forward ref array
 */

fwdinit()
{
 char *malloc();
 
 Fbase = (struct fref *)malloc( sizeof(struct fref) * MAXFWD );
 if( Fbase == (struct fref *)NULL )
  fatal("No mem for fwd refs");
 Fnext = Fbase;
 Fleft = MAXFWD-1;
}
 
/*
 *      fwdreinit --- reinitialize forward ref file
 */

fwdreinit()
{
 Fnext->f_fno = Fnext->f_line = 0;
 Fnext = Fbase;
 Ffn = Fnext->f_fno;
 F_ref = Fnext->f_line;
 Fnext++;
}
 
/*
 *      fwdmark --- mark current file/line as containing a forward ref
 */

fwdmark()
{
 if( Fleft != 0 ){
  Fnext->f_fno = Cfn;
  Fnext->f_line = Line_num;
  Fnext++;
  Fleft--;
  }
 else
  error("No space for fwd refs");
}
 
/*
 *      fwdnext --- get next forward ref
 */

fwdnext()
{
 Ffn = Fnext->f_fno;
 F_ref = Fnext->f_line;
 Fnext++;
#ifdef DEBUG
 printf("Next Fwd ref: %d,%d\n",Ffn,F_ref);
#endif
}

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings