Choose a bank from the services the export needs
A DLL takes space only in its configured execution window while active. If visible RAM is scarce, a window can use RAM behind BASIC or KERNAL ROM. The CPU still executes from C64 RAM. The REU cache supplies the payload bytes.
| Window | Example range | What changes during the call |
|---|---|---|
| Visible RAM | $6000–$6fff | The payload runs without hiding a ROM. |
| RAM under BASIC | $a000–$a7ff | The loader temporarily exposes the RAM under BASIC. |
| RAM under KERNAL | $e000–$e7ff | The loader exposes RAM, preserves processor status, and masks IRQs during the banked operation. |
The range must fit entirely inside its chosen bank. In a KERNAL-hidden export, keep keyboard and disk operations in the resident caller. Supported console output has a generated path to screen-writing helpers. Use a visible window if your export requires KERNAL services.
Follow a banner export into the hidden window
This program seeds the cache from its resident PRG. The loader copies and relocates the payload into the window at $e000. The banner runs there. Its supported console call uses the compiler's trampoline path, and the byte return survives restoration of the caller's mapping.
const c64 = @import("c64");
const ZeroPage = @import("ZeroPage");
memory {
region call_stack: c64 at 0xc800 size 0x0400;
region module_window: c64 at 0xe000 size 0x0800 bank .ram_under_kernal;
region module_cache: reu at 0x030000 size 0x010000;
stack in call_stack;
}
module_loader {
window main in module_window;
reu_cache in module_cache;
}
module enemy_kernal_console abi 1 {
export banner;
}
fn banner() callconv(.stack) u8 {
c64.console.print("TRAMP EXPORT\n", .{});
return 5;
}
export fn main() void {
c64.console.clear();
var ok = false;
if (ZeroPage.module.load("enemy_kernal_console")) {
if (ZeroPage.module.call("enemy_kernal_console", "banner", .{})) |value| {
ok = value == 5;
}
}
c64.console.print("\nMODULE KERNAL TRAMP\n", .{});
if (ok) {
c64.console.print("TRAMP OK\n", .{});
c64.vic.border = 5;
} else {
c64.console.print("TRAMP BAD\n", .{});
c64.vic.border = 2;
}
}
Expect TRAMP EXPORT from the DLL and TRAMP OK from resident code, with a green border. The declared cache starts at REU $030000 and ends at $040000 exclusive, which fits the command's 256 KiB configuration.
Verify the return and the restored mapping
In the VICE monitor, read the processor port with m 0001 0001 at entry to main and again after the call. Use the generated label file to set breakpoints in your build. In the default configuration both reads show 37. Inspect the generated assembly to find the save, bank switch, call, and restore sequence. The export's green-border return and the restored port check two different effects.
Try replacing return 5; with return c64.keyboard.readPetscii(); in banner. The compiler rejects the keyboard helper in this stack-frame export. Read the key in resident code and pass its byte to the export instead. See the banked-window guide for BASIC banking, independent windows, and restrictions when assigning producers to a different window.