Teach da65 about table units

This commit is contained in:
Lauri Kasanen 2022-11-08 19:04:46 +02:00
parent cce119a9e7
commit 56a414593a
5 changed files with 43 additions and 2 deletions

View File

@ -522,6 +522,11 @@ following attributes are recognized:
</descrip>
<tag><tt>UNIT</tt></tag>
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.
<tag><tt>ADDRMODE</tt></tag>
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

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -91,6 +91,7 @@ typedef enum token_t {
INFOTOK_END,
INFOTOK_TYPE,
INFOTOK_ADDRMODE,
INFOTOK_UNIT,
INFOTOK_CODE,
INFOTOK_BYTETAB,