Files
Basys3RiscV/basic/basic.ld
T
brad ArantandClaude Opus 5.5 2e668c708f BASIC compiler (tools/basc.py) and a runtime jump table in BASIC's ROM
tools/basc.py compiles a BASIC program to C and through GCC to an Intel HEX
file loaded at A200h like the games, with a two-line BLOAD/CALL loader.
Arithmetic, variables, arrays, all control flow and graphics arguments are
compiled; PRINT, INPUT, strings, files, sound, DATA and the remaining
functions go through BASIC's ROM via a fixed jump table at 9F00h (RT_ABI 1),
so they behave identically. basic/test-compile.py runs 31 programs both
ways and checks identical screens and graphics; typical loops run 7-26x
faster. New error PROGRAM NEEDS ANOTHER BASIC.

Fixes a bug present since the first version: variable numbers past 255
wrapped, so X1-Z9 shared storage with A-B9 (A7 and Y were the same
variable). test-blocks.py checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 19:29:59 -08:00

43 lines
1.3 KiB
Plaintext

/* BASIC: code and constants below A000h (ROM_TOP: the hardware ignores writes
there), the program area at A000h, then data. 12000h-12FFFh is left free for
machine code; the stack comes down from 13FF0h; 13FF8h-13FFFh hold the clock
(include/basys3.h). */
OUTPUT_ARCH("riscv")
ENTRY(_start)
MEMORY
{
ROM (rx) : ORIGIN = 0x00000, LENGTH = 0xA000
RAM (rw) : ORIGIN = 0x0A000, LENGTH = 0x8000
}
SECTIONS
{
.text : {
KEEP(*(.text.start))
*(.text .text.*)
*(.rodata .rodata.* .srodata .srodata.*)
. = ALIGN(4);
} > ROM
/* the jump table for compiled programs (rt_table in basic.c): fixed */
.rtab 0x9F00 : { KEEP(*(.rtab)) } > ROM
.arena (NOLOAD) : { KEEP(*(.arena)) } > RAM
.data : ALIGN(4) {
__data_start = .;
*(.data .data.*)
__global_pointer$ = . + 0x800;
*(.sdata .sdata.*)
. = ALIGN(4);
__data_end = .;
} > RAM AT > ROM
__data_load = LOADADDR(.data);
.bss (NOLOAD) : ALIGN(4) {
__bss_start = .;
*(.sbss .sbss.* .bss .bss.* COMMON)
. = ALIGN(4);
__bss_end = .;
} > RAM
ASSERT(__bss_end <= 0x12000, "BASIC's data runs into the machine-code area")
__stack_top = 0x13FF0;
__rom_end = __data_load + SIZEOF(.data);
/DISCARD/ : { *(.comment) *(.riscv.attributes) }
}