31 lines
1.2 KiB
C
31 lines
1.2 KiB
C
// bankProbe.c — empirical verification that cRELOC ByteCnt=2 BitShift=16
|
|
// (the BANK16 relocation path) delivers the actually-placed segment bank.
|
|
//
|
|
// Memory at frame 5400, read by runViaFinder.sh:
|
|
// $70 = bank byte of &probe (the codegen path under test)
|
|
// $71 = 0x99 (sentinel: program reached the writeback)
|
|
// $72 = byte at $BE (crt0Gsos stores PBR here = actual placed bank)
|
|
//
|
|
// Control run (current AsmPrinter, LDAi16imm_bank -> `lda $BE`):
|
|
// Expect $70 == $72 (both read PBR via the runtime hack).
|
|
//
|
|
// Patched run (AsmPrinter emits LDA_Imm16_Bank with fixup_bank16):
|
|
// $70 = (segPlacedBase + &probe.lo16) >> 16 patched by the Loader cRELOC.
|
|
// PASS if $70 == $72 and $72 != 0 (proves BANK16 cRELOC delivers placed bank).
|
|
// FAIL if $70 == 0 while $72 != 0 (Loader's BitShift=16 truncates to 16-bit
|
|
// segPlacedBase as the AsmPrinter comment claims) -> keep `lda $BE` hack.
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
static volatile uint8_t probe;
|
|
|
|
|
|
int main(void) {
|
|
uint32_t pi = (uint32_t)(void *)&probe;
|
|
*(volatile uint8_t *)0x70 = (uint8_t)((pi >> 16) & 0xFF);
|
|
*(volatile uint8_t *)0x72 = *(volatile uint8_t *)0xBE;
|
|
*(volatile uint8_t *)0x71 = 0x99;
|
|
for (;;) {
|
|
}
|
|
}
|