X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fld65%2Fo65.c;h=6845efed112d8acad023b1d3efaa7f289eb284fa;hb=4786caf496bd8e6989abee74017aa098df860c41;hp=bc2ae6f616ef656545902c40271414f726bafb45;hpb=ad140bede4f73f812bdd5c402ae59f0ccc11d3d5;p=cc65 diff --git a/src/ld65/o65.c b/src/ld65/o65.c index bc2ae6f61..6845efed1 100644 --- a/src/ld65/o65.c +++ b/src/ld65/o65.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1999-2009, Ullrich von Bassewitz */ +/* (C) 1999-2010, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -53,6 +53,7 @@ #include "fileio.h" #include "global.h" #include "lineinfo.h" +#include "memarea.h" #include "o65.h" #include "spool.h" @@ -175,7 +176,7 @@ struct ExprDesc { O65Desc* D; /* File format descriptor */ long Val; /* The offset value */ int TooComplex; /* Expression too complex */ - Memory* MemRef; /* Memory reference if any */ + MemoryArea* MemRef; /* Memory reference if any */ Segment* SegRef; /* Segment reference if any */ Section* SecRef; /* Section reference if any */ ExtSym* ExtRef; /* External reference if any */ @@ -244,20 +245,18 @@ static void CvtMemoryToSegment (ExprDesc* ED) */ { /* Get the memory area from the expression */ - Memory* M = ED->MemRef; - - /* Get the list of segments in this memory area */ - MemListNode* N = M->SegList; + MemoryArea* M = ED->MemRef; /* Remember the "nearest" segment and its offset */ Segment* Nearest = 0; unsigned long Offs = ULONG_MAX; /* Walk over all segments */ - while (N != 0) { + unsigned I; + for (I = 0; I < CollCount (&M->SegList); ++I) { - /* Get the segment from this node and check if it's a run segment */ - SegDesc* S = N->Seg; + /* Get the segment and check if it's a run segment */ + SegDesc* S = CollAtUnchecked (&M->SegList, I); if (S->Run == M) { unsigned long O; @@ -277,9 +276,6 @@ static void CvtMemoryToSegment (ExprDesc* ED) } } } - - /* Next segment */ - N = N->Next; } /* If we found a segment, use it and adjust the offset */ @@ -791,7 +787,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite) /* Write this segment */ if (DoWrite) { - SegWrite (D->F, S->Seg, O65WriteExpr, D); + SegWrite (D->Filename, D->F, S->Seg, O65WriteExpr, D); } /* Mark the segment as dumped */ @@ -1221,7 +1217,7 @@ void O65SetExport (O65Desc* D, unsigned Ident) static void O65SetupSegments (O65Desc* D, File* F) /* Setup segment assignments */ -{ +{ unsigned I; unsigned TextIdx, DataIdx, BssIdx, ZPIdx; @@ -1232,16 +1228,16 @@ static void O65SetupSegments (O65Desc* D, File* F) D->ZPCount = 0; /* Walk over the memory list */ - for (I = 0; I < CollCount (&F->MemList); ++I) { + for (I = 0; I < CollCount (&F->MemoryAreas); ++I) { /* Get this entry */ - Memory* M = CollAtUnchecked (&F->MemList, I); + MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I); /* Walk through the segment list and count the segment types */ - MemListNode* N = M->SegList; - while (N) { + unsigned J; + for (J = 0; J < CollCount (&M->SegList); ++J) { - /* Get the segment from the list node */ - SegDesc* S = N->Seg; + /* Get the segment */ + SegDesc* S = CollAtUnchecked (&M->SegList, J); /* Check the segment type. */ switch (O65SegType (S)) { @@ -1249,11 +1245,8 @@ static void O65SetupSegments (O65Desc* D, File* F) case O65SEG_DATA: D->DataCount++; break; case O65SEG_BSS: D->BssCount++; break; case O65SEG_ZP: D->ZPCount++; break; - default: Internal ("Invalid return from O65SegType"); + default: Internal ("Invalid return from O65SegType"); } - - /* Next segment node */ - N = N->Next; } } @@ -1265,16 +1258,16 @@ static void O65SetupSegments (O65Desc* D, File* F) /* Walk again through the list and setup the segment arrays */ TextIdx = DataIdx = BssIdx = ZPIdx = 0; - for (I = 0; I < CollCount (&F->MemList); ++I) { + for (I = 0; I < CollCount (&F->MemoryAreas); ++I) { /* Get this entry */ - Memory* M = CollAtUnchecked (&F->MemList, I); + MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I); /* Walk over the segment list and check the segment types */ - MemListNode* N = M->SegList; - while (N) { + unsigned J; + for (J = 0; J < CollCount (&M->SegList); ++J) { - /* Get the segment from the list node */ - SegDesc* S = N->Seg; + /* Get the segment */ + SegDesc* S = CollAtUnchecked (&M->SegList, J); /* Check the segment type. */ switch (O65SegType (S)) { @@ -1284,9 +1277,6 @@ static void O65SetupSegments (O65Desc* D, File* F) case O65SEG_ZP: D->ZPSeg [ZPIdx++] = S; break; default: Internal ("Invalid return from O65SegType"); } - - /* Next segment node */ - N = N->Next; } } }