DOWNLOAD HARE BASIC
Folder in Aleksi's Eight Bit Shed: https://bit.ly/harebasic
Hare Basic Handbook: https://bit.ly/harebasichandbook
Released in May 2024
Many thanks to Robin Harbron / 8-Bit Show And Tell for the YouTube coverage!
Hare Basic: 10× Faster CBM BASIC
Hare Basic is a high-speed, integer-only BASIC interpreter. It runs up to 10× faster than standard CBM BASIC while preserving the classic look and feel.
Write real-time logic, smooth animation, and responsive programs—without touching machine code. Hare Basic keeps things simple: one operation at a time, no strings or arrays, and all variables are 16-bit unsigned integers (A to Z).
You get core commands like PRINT, POKE, GOTO, and FOR/NEXT, plus fast extras like A+/A– (quick increment/decrement), null-terminated string support via string POKE and STR$, and direct-to-memory INPUT.
Call Hare code from CBM BASIC using USR(line)—just like GOSUB—or write entire programs directly in Hare. For features Hare doesn’t support (like DATA statements), fall back to CBM BASIC, or use Hare’s SAVE and LOAD commands to work with binary files directly in memory.
Think of it as machine-code discipline with BASIC syntax—lean, direct, and fast.
INTRODUCTION
Hare Basic is a fast, limited instruction set, integer-only basic interpreter (not a compiler) for Commodore 64 and VIC 20.
Commands: PRINT, INPUT, GET, POKE, SYS, GOTO, CLR, GOSUB, RETURN, IF/THEN, END, FOR/NEXT, LOAD, SAVE, REM, LET, RND (as command), CMD (repurposed for POKE mode)
Functions: AND, OR, PEEK, VAL, LEN, ASC, <, =, >, <>, <=, >=, +, -
Variables: 26 one-letter variables A-Z, 16-bit unsigned integer (not shared with CBM BASIC)
Arithmetics: 16-bit unsigned integer addition, subtraction, multiplication, division, negation
Limited string functions: CHR$, STR$ (repurposed to display strings), POKE12345,"TEXT"
THE BIGGEST DIFFERENCES FROM CBM BASIC
Hare Basic syntax is very similar to CBM BASIC, but there's quite a few restrictions and some critical differences. You should still feel like at home right away, just dive in!
There is no string variables. However, there's simple support for null-terminated strings that can be freely located in the memory.
There is no arrays. Access memory directly with POKE and PEEK to create larger data structures. All variables are 16-bit unsigned integers. Negative numbers, if entered, are handled as two's complement.
Only one arithmetic operation can be done at once. Arithmetics may only be done as separate instructions and not as regular expressions in command parameters. Hare Basic interpreter doesn't understand the concept of temporary variables.
Whitespaces cannot be used. You will get a ?HARE ERROR READY.
GOTO and GOSUB can take a variable as destination. THEN doesn't accept a variable, only numbers. However, THENGOTO works fine with variables.
Quick "C-style" variable increment/decrement functionality is added: A+, A-
POKE can also poke strings into memory. Repurposed CMD0 / CMD1 command sets screen codes or null-terminated PETSCII output (default) for string POKE's.
STR$ function is repurposed to refer to null-terminated strings in the memory. You can use a variable as a pointer or use a direct memory address. Works with PRINT, LOAD and SAVE.
RND is implemented as a command, that places a random number in the range 0-65534 in variable A.
LOAD command doesn't restart the program, but continues at the next instruction. Second parameter defines the load address. LOAD"FILE",8 is the same as ,8,1 in CBM BASIC.
SAVE command can save any memory area, and then continues at the next instruction. Both LOAD and SAVE can either take a direct filename in quotes or a filename anywhere from the memory through the repurposed STR$ function.
There's no DATA or READ. Use LOAD instead to load tables and data directly into memory, or write an initialization routine in slow CBM BASIC to read your DATA's into memory.
FOR/NEXT loops cannot run through zero, flipping from negative to positive or vice versa. This is due to how the negative numbers and STEP's are implemented: Sign flip is always considered an end condition to avoid endless loops if the STEP overflows.
Hare Basic variable values persist between subsequent calls, unless they are cleared using the CLR command.
About two character compare signs: Only <>, <=, and >= are valid comparisons in Hare Basic. The following 'smiley-style' variants will result in a ?HARE ERROR: ><, =<, =>
RUNNING HARE BASIC PROGRAMS
A=USR(10) in CBM BASIC starts running a Hare Basic program starting from line 10.
If you're writing your entire program in Hare Basic, just type A=USR(10):END on the first basic line before line 10. Start writing Hare Basic code from line 10. This way you can start your program normally with a RUN.
It's easy to call Hare Basic subroutines from CBM BASIC code by using the function USR. You could then consider A=USR(100) as "GOSUB100", except that the subroutine is now a Hare Basic subroutine. The subroutine ends and execution continues in CBM BASIC, when Hare Basic interpreter reaches an END instruction, or an RETURN instruction without a previous GOSUB, or if the last basic line number is reached.
Highest starting line number for USR function is 32767, but you can use line numbers up to 63999 within your program.
Hare Basic variable A value is returned to CBM BASIC, and it goes to whatever CBM BASIC variable you had with the USR.
Hare Basic instructions cannot be executed directly from the READY prompt.
Hare Basic interpreter can be automatically loaded from CBM BASIC. Here's the suggested boot
code for C-64 and VIC 20:
0 REM COMMODORE 64 HARE BASIC LOADER
1 IFA=0ANDPEEK(793)<>192THENA=1:LOAD"C000",8,1
2 IFPEEK(793)<>192THENSYS49152
3 A=USR(10):END
0 REM VIC 20 HARE BASIC LOADER
1 IFA=0ANDPEEK(793)<>160THENA=1:LOAD"A000",8,1
2 IFPEEK(793)<>160THENSYS40960
3 A=USR(10):END
Hare Basic boots up silently and invisibly if sys'd from inside a program. If sys'ed from direct mode, Hare Basic shows the startup text and does a NEW.
When loading Hare Basic programs, you may need to use LOAD"NAME",8 instead of ,8,1. That's because if you have used the GO12 system call to reserve memory for graphics, the basic text area has been moved to address 16384 ($4000) on C-64 or 8192 ($2000) on VIC 20. See MEMORY CONFIGURATIONS.
SPECIAL VARIABLES: A, X, Y, Z
In Hare Basic the variables A, X, Y, and Z have specialized uses and you should generally avoid using them elsewhere, except maybe as short-term local variables.
A
- Return value to CBM BASIC(to USR function variable) after Hare Basic routine ends
- 6502/6510 accumulator value before and after SYS command (low 8 bits)
- Variable where RND command places the next pseudo-random number
- Parameter to/from GO system calls (character code, value, sprite index)
X, Y
- 6502/6510 X- and Y-register values before and after SYS command (low 8 bits)
- Parameters to/from GO system calls (memory range, coordinates)
Z
- 6502/6510 carry flag before and after SYS command (0 or 1)
- Parameter to/from GO system calls (target address, bit shifts, color memory)
EXAMPLES ON THE HARE BASIC DISK
Remember to load Hare Basic programs using LOAD with ",8" (not ",8,1"), because the basic program area may have been moved by a GO12 system call earlier in the session. Also, some of the example programs work on both C-64 and VIC 20, but only if loaded with ",8".
Type SYS49152 (C-64) or SYS40960 (VIC 20) to reset Hare Basic.