static void CheckSegName (const char* Seg) /* Abort if the given name is not a valid segment name */ { /* Print an error and abort if the name is not ok */ if (!ValidSegName (Seg)) { AbEnd ("Segment name `%s' is invalid", Seg); } }
static Segment* NewSegment (const char* Name, unsigned char AddrSize) /* Create a new segment, insert it into the global list and return it */ { /* Check for too many segments */ if (CollCount (&SegmentList) >= 256) { Fatal ("Too many segments"); } /* Check the segment name for invalid names */ if (!ValidSegName (Name)) { Error ("Illegal segment name: `%s'", Name); } /* Create a new segment and return it */ return NewSegFromDef (NewSegDef (Name, AddrSize)); }
static Segment* NewSegment (const char* Name, unsigned char AddrSize) /* Create a new segment, insert it into the global list and return it */ { Segment* S; /* Check for too many segments */ if (SegmentCount >= 256) { Fatal ("Too many segments"); } /* Check the segment name for invalid names */ if (!ValidSegName (Name)) { Error ("Illegal segment name: `%s'", Name); } /* Create a new segment */ S = xmalloc (sizeof (*S)); /* Initialize it */ S->List = 0; S->Root = 0; S->Last = 0; S->FragCount = 0; S->Num = SegmentCount++; S->Align = 0; S->RelocMode = 1; S->PC = 0; S->AbsPC = 0; S->Def = NewSegDef (Name, AddrSize); /* Insert it into the segment list */ SegmentLast->List = S; SegmentLast = S; /* And return it... */ return S; }
static void SegNamePragma (StrBuf* B, segment_t Seg) /* Handle a pragma that expects a segment name parameter */ { StrBuf S = AUTO_STRBUF_INITIALIZER; const char* Name; /* Check for the "push" or "pop" keywords */ int Push = 0; switch (ParsePushPop (B)) { case PP_NONE: break; case PP_PUSH: Push = 1; break; case PP_POP: /* Pop the old value and output it */ PopSegName (Seg); g_segname (Seg); /* Done */ goto ExitPoint; case PP_ERROR: /* Bail out */ goto ExitPoint; default: Internal ("Invalid result from ParsePushPop"); } /* A string argument must follow */ if (!GetString (B, &S)) { goto ExitPoint; } /* Get the string */ Name = SB_GetConstBuf (&S); /* Check if the name is valid */ if (ValidSegName (Name)) { /* Set the new name */ if (Push) { PushSegName (Seg, Name); } else { SetSegName (Seg, Name); } g_segname (Seg); } else { /* Segment name is invalid */ Error ("Illegal segment name: `%s'", Name); } ExitPoint: /* Call the string buf destructor */ SB_Done (&S); }