From 54ed050ecf9a164ecb9cf368bbdedd524f23560a Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 8 Sep 2019 22:28:28 +0200 Subject: [PATCH] Make `BANK(@)` known at assembling time when possible If the current section's bank is fixed, this means this value is known prior to linking. --- src/asm/rpn.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/asm/rpn.c b/src/asm/rpn.c index dff5613c..fc6e228f 100644 --- a/src/asm/rpn.c +++ b/src/asm/rpn.c @@ -19,6 +19,7 @@ #include "asm/main.h" #include "asm/rpn.h" #include "asm/symbol.h" +#include "asm/output.h" #include "asm/warning.h" #include "linkdefs.h" @@ -160,11 +161,14 @@ void rpn_BankSelf(struct Expression *expr) { rpn_Init(expr); - /* - * This symbol is not really relocatable, but this makes the assembler - * write this expression as a RPN patch to the object file. - */ - expr->isReloc = 1; + if (pCurrentSection->nBank == -1) + /* + * This is not really relocatable, but this makes the assembler + * write this expression as a RPN patch to the object file. + */ + expr->isReloc = 1; + else + expr->nVal = pCurrentSection->nBank; pushbyte(expr, RPN_BANK_SELF); expr->nRPNPatchSize++;