Allow specifying range end as a size

This commit is contained in:
Lauri Kasanen
2022-10-27 18:19:44 +03:00
parent ad7c5a6617
commit c95c9c2749
4 changed files with 24 additions and 4 deletions

View File

@@ -592,9 +592,19 @@ static void RangeSection (void)
case INFOTOK_END:
AddAttr ("END", &Attributes, tEnd);
InfoNextTok ();
InfoAssureInt ();
InfoRangeCheck (0x0000, 0xFFFF);
End = InfoIVal;
if (InfoTok == INFOTOK_OFFSET_INTCON) {
InfoRangeCheck (0x0000, 0xFFFF);
if (!(Attributes & tStart))
InfoError ("When using End with an offset, Start must be specified before");
End = Start + InfoIVal - 1;
if (End > 0xFFFF)
InfoError ("Range error");
} else {
InfoAssureInt ();
InfoRangeCheck (0x0000, 0xFFFF);
End = InfoIVal;
}
InfoNextTok ();
break;

View File

@@ -372,6 +372,14 @@ Again:
return;
}
/* Decimal number offset? */
if (C == '+') {
NextChar ();
InfoIVal = GetDecimalToken ();
InfoTok = INFOTOK_OFFSET_INTCON;
return;
}
/* Other characters */
switch (C) {

View File

@@ -48,6 +48,7 @@
typedef enum token_t {
INFOTOK_NONE,
INFOTOK_INTCON,
INFOTOK_OFFSET_INTCON,
INFOTOK_STRCON,
INFOTOK_CHARCON,
INFOTOK_IDENT,