mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
More segment support stuff.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3806 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
8db6dcd414
commit
a4b43370e7
@ -75,7 +75,19 @@ int SegmentDefined (unsigned Start, unsigned End)
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int HaveSegmentChange (unsigned Addr)
|
||||
/* Return true if the segment change attribute is set for the given address */
|
||||
{
|
||||
/* Check the given address */
|
||||
AddrCheck (Addr);
|
||||
|
||||
/* Return the attribute */
|
||||
return (AttrTab[Addr] & atSegmentChange) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -133,6 +145,18 @@ void MarkAddr (unsigned Addr, attr_t Attr)
|
||||
|
||||
|
||||
|
||||
attr_t GetAttr (unsigned Addr)
|
||||
/* Return the attribute for the given address */
|
||||
{
|
||||
/* Check the given address */
|
||||
AddrCheck (Addr);
|
||||
|
||||
/* Return the attribute */
|
||||
return AttrTab[Addr];
|
||||
}
|
||||
|
||||
|
||||
|
||||
attr_t GetStyleAttr (unsigned Addr)
|
||||
/* Return the style attribute for the given address */
|
||||
{
|
||||
|
@ -73,6 +73,7 @@ typedef enum attr_t {
|
||||
|
||||
/* Segment */
|
||||
atSegment = 0x0100, /* Code is in a segment */
|
||||
atSegmentChange = 0x0200, /* Either segment start or segment end */
|
||||
} attr_t;
|
||||
|
||||
|
||||
@ -89,6 +90,9 @@ void AddrCheck (unsigned Addr);
|
||||
int SegmentDefined (unsigned Start, unsigned End);
|
||||
/* Return true if the atSegment bit is set somewhere in the given range */
|
||||
|
||||
int HaveSegmentChange (unsigned Addr);
|
||||
/* Return true if the segment change attribute is set for the given address */
|
||||
|
||||
unsigned GetGranularity (attr_t Style);
|
||||
/* Get the granularity for the given style */
|
||||
|
||||
@ -98,6 +102,9 @@ void MarkRange (unsigned Start, unsigned End, attr_t Attr);
|
||||
void MarkAddr (unsigned Addr, attr_t Attr);
|
||||
/* Mark an address with an attribute */
|
||||
|
||||
attr_t GetAttr (unsigned Addr);
|
||||
/* Return the attribute for the given address */
|
||||
|
||||
attr_t GetStyleAttr (unsigned Addr);
|
||||
/* Return the style attribute for the given address */
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2004 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* (C) 2000-2007 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -57,14 +57,22 @@ static unsigned GetSpan (attr_t Style)
|
||||
unsigned RemainingBytes = GetRemainingBytes ();
|
||||
|
||||
/* Count how many bytes are available. This number is limited by the
|
||||
* number of remaining bytes, a label, or the end of the given Style
|
||||
* attribute.
|
||||
* number of remaining bytes, a label, a segment change, or the end of
|
||||
* the given Style attribute.
|
||||
*/
|
||||
unsigned Count = 1;
|
||||
while (Count < RemainingBytes) {
|
||||
if (MustDefLabel(PC+Count) || GetStyleAttr (PC+Count) != Style) {
|
||||
attr_t Attr;
|
||||
if (MustDefLabel(PC+Count)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Attr = GetAttr (PC+Count);
|
||||
if ((Attr & atStyleMask) != Style) {
|
||||
break;
|
||||
}
|
||||
if ((Attr & atSegmentChange)) {
|
||||
break;
|
||||
}
|
||||
++Count;
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2006 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* (C) 2006-2007 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -378,7 +378,7 @@ static void DefOutOfRangeLabel (unsigned long Addr)
|
||||
|
||||
case atIntLabel:
|
||||
case atExtLabel:
|
||||
DefineConst (SymTab[Addr], GetComment (Addr), Addr);
|
||||
DefConst (SymTab[Addr], GetComment (Addr), Addr);
|
||||
break;
|
||||
|
||||
case atUnnamedLabel:
|
||||
|
@ -6,8 +6,8 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2006 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* (C) 1998-2007 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -385,7 +385,7 @@ static void OneOpcode (unsigned RemainingBytes)
|
||||
} else {
|
||||
unsigned I;
|
||||
for (I = 1; I < D->Size; ++I) {
|
||||
if (HaveLabel (PC+I)) {
|
||||
if (HaveLabel (PC+I) || HaveSegmentChange (PC+I)) {
|
||||
Style = atIllegal;
|
||||
MarkAddr (PC, Style);
|
||||
break;
|
||||
|
@ -6,8 +6,8 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2006 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* (C) 2000-2007 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -40,6 +40,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
/* common */
|
||||
#include "addrsize.h"
|
||||
#include "cpu.h"
|
||||
#include "version.h"
|
||||
|
||||
@ -199,7 +200,7 @@ void DefForward (const char* Name, const char* Comment, unsigned Offs)
|
||||
|
||||
|
||||
|
||||
void DefineConst (const char* Name, const char* Comment, unsigned Addr)
|
||||
void DefConst (const char* Name, const char* Comment, unsigned Addr)
|
||||
/* Define an address constant */
|
||||
{
|
||||
if (Pass == PassCount) {
|
||||
@ -216,6 +217,23 @@ void DefineConst (const char* Name, const char* Comment, unsigned Addr)
|
||||
|
||||
|
||||
|
||||
void StartSegment (const char* Name, unsigned AddrSize)
|
||||
/* Start a segment */
|
||||
{
|
||||
if (Pass == PassCount) {
|
||||
Output (".segment");
|
||||
Indent (ACol);
|
||||
if (AddrSize == ADDR_SIZE_DEFAULT) {
|
||||
Output ("\"%s\"", Name);
|
||||
} else {
|
||||
Output ("\"%s\": %s", Name, AddrSizeToStr (AddrSize));
|
||||
}
|
||||
LineFeed ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DataByteLine (unsigned ByteCount)
|
||||
/* Output a line with bytes */
|
||||
{
|
||||
|
@ -6,8 +6,8 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* (C) 2000-2007 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -67,13 +67,19 @@ void LineFeed (void);
|
||||
void DefLabel (const char* Name);
|
||||
/* Define a label with the given name */
|
||||
|
||||
void DefForward (const char* Name, const char* Comment, unsigned Offs);
|
||||
void DefForward (const char* Name, const char* Comment, unsigned Offs);
|
||||
/* Define a label as "* + x", where x is the offset relative to the
|
||||
* current PC.
|
||||
*/
|
||||
|
||||
void DefineConst (const char* Name, const char* Comment, unsigned Addr);
|
||||
void DefConst (const char* Name, const char* Comment, unsigned Addr);
|
||||
/* Define an address constant */
|
||||
|
||||
void StartSegment (const char* Name, unsigned AddrSize);
|
||||
/* Start a segment */
|
||||
|
||||
void EndSegment (void);
|
||||
/* End a segment */
|
||||
|
||||
void OneDataByte (void);
|
||||
/* Output a .byte line with the current code byte */
|
||||
|
@ -52,8 +52,7 @@
|
||||
|
||||
|
||||
/* Hash definitions */
|
||||
#define HASH_SIZE 64 /* Must be power of two */
|
||||
#define HASH_MASK (HASH_SIZE-1)
|
||||
#define HASH_SIZE 53
|
||||
|
||||
/* Segment definition */
|
||||
typedef struct Segment Segment;
|
||||
@ -96,10 +95,14 @@ void AddAbsSegment (unsigned Start, unsigned End, const char* Name)
|
||||
memcpy (S->Name, Name, Len + 1);
|
||||
|
||||
/* Insert the segment into the hash tables */
|
||||
S->NextStart = StartTab[Start & HASH_MASK];
|
||||
StartTab[Start & HASH_MASK] = S;
|
||||
S->NextEnd = EndTab[End & HASH_MASK];
|
||||
EndTab[End & HASH_MASK] = S;
|
||||
S->NextStart = StartTab[Start % HASH_SIZE];
|
||||
StartTab[Start % HASH_SIZE] = S;
|
||||
S->NextEnd = EndTab[End % HASH_SIZE];
|
||||
EndTab[End % HASH_SIZE] = S;
|
||||
|
||||
/* Mark start and end of the segment */
|
||||
MarkAddr (Start, atSegmentChange);
|
||||
MarkAddr (End, atSegmentChange);
|
||||
|
||||
/* Mark the addresses within the segment */
|
||||
MarkRange (Start, End, atSegment);
|
||||
|
Loading…
Reference in New Issue
Block a user