Allow specifying offset in addition to alignment

This commit is contained in:
ISSOtm
2020-04-08 00:40:41 +02:00
parent e82ad21704
commit b0ec8468e6
16 changed files with 154 additions and 44 deletions

View File

@@ -1425,6 +1425,7 @@ section : T_POP_SECTION sectunion string ',' sectiontype sectorg sectattrs {
sectunion : /* empty */ { $$ = false; }
| T_POP_UNION { $$ = true; }
;
sectiontype : T_SECT_WRAM0 { $$ = SECTTYPE_WRAM0; }
| T_SECT_VRAM { $$ = SECTTYPE_VRAM; }
@@ -1449,15 +1450,29 @@ sectorg : /* empty */ { $$ = -1; }
sectattrs : /* empty */ {
$$.alignment = 0;
$$.alignOfs = 0;
$$.bank = -1;
}
| sectattrs ',' T_OP_ALIGN '[' uconst ']' {
if ($5 < 0 || $5 > 16)
yyerror("Alignment must be between 0 and 16 bits, not %u",
if ($5 > 16)
yyerror("Alignment must be between 0 and 16, not %u",
$5);
else
$$.alignment = $5;
}
| sectattrs ',' T_OP_ALIGN '[' uconst ',' uconst ']' {
if ($5 > 16) {
yyerror("Alignment must be between 0 and 16, not %u",
$5);
} else {
$$.alignment = $5;
if ($7 >= 1 << $$.alignment)
yyerror("Alignment offset must not be greater than alignment (%u < %u)",
$7, 1 << $$.alignment);
else
$$.alignOfs = $7;
}
}
| sectattrs ',' T_OP_BANK '[' uconst ']' {
/* We cannot check the validity of this now */
$$.bank = $5;