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