commit 902997b570dba4e719de8c989b4ecdf8b0dbb9fb
parent 843c770ef8d59b417de2cd925593ffb03256a457
Author: Brian Swetland <swetland@frotz.net>
Date: Mon, 30 Jun 2025 15:16:04 -0700
sr32asm: hack for relative branches
Allow @<number> to be used in b/j instructions to reference
instructions relative to the current instruction (forward
or backward)
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/softrisc32/src/assemble-sr32.c b/softrisc32/src/assemble-sr32.c
@@ -479,6 +479,13 @@ void parse_rel(State *s, unsigned type, uint32_t *i) {
case tDOT:
*i = -4;
break;
+ case tAT:
+ next(s);
+ if ((type == TYPE_PCREL_S16) || (type == TYPE_PCREL_S21)) {
+ expect(s, tNUMBER);
+ *i = (s->num * 4) - 4;
+ break;
+ }
default:
die("expected address");
}