diff --git a/man/rgblink.5 b/man/rgblink.5 index 192560ad..ea827709 100644 --- a/man/rgblink.5 +++ b/man/rgblink.5 @@ -67,10 +67,11 @@ are only relevant to assembly code and do not apply in section names. When a new bank statement is found, sections found after it will be placed right from the beginning of that bank. If the linker script switches to a different bank and then comes back to a previous one, it will continue from the last address that was used. .Pp -The only two commands are -.Ic ORG +The only three commands are +.Ic ORG , +.Ic ALIGN , and -.Ic ALIGN : +.Ic DS : .Bl -bullet .It .Ic ORG @@ -83,6 +84,9 @@ will increase the address until it is aligned to the specified boundary .Ql ALIGN 8 will align to $100 .Pc . +.It +.Ic DS +will increase the address by the specified non-negative amount. .El .Pp .Sy Note: diff --git a/src/link/script.c b/src/link/script.c index ebd4ca98..7d3705c4 100644 --- a/src/link/script.c +++ b/src/link/script.c @@ -154,6 +154,7 @@ char const *tokenTypes[] = { enum LinkerScriptCommand { COMMAND_ORG, COMMAND_ALIGN, + COMMAND_DS, COMMAND_INVALID }; @@ -170,7 +171,8 @@ struct LinkerScriptToken { static char const * const commands[] = { [COMMAND_ORG] = "ORG", - [COMMAND_ALIGN] = "ALIGN" + [COMMAND_ALIGN] = "ALIGN", + [COMMAND_DS] = "DS" }; static int nextChar(void) @@ -339,10 +341,17 @@ static void processCommand(enum LinkerScriptCommand command, uint16_t arg, uint1 break; case COMMAND_ALIGN: - if (arg >= 16) + if (arg >= 16) { arg = 0; - else - arg = (*pc + (1 << arg) - 1) & ~((1 << arg) - 1); + } else { + uint16_t mask = (1 << arg) - 1; + + arg = (*pc + mask) & ~mask; + } + break; + + case COMMAND_DS: + arg += *pc; } if (arg < *pc) diff --git a/test/link/section-attributes.asm b/test/link/section-attributes.asm index db5b596c..4ea51d14 100644 --- a/test/link/section-attributes.asm +++ b/test/link/section-attributes.asm @@ -1,2 +1,3 @@ SECTION "sec",ROM0,ALIGN[4] + ds 8, $42 SECTION "secfix",ROM0[$20] diff --git a/test/link/section-attributes.link b/test/link/section-attributes.link index 7d62322a..2d93a7e6 100644 --- a/test/link/section-attributes.link +++ b/test/link/section-attributes.link @@ -1,5 +1,6 @@ ROM0 align 4 "sec" + ds $18 org $20 "secfix"