Skip to content

szilvasyz/bas65

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bas65 - BASIC interpreter for 6502 written in C

Overview

(As it is written in pure C it is not especially linked to the CPU 6502.) The main goal of the interpreter is using it for controlling purposes in very small computers (embedded systems) or in synthesized environments (FPGAs).

Implementation

Main features

  • portable source code
  • 26 integer variables (A*Z) stored in separated area
  • no arrays
  • no strings (except for printing quoted string literals)
  • integer arithmetics
  • multiple statements can be written in a line separated by comma
  • separated, fixed length FOR and GOSUB stacks
  • tokenized storage of the program text
  • calculated GOTO and GOSUB possible
  • no THEN keyword, any statement can be written immediately after the conditional expression of IF
  • no ELSE branch in IF statement
  • if STEP keyword is omitted, FOR automatically selects 1 or -1 for STEP according to the loop limits

BASIC statements

  • LET
  • PRINT
  • POKE
  • LIST
  • NEW
  • RUN
  • GOTO
  • GOSUB
  • RETURN
  • STOP
  • IF
  • FOR
  • NEXT

BASIC Functions

  • PEEK

Usage

Sample BASIC program

10 FOR I=1TO 200
20 PRINT I;" = ";
30 N=I : GOSUB 1000
40 NEXT 
999 STOP 
1000 REM  Determine prime factors of N
1010 P=2
1020 IF (N%P)=0LET N=N/P : PRINT P;"*"; : GOTO 1020
1030 P=P+1 : IF N>1GOTO 1020
1040 PRINT N : RETURN 

About

BASIC interpreter written in C for 6502

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published