Merge pull request #155 from feelfree69/fix-bank-overflow

fix bank overflow
This commit is contained in:
logicog
2026-03-10 21:47:46 +01:00
committed by GitHub
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -21,8 +21,8 @@
#include "machine.h" #include "machine.h"
#include "phy.h" #include "phy.h"
#pragma codeseg BANK1 #pragma codeseg BANK2
#pragma constseg BANK1 #pragma constseg BANK2
extern __code struct machine machine; extern __code struct machine machine;
extern __xdata uint8_t stpEnabled; extern __xdata uint8_t stpEnabled;
+3 -3
View File
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
} }
int nbanks = (filesize - BANK0_SIZE) / BANK_STRIDE; int nbanks = (filesize - BANK0_SIZE) / BANK_STRIDE;
printf("Input file contains %d banks\n", nbanks); printf("Input file contains %d banks\n", nbanks+1);
/* Verify the size of banks in input file: /* Verify the size of banks in input file:
* Bank 0: 0x00002 - 0x04000 <- 0x00000 - 0x03ffe * Bank 0: 0x00002 - 0x04000 <- 0x00000 - 0x03ffe
@@ -119,8 +119,8 @@ int main(int argc, char **argv)
for (int bank = 1; bank <= nbanks; bank++) { for (int bank = 1; bank <= nbanks; bank++) {
for (int b = (bank + 1) * BANK_STRIDE; b < (bank + 1) * BANK_STRIDE + BANK0_SIZE; b ++) { for (int b = (bank + 1) * BANK_STRIDE; b < (bank + 1) * BANK_STRIDE + BANK0_SIZE; b ++) {
if (buffer[b]) { if (buffer[b]) {
printf("WARNING: Bank %d: code segment too large at 0x%x!\n", bank, b); printf("Error: Bank %d: code segment too large at 0x%x!\n", bank, b);
break; return 5;
} }
} }
} }