Finish support for .BANK.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5384 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2012-01-04 22:45:26 +00:00
parent e7e4877e6e
commit 1fccae4cff
8 changed files with 73 additions and 21 deletions

View File

@@ -47,6 +47,7 @@
#include "bitops.h"
#include "check.h"
#include "print.h"
#include "segdefs.h"
#include "xmalloc.h"
#include "xsprintf.h"
@@ -1873,7 +1874,7 @@ unsigned CfgProcess (void)
* must be placed into a memory area that has the bank
* attribute.
*/
if (S->Seg->BankRef && M->BankExpr == 0) {
if ((S->Seg->Flags & SEG_FLAG_BANKREF) != 0 && M->BankExpr == 0) {
CfgError (GetSourcePos (S->LI),
"Segment `%s' is refered to by .BANK, but the "
"memory area `%s' it is placed into has no BANK "

View File

@@ -72,7 +72,7 @@ ExprNode* NewExprNode (ObjData* O, unsigned char Op)
static void FreeExprNode (ExprNode* E)
/* Free a node */
{
{
/* Free the memory */
xfree (E);
}
@@ -589,7 +589,6 @@ ExprNode* ReadExpr (FILE* F, ObjData* O)
/* Read an expression from the given file */
{
ExprNode* Expr;
Section* S;
/* Read the node tag and handle NULL nodes */
unsigned char Op = Read8 (F);
@@ -614,18 +613,9 @@ ExprNode* ReadExpr (FILE* F, ObjData* O)
break;
case EXPR_SECTION:
/* Read the section number */
Expr->V.SecNum = ReadVar (F);
break;
case EXPR_BANK:
/* Read the section number */
Expr->V.SecNum = ReadVar (F);
/* Mark the section so we know it must be placed into a memory
* area with the "bank" attribute.
*/
S = GetExprSection (Expr);
S->Seg->BankRef = 1;
break;
default:

View File

@@ -45,6 +45,7 @@
#include "fragdefs.h"
#include "hashfunc.h"
#include "print.h"
#include "segdefs.h"
#include "symdefs.h"
#include "xmalloc.h"
@@ -93,6 +94,7 @@ static Segment* NewSegment (unsigned Name, unsigned char AddrSize)
/* Initialize the fields */
S->Name = Name;
S->Next = 0;
S->Flags = SEG_FLAG_NONE;
S->Sections = EmptyCollection;
S->MemArea = 0;
S->PC = 0;
@@ -104,7 +106,6 @@ static Segment* NewSegment (unsigned Name, unsigned char AddrSize)
S->AddrSize = AddrSize;
S->ReadOnly = 0;
S->Dumped = 0;
S->BankRef = 0;
/* Insert the segment into the segment list and assign the segment id */
S->Id = CollCount (&SegmentList);
@@ -190,6 +191,7 @@ Section* ReadSection (FILE* F, ObjData* O)
/* Read a section from a file */
{
unsigned Name;
unsigned Flags;
unsigned Size;
unsigned long Alignment;
unsigned char Type;
@@ -198,12 +200,13 @@ Section* ReadSection (FILE* F, ObjData* O)
Section* Sec;
/* Read the segment data */
(void) Read32 (F); /* File size of data */
(void) Read32 (F); /* File size of data */
Name = MakeGlobalStringId (O, ReadVar (F)); /* Segment name */
Size = ReadVar (F); /* Size of data */
Alignment = ReadVar (F); /* Alignment */
Type = Read8 (F); /* Segment type */
FragCount = ReadVar (F); /* Number of fragments */
Flags = ReadVar (F); /* Segment flags */
Size = ReadVar (F); /* Size of data */
Alignment = ReadVar (F); /* Alignment */
Type = Read8 (F); /* Segment type */
FragCount = ReadVar (F); /* Number of fragments */
/* Print some data */
@@ -213,6 +216,11 @@ Section* ReadSection (FILE* F, ObjData* O)
/* Get the segment for this section */
S = GetSegment (Name, Type, GetObjFileName (O));
/* The only possible flag is currently SEG_FLAG_BANKREF, and it must be
* applied to the segment, not the section.
*/
S->Flags |= Flags;
/* Allocate the section we will return later */
Sec = NewSection (S, Alignment, Type);

View File

@@ -61,6 +61,7 @@ struct Segment {
unsigned Name; /* Name index of the segment */
unsigned Id; /* Segment id for debug info */
Segment* Next; /* Hash list */
unsigned Flags; /* Segment flags */
Collection Sections; /* Sections in this segment */
struct MemoryArea* MemArea; /* Run memory area once placed */
unsigned long PC; /* PC were this segment is located */
@@ -72,7 +73,6 @@ struct Segment {
unsigned char AddrSize; /* Address size of segment */
unsigned char ReadOnly; /* True for readonly segments (config) */
unsigned char Dumped; /* Did we dump this segment? */
unsigned char BankRef; /* We need the bank of this segment */
};