mirror of
https://github.com/adamdunkels/ubasic.git
synced 2026-11-20 11:39:43 +00:00
The uBASIC interpreter
To use PEEK and POKE initialize uBASIC from your program with ubasic_init_peek_poke(program, &peek, &poke) where "peek" is a function peek(VARIABLE_TYPE addr) that returns VARIABLE_TYPE and "poke" is a procedure void poke(VARIABLE_TYPE addr, VARIABLE_TYPE value). Use "PEEK addr, var" to set the value of the variable var to the result of calling peek(addr). Use "POKE addr, value" to call poke(addr, value); The argument name "addr" is arbitrary; it doesn't mean you should necessarily use it to pass your routines a memory address. |
||
|---|---|---|
| LICENSE | ||
| Makefile | ||
| README.md | ||
| tests.c | ||
| tokenizer.c | ||
| tokenizer.h | ||
| ubasic.c | ||
| ubasic.h | ||
| use-ubasic.c | ||
| vartype.h | ||
uBASIC: a really simple BASIC interpreter
http://dunkels.com/adam/ubasic/
Written in a couple of hours, for the fun of it. Ended up being used in a bunch of places!
The (non-interactive) uBASIC interpreter supports only the most basic BASIC functionality: if/then/else, for/next, let, goto, gosub, print, and mathematical expressions. There is only support for integer variables and the variables can only have single character names. I have added an API that allows for the program that uses the uBASIC interpreter to get and set BASIC variables, so it might be possible to actually use the uBASIC code for something useful (e.g. a small scripting language for an application that has to be really small).
See the file use-ubasic.c for an example of how to use it.