-static void O65WriteTextSeg (O65Desc* D, Memory* M attribute ((unused)))
+static void O65WriteTextSeg (O65Desc* D)
/* Write the code segment to the o65 output file */
{
/* Initialize variables */
-static void O65WriteDataSeg (O65Desc* D, Memory* M attribute ((unused)))
+static void O65WriteDataSeg (O65Desc* D)
/* Write the data segment to the o65 output file */
{
/* Initialize variables */
-static void O65WriteBssSeg (O65Desc* D, Memory* M attribute ((unused)))
+static void O65WriteBssSeg (O65Desc* D)
/* "Write" the bss segments to the o65 output file. This will only update
* the relevant header fields.
*/
-static void O65WriteZPSeg (O65Desc* D, Memory* M attribute ((unused)))
+static void O65WriteZPSeg (O65Desc* D)
/* "Write" the zeropage segments to the o65 output file. This will only update
* the relevant header fields.
*/
-static void O65SetupSegments (O65Desc* D, Memory* M)
+static void O65SetupSegments (O65Desc* D, File* F)
/* Setup segment assignments */
{
+ Memory* M;
MemListNode* N;
SegDesc* S;
unsigned TextIdx, DataIdx, BssIdx, ZPIdx;
D->BssCount = 0;
D->ZPCount = 0;
- /* Walk through the segment list and count the segment types */
- N = M->SegList;
- while (N) {
-
- /* Get the segment from the list node */
- S = N->Seg;
-
- /* Check the segment type. */
- switch (O65SegType (S)) {
- case O65SEG_TEXT: D->TextCount++; break;
- case O65SEG_DATA: D->DataCount++; break;
- case O65SEG_BSS: D->BssCount++; break;
- case O65SEG_ZP: D->ZPCount++; break;
- default: Internal ("Invalid return from O65SegType");
- }
-
- /* Next segment node */
- N = N->Next;
+ /* Walk over the memory list */
+ M = F->MemList;
+ while (M) {
+ /* Walk through the segment list and count the segment types */
+ N = M->SegList;
+ while (N) {
+
+ /* Get the segment from the list node */
+ S = N->Seg;
+
+ /* Check the segment type. */
+ switch (O65SegType (S)) {
+ case O65SEG_TEXT: D->TextCount++; break;
+ case O65SEG_DATA: D->DataCount++; break;
+ case O65SEG_BSS: D->BssCount++; break;
+ case O65SEG_ZP: D->ZPCount++; break;
+ default: Internal ("Invalid return from O65SegType");
+ }
+
+ /* Next segment node */
+ N = N->Next;
+ }
+ /* Next memory area */
+ M = M->FNext;
}
/* Allocate memory according to the numbers */
/* Walk again through the list and setup the segment arrays */
TextIdx = DataIdx = BssIdx = ZPIdx = 0;
- N = M->SegList;
- while (N) {
-
- /* Get the segment from the list node */
- S = N->Seg;
-
- /* Check the segment type. */
- switch (O65SegType (S)) {
- case O65SEG_TEXT: D->TextSeg [TextIdx++] = S; break;
- case O65SEG_DATA: D->DataSeg [DataIdx++] = S; break;
- case O65SEG_BSS: D->BssSeg [BssIdx++] = S; break;
- case O65SEG_ZP: D->ZPSeg [ZPIdx++] = S; break;
- default: Internal ("Invalid return from O65SegType");
- }
-
- /* Next segment node */
- N = N->Next;
+ M = F->MemList;
+ while (M) {
+
+ N = M->SegList;
+ while (N) {
+
+ /* Get the segment from the list node */
+ S = N->Seg;
+
+ /* Check the segment type. */
+ switch (O65SegType (S)) {
+ case O65SEG_TEXT: D->TextSeg [TextIdx++] = S; break;
+ case O65SEG_DATA: D->DataSeg [DataIdx++] = S; break;
+ case O65SEG_BSS: D->BssSeg [BssIdx++] = S; break;
+ case O65SEG_ZP: D->ZPSeg [ZPIdx++] = S; break;
+ default: Internal ("Invalid return from O65SegType");
+ }
+
+ /* Next segment node */
+ N = N->Next;
+ }
+ /* Next memory area */
+ M = M->FNext;
}
-
}
void O65WriteTarget (O65Desc* D, File* F)
/* Write an o65 output file */
{
- Memory* M;
char OptBuf [256]; /* Buffer for option strings */
time_t T;
/* Place the filename in the control structure */
D->Filename = F->Name;
- /* The o65 format uses only one memory area per file. Check that. */
- M = F->MemList;
- if (M->Next != 0) {
- Warning ("Cannot handle more than one memory area for o65 format");
- }
-
/* Check for unresolved symbols. The function O65Unresolved is called
* if we get an unresolved symbol.
*/
}
/* Setup the segment arrays */
- O65SetupSegments (D, M);
+ O65SetupSegments (D, F);
/* Setup additional stuff in the header */
O65SetupHeader (D);
O65WriteHeader (D);
/* Write the text segment */
- O65WriteTextSeg (D, M);
+ O65WriteTextSeg (D);
/* Write the data segment */
- O65WriteDataSeg (D, M);
+ O65WriteDataSeg (D);
/* "Write" the bss segments */
- O65WriteBssSeg (D, M);
+ O65WriteBssSeg (D);
/* "Write" the zeropage segments */
- O65WriteZPSeg (D, M);
+ O65WriteZPSeg (D);
/* Write the undefined references list */
O65WriteImports (D);