diff --git a/doc/da65.sgml b/doc/da65.sgml
index aa6ad40bf..3a01ce4f5 100644
--- a/doc/da65.sgml
+++ b/doc/da65.sgml
@@ -522,6 +522,11 @@ following attributes are recognized:
+ UNIT
+ Split the table into sections of this size. For example, if you have a
+ ByteTable of size 48, but it has logical groups of size 16, specifying
+ 16 for UNIT adds newlines after every 16 bytes. UNIT is always in bytes.
+
ADDRMODE
When disassembling 65816 code, this specifies the M and X flag states
for this range. It's a string argument of the form "mx", capital letters
diff --git a/src/da65/attrtab.h b/src/da65/attrtab.h
index 37143c0d1..4a0ea8225 100644
--- a/src/da65/attrtab.h
+++ b/src/da65/attrtab.h
@@ -71,6 +71,9 @@ typedef enum attr_t {
atSegmentEnd = 0x0200, /* Segment end */
atSegmentStart = 0x0400, /* Segment start */
+ /* Table unit separator */
+ atTableUnit = 0x0800,
+
/* 65816 addressing mode */
atMem8 = 0x1000, /* M flag enabled, 8-bit */
atMem16 = 0x2000, /* M flag disabled, 16-bit */
@@ -79,7 +82,7 @@ typedef enum attr_t {
atStyleMask = 0x000F, /* Output style */
atLabelMask = 0x00F0, /* Label information */
- atSegmentMask = 0x0F00, /* Segment information */
+ atSegmentMask = 0x0700, /* Segment information */
at65816Mask = 0xF000, /* 65816 information */
} attr_t;
diff --git a/src/da65/data.c b/src/da65/data.c
index 7355e60d1..f85cd327d 100644
--- a/src/da65/data.c
+++ b/src/da65/data.c
@@ -70,7 +70,7 @@ static unsigned GetSpan (attr_t Style)
if ((Attr & atStyleMask) != Style) {
break;
}
- if ((Attr & (atSegmentStart | atSegmentEnd))) {
+ if ((Attr & (atSegmentStart | atSegmentEnd | atTableUnit))) {
break;
}
++Count;
diff --git a/src/da65/infofile.c b/src/da65/infofile.c
index 923cc53c9..fbf367cc9 100644
--- a/src/da65/infofile.c
+++ b/src/da65/infofile.c
@@ -528,6 +528,7 @@ static void RangeSection (void)
{ "START", INFOTOK_START },
{ "TYPE", INFOTOK_TYPE },
{ "ADDRMODE", INFOTOK_ADDRMODE },
+ { "UNIT", INFOTOK_UNIT },
};
static const IdentTok TypeDefs[] = {
@@ -552,6 +553,7 @@ static void RangeSection (void)
tName = 0x08,
tComment = 0x10,
tAddrMode = 0x20,
+ tUnit = 0x40,
tNeeded = (tStart | tEnd | tType)
};
unsigned Attributes = tNone;
@@ -564,6 +566,7 @@ static void RangeSection (void)
char* Name = 0;
char* Comment = 0;
unsigned MemberSize = 0;
+ unsigned Unit = 0;
/* Skip the token */
@@ -682,6 +685,15 @@ static void RangeSection (void)
InfoNextTok ();
break;
+ case INFOTOK_UNIT:
+ AddAttr ("UNIT", &Attributes, tUnit);
+ InfoNextTok ();
+ InfoAssureInt ();
+ InfoRangeCheck (0x0002, 0xFFFF);
+ Unit = InfoIVal;
+ InfoNextTok ();
+ break;
+
default:
Internal ("Unexpected token: %u", InfoTok);
}
@@ -705,6 +717,26 @@ static void RangeSection (void)
}
}
+ /* Only tables support unit sizes */
+ if ((Attributes & tUnit) &&
+ Type != atAddrTab &&
+ Type != atByteTab &&
+ Type != atDByteTab &&
+ Type != atDWordTab &&
+ Type != atRtsTab &&
+ Type != atTextTab &&
+ Type != atWordTab) {
+ InfoError ("Only table types support unit size");
+ }
+
+ /* Mark each unit separator */
+ if (Attributes & tUnit) {
+ unsigned i;
+ for (i = Start; i < End; i += Unit) {
+ MarkAddr(i, atTableUnit);
+ }
+ }
+
/* Start must be less than end */
if (Start > End) {
InfoError ("Start value must not be greater than end value");
diff --git a/src/da65/scanner.h b/src/da65/scanner.h
index 60648a40c..ce76d4a98 100644
--- a/src/da65/scanner.h
+++ b/src/da65/scanner.h
@@ -91,6 +91,7 @@ typedef enum token_t {
INFOTOK_END,
INFOTOK_TYPE,
INFOTOK_ADDRMODE,
+ INFOTOK_UNIT,
INFOTOK_CODE,
INFOTOK_BYTETAB,