├── .gitattributes ├── .github └── workflows │ └── c-cpp.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── a5200.md ├── cc65 ├── LICENSE ├── README.md ├── ar65 │ ├── add.c │ ├── add.h │ ├── del.c │ ├── del.h │ ├── error.c │ ├── error.h │ ├── exports.c │ ├── exports.h │ ├── extract.c │ ├── extract.h │ ├── fileio.c │ ├── fileio.h │ ├── global.c │ ├── global.h │ ├── library.c │ ├── library.h │ ├── list.c │ ├── list.h │ ├── main.c │ ├── objdata.c │ ├── objdata.h │ ├── objfile.c │ └── objfile.h ├── asminc │ ├── atari.inc │ ├── atari5200.inc │ ├── atari_antic.inc │ ├── atari_gtia.inc │ ├── atari_pokey.inc │ └── target.inc ├── ca65 │ ├── anonname.c │ ├── anonname.h │ ├── asserts.c │ ├── asserts.h │ ├── condasm.c │ ├── condasm.h │ ├── dbginfo.c │ ├── dbginfo.h │ ├── ea.h │ ├── ea65.c │ ├── ea65.h │ ├── easw16.c │ ├── easw16.h │ ├── enum.c │ ├── enum.h │ ├── error.c │ ├── error.h │ ├── expr.c │ ├── expr.h │ ├── feature.c │ ├── feature.h │ ├── filetab.c │ ├── filetab.h │ ├── fragment.c │ ├── fragment.h │ ├── global.c │ ├── global.h │ ├── incpath.c │ ├── incpath.h │ ├── instr.c │ ├── instr.h │ ├── istack.c │ ├── istack.h │ ├── lineinfo.c │ ├── lineinfo.h │ ├── listing.c │ ├── listing.h │ ├── macro.c │ ├── macro.h │ ├── main.c │ ├── nexttok.c │ ├── nexttok.h │ ├── objcode.c │ ├── objcode.h │ ├── objfile.c │ ├── objfile.h │ ├── options.c │ ├── options.h │ ├── pseudo.c │ ├── pseudo.h │ ├── repeat.c │ ├── repeat.h │ ├── scanner.c │ ├── scanner.h │ ├── segdef.c │ ├── segdef.h │ ├── segment.c │ ├── segment.h │ ├── sizeof.c │ ├── sizeof.h │ ├── span.c │ ├── span.h │ ├── spool.c │ ├── spool.h │ ├── struct.c │ ├── struct.h │ ├── studyexpr.c │ ├── studyexpr.h │ ├── symbol.c │ ├── symbol.h │ ├── symentry.c │ ├── symentry.h │ ├── symtab.c │ ├── symtab.h │ ├── token.c │ ├── token.h │ ├── toklist.c │ ├── toklist.h │ ├── ulabel.c │ └── ulabel.h ├── common │ ├── abend.c │ ├── abend.h │ ├── addrsize.c │ ├── addrsize.h │ ├── alignment.c │ ├── alignment.h │ ├── assertion.c │ ├── assertion.h │ ├── attrib.h │ ├── bitops.c │ ├── bitops.h │ ├── cddefs.h │ ├── chartype.c │ ├── chartype.h │ ├── check.c │ ├── check.h │ ├── cmdline.c │ ├── cmdline.h │ ├── coll.c │ ├── coll.h │ ├── cpu.c │ ├── cpu.h │ ├── debugflag.c │ ├── debugflag.h │ ├── exprdefs.c │ ├── exprdefs.h │ ├── fileid.c │ ├── fileid.h │ ├── filepos.c │ ├── filepos.h │ ├── filestat.c │ ├── filestat.h │ ├── filetime.c │ ├── filetime.h │ ├── filetype.c │ ├── filetype.h │ ├── fname.c │ ├── fname.h │ ├── fragdefs.h │ ├── gentype.c │ ├── gentype.h │ ├── hashfunc.c │ ├── hashfunc.h │ ├── hashtab.c │ ├── hashtab.h │ ├── hlldbgsym.h │ ├── inline.h │ ├── intstack.c │ ├── intstack.h │ ├── inttypes.h │ ├── libdefs.h │ ├── lidefs.h │ ├── mmodel.c │ ├── mmodel.h │ ├── objdefs.h │ ├── optdefs.h │ ├── print.c │ ├── print.h │ ├── scopedefs.h │ ├── searchpath.c │ ├── searchpath.h │ ├── segdefs.h │ ├── segnames.c │ ├── segnames.h │ ├── shift.c │ ├── shift.h │ ├── strbuf.c │ ├── strbuf.h │ ├── strpool.c │ ├── strpool.h │ ├── strutil.c │ ├── strutil.h │ ├── symdefs.h │ ├── target.c │ ├── target.h │ ├── tgttrans.c │ ├── tgttrans.h │ ├── va_copy.h │ ├── version.c │ ├── version.h │ ├── xmalloc.c │ ├── xmalloc.h │ ├── xsprintf.c │ └── xsprintf.h └── ld65 │ ├── asserts.c │ ├── asserts.h │ ├── bin.c │ ├── bin.h │ ├── binfmt.c │ ├── binfmt.h │ ├── cfgexpr.c │ ├── cfgexpr.h │ ├── condes.c │ ├── condes.h │ ├── config.c │ ├── config.h │ ├── dbgfile.c │ ├── dbgfile.h │ ├── dbgsyms.c │ ├── dbgsyms.h │ ├── error.c │ ├── error.h │ ├── exports.c │ ├── exports.h │ ├── expr.c │ ├── expr.h │ ├── extsyms.c │ ├── extsyms.h │ ├── fileinfo.c │ ├── fileinfo.h │ ├── fileio.c │ ├── fileio.h │ ├── filepath.c │ ├── filepath.h │ ├── fragment.c │ ├── fragment.h │ ├── global.c │ ├── global.h │ ├── library.c │ ├── library.h │ ├── lineinfo.c │ ├── lineinfo.h │ ├── main.c │ ├── mapfile.c │ ├── mapfile.h │ ├── memarea.c │ ├── memarea.h │ ├── o65.c │ ├── o65.h │ ├── objdata.c │ ├── objdata.h │ ├── objfile.c │ ├── objfile.h │ ├── scanner.c │ ├── scanner.h │ ├── scopes.c │ ├── scopes.h │ ├── segments.c │ ├── segments.h │ ├── span.c │ ├── span.h │ ├── spool.c │ ├── spool.h │ ├── tpool.c │ ├── tpool.h │ ├── xex.c │ └── xex.h ├── compiler ├── LICENSE ├── USAGE.md ├── a5200.tgt ├── a800.tgt ├── atari-5200.tgt ├── atari-cart-fp.tgt ├── atari-cart-int.tgt ├── atari-cart.tgt ├── atari-fp.tgt ├── atari-int.tgt ├── default.tgt ├── fastbasic-a5200.cfg ├── fastbasic-cart.cfg ├── fastbasic.cfg └── utf8.manifest ├── deps.mak ├── disk └── dos │ ├── bwdos-license.txt │ ├── copy.com │ ├── efast.asm │ ├── efast.com │ ├── efast.txt │ ├── pause.com │ └── xbw14d.dos ├── help.txt ├── make-release.sh ├── manual.md ├── readme ├── rules.mak ├── samples ├── fp │ ├── ahlbench.bas │ ├── draw.bas │ ├── fedora.bas │ ├── mastodon.bas │ └── nc.bas └── int │ ├── carrera3d.bas │ ├── dli.bas │ ├── iospeed.bas │ ├── joyas.bas │ ├── pi.bas │ ├── pmtest.bas │ └── sieve.bas ├── src ├── a5200cart.asm ├── actions.asm ├── alloc.asm ├── cartridge.asm ├── cmdline.bas ├── cmdmenu.asm ├── comp_header.asm ├── compile.asm ├── compiler │ ├── atarifp.cc │ ├── atarifp.h │ ├── codestat.cc │ ├── codestat.h │ ├── codew.h │ ├── compile.cc │ ├── compile.h │ ├── ifile.cc │ ├── ifile.h │ ├── looptype.cc │ ├── looptype.h │ ├── main.cc │ ├── os.cc │ ├── os.h │ ├── parser-actions.cc │ ├── parser-actions.h │ ├── parser.cc │ ├── parser.h │ ├── peephole.cc │ ├── peephole.h │ ├── synt-emit-asm.cc │ ├── synt-emit-asm.h │ ├── synt-optimize.cc │ ├── synt-optimize.h │ ├── synt-parser.cc │ ├── synt-parser.h │ ├── synt-preproc.cc │ ├── synt-preproc.h │ ├── synt-pstate.cc │ ├── synt-pstate.h │ ├── synt-sm-list.h │ ├── synt-sm.cc │ ├── synt-sm.h │ ├── synt-symlist.cc │ ├── synt-symlist.h │ ├── synt-wlist.cc │ ├── synt-wlist.h │ ├── syntp.cc │ ├── target.cc │ ├── target.h │ ├── vartype.cc │ └── vartype.h ├── countlines.asm ├── deftok.inc ├── editor.bas ├── errors.asm ├── interp │ ├── a5200 │ │ ├── drawto.asm │ │ ├── getkey.asm │ │ ├── graphics.asm │ │ ├── input.asm │ │ ├── locate.asm │ │ ├── putchar.asm │ │ ├── str.asm │ │ └── val.asm │ ├── a800 │ │ ├── bgetput.asm │ │ ├── getkey.asm │ │ ├── graphics.asm │ │ ├── input.asm │ │ ├── iochn.asm │ │ ├── putchar.asm │ │ ├── str.asm │ │ ├── streol.asm │ │ ├── val.asm │ │ └── xio.asm │ ├── absneg.asm │ ├── addsub.asm │ ├── atari │ │ ├── color.asm │ │ ├── pause.asm │ │ ├── pmgraphics.asm │ │ ├── position.asm │ │ ├── print_tab.asm │ │ ├── rand.asm │ │ ├── soundoff.asm │ │ └── time.asm │ ├── atarifp │ │ ├── fp_abs.asm │ │ ├── fp_atn.asm │ │ ├── fp_cmp.asm │ │ ├── fp_coef.asm │ │ ├── fp_const.asm │ │ ├── fp_div.asm │ │ ├── fp_evalpoly.asm │ │ ├── fp_exp.asm │ │ ├── fp_exp10.asm │ │ ├── fp_int.asm │ │ ├── fp_intfp.asm │ │ ├── fp_ipow.asm │ │ ├── fp_load.asm │ │ ├── fp_log.asm │ │ ├── fp_log10.asm │ │ ├── fp_mul.asm │ │ ├── fp_pop.asm │ │ ├── fp_push.asm │ │ ├── fp_rnd.asm │ │ ├── fp_set1.asm │ │ ├── fp_sgn.asm │ │ ├── fp_sincos.asm │ │ ├── fp_sqrt.asm │ │ ├── fp_store.asm │ │ ├── fp_str.asm │ │ ├── fp_sub.asm │ │ ├── fp_time.asm │ │ ├── fp_val.asm │ │ ├── fpmain.asm │ │ └── mul6.asm │ ├── bitand.asm │ ├── bitexor.asm │ ├── bitor.asm │ ├── chr.asm │ ├── clearmem.asm │ ├── cmpstr.asm │ ├── comp0.asm │ ├── const.asm │ ├── const_poke.asm │ ├── copystr.asm │ ├── dec.asm │ ├── div.asm │ ├── dpeek.asm │ ├── dpoke.asm │ ├── for.asm │ ├── for_exit.asm │ ├── inc.asm │ ├── jump.asm │ ├── land.asm │ ├── lnot.asm │ ├── lor.asm │ ├── move.asm │ ├── mset.asm │ ├── mul.asm │ ├── negax.asm │ ├── nmove.asm │ ├── peek.asm │ ├── peekb.asm │ ├── poke.asm │ ├── pop.asm │ ├── print_str.asm │ ├── push.asm │ ├── put.asm │ ├── putbyte.asm │ ├── return.asm │ ├── saddr.asm │ ├── sgn.asm │ ├── shl8.asm │ ├── strindex.asm │ ├── ushl.asm │ ├── usr.asm │ ├── varadd.asm │ ├── varaddr.asm │ └── varstore.asm ├── interpreter.asm ├── memptr.asm ├── parse.asm ├── standalone.asm ├── syntax │ ├── a5200.syn │ ├── a800.syn │ ├── basic.syn │ ├── dli.syn │ ├── extended.syn │ ├── fileio.syn │ ├── float.syn │ ├── fujinet.syn │ ├── gr-a5200.syn │ ├── graphics.syn │ ├── pm.syn │ ├── sio.syn │ └── sound.syn └── vars.asm ├── startup.bat ├── template.tex ├── tests.mak ├── testsuite ├── README.md ├── src │ └── fbtest.c └── tests │ ├── abbrev.bas │ ├── abbrev.chk │ ├── addr2str.bas │ ├── addr2str.chk │ ├── ahlbench.bas │ ├── ahlbench.chk │ ├── arrays.bas │ ├── arrays.chk │ ├── big-num.bas │ ├── big-num.chk │ ├── bug2.bas │ ├── bug2.chk │ ├── color.bas │ ├── color.chk │ ├── cstring.bas │ ├── cstring.chk │ ├── data-file.bas │ ├── data-file.chk │ ├── data-in-proc.bas │ ├── data-in-proc.chk │ ├── data-rom.bas │ ├── data-rom.chk │ ├── diskio.bas │ ├── diskio.chk │ ├── done.bas │ ├── done.chk │ ├── draw.bas │ ├── draw.chk │ ├── err-bad-pos.bas │ ├── err-bad-pos.chk │ ├── err-else.bas │ ├── err-else.chk │ ├── err-endif.bas │ ├── err-endif.chk │ ├── err-loop-1.bas │ ├── err-loop-1.chk │ ├── err-loop-2.bas │ ├── err-loop-2.chk │ ├── err-loop-3.bas │ ├── err-loop-3.chk │ ├── err-loop-4.bas │ ├── err-loop-4.chk │ ├── err-loop-5.bas │ ├── err-loop-5.chk │ ├── err-loop-6.bas │ ├── err-loop-6.chk │ ├── err-loop.bas │ ├── err-loop.chk │ ├── err-memory.bas │ ├── err-memory.chk │ ├── err-next.bas │ ├── err-next.chk │ ├── err-parse-bug.bas │ ├── err-parse-bug.chk │ ├── err-parse-overflow.bas │ ├── err-parse-overflow.chk │ ├── err-string1.bas │ ├── err-string1.chk │ ├── err-string2.bas │ ├── err-string2.chk │ ├── err-vdata.bas │ ├── err-vdata.chk │ ├── err-wend.bas │ ├── err-wend.chk │ ├── errlong.bas │ ├── errlong.chk │ ├── execdata.bas │ ├── execdata.chk │ ├── floatadr.bas │ ├── floatadr.chk │ ├── fp-array.bas │ ├── fp-array.chk │ ├── fp-fun.bas │ ├── fp-fun.chk │ ├── fp-input.bas │ ├── fp-input.chk │ ├── fpcomp.bas │ ├── fpcomp.chk │ ├── fpint.bas │ ├── fpint.chk │ ├── func-chr.bas │ ├── func-chr.chk │ ├── index.bas │ ├── index.chk │ ├── indexopt.bas │ ├── indexopt.chk │ ├── longstr.bas │ ├── longstr.chk │ ├── looperr.bas │ ├── looperr.chk │ ├── manyvars.bas │ ├── manyvars.chk │ ├── memerror.bas │ ├── memerror.chk │ ├── misc-fp.bas │ ├── misc-fp.chk │ ├── misc-int.bas │ ├── misc-int.chk │ ├── mset.bas │ ├── mset.chk │ ├── operator.bas │ ├── operator.chk │ ├── opt-poke.bas │ ├── opt-poke.chk │ ├── parsehex.bas │ ├── parsehex.chk │ ├── parsehex2.bas │ ├── parsehex2.chk │ ├── print-color.bas │ ├── print-color.chk │ ├── proc-line.bas │ ├── proc-line.chk │ ├── procerr.bas │ ├── procerr.chk │ ├── procerr2.bas │ ├── procerr2.chk │ ├── procerr3.bas │ ├── procerr3.chk │ ├── stmt-clr.bas │ ├── stmt-clr.chk │ ├── stmt-cls.bas │ ├── stmt-cls.chk │ ├── stmt-data.bas │ ├── stmt-data.chk │ ├── stmt-deg.bas │ ├── stmt-deg.chk │ ├── stmt-dli.bas │ ├── stmt-dli.chk │ ├── stmt-getk.bas │ ├── stmt-getk.chk │ ├── stmt-incdec.bas │ ├── stmt-incdec.chk │ ├── stmt-input.bas │ ├── stmt-input.chk │ ├── stmt-locate.bas │ ├── stmt-locate.chk │ ├── stmt-move.bas │ ├── stmt-move.chk │ ├── stmt-poke.bas │ ├── stmt-poke.chk │ ├── stmt-print.bas │ ├── stmt-print.chk │ ├── stmt-setcolor.bas │ ├── stmt-setcolor.chk │ ├── stmt-sio.bas │ ├── stmt-sio.chk │ ├── stmt-sound.bas │ ├── stmt-sound.chk │ ├── strarr1.bas │ ├── strarr1.chk │ ├── strerror.bas │ ├── strerror.chk │ ├── testcmp.bas │ ├── testcmp.chk │ ├── testif.bas │ ├── testif.chk │ ├── testloop.bas │ ├── testloop.chk │ ├── testproc.bas │ ├── testproc.chk │ ├── testusr.bas │ ├── testusr.chk │ ├── val.bas │ ├── val.chk │ ├── void.bas │ └── void.chk └── version.mk /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | testsuite/tests/* -text 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | temp/ 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "testsuite/mini65"] 2 | path = testsuite/mini65 3 | url = https://github.com/dmsc/mini65-sim 4 | [submodule "mkatr"] 5 | path = mkatr 6 | url = https://github.com/dmsc/mkatr 7 | -------------------------------------------------------------------------------- /cc65/LICENSE: -------------------------------------------------------------------------------- 1 | This software is provided 'as-is', without any express or implied warranty. 2 | In no event will the authors be held liable for any damages arising from 3 | the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any purpose, 6 | including commercial applications, and to alter it and redistribute it 7 | freely, subject to the following restrictions: 8 | 9 | 1. The origin of this software must not be misrepresented; you must not 10 | claim that you wrote the original software. If you use this software in 11 | a product, an acknowledgment in the product documentation would be 12 | appreciated but is not required. 13 | 14 | 2. Altered source versions must be plainly marked as such, and must not 15 | be misrepresented as being the original software. 16 | 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /cc65/README.md: -------------------------------------------------------------------------------- 1 | CC65 Tools 2 | ---------- 3 | 4 | This is an extract of the CC65 Assembler and Linkers, without the compiler and 5 | libraries. 6 | 7 | If you need the full CC65 suite, it is available from 8 | [the main CC65 site](https://cc65.github.io/), and to get the last source code 9 | you can go to [the Github repository](https://github.com/cc65/cc65) 10 | 11 | Original Readme 12 | --------------- 13 | 14 | cc65 is a complete cross development package for 65(C)02 systems, including 15 | a powerful macro assembler, a C compiler, linker, librarian and several 16 | other tools. 17 | 18 | cc65 has C and runtime library support for many of the old 6502 machines, 19 | including 20 | 21 | - the following Commodore machines: 22 | - VIC20 23 | - C16/C116 and Plus/4 24 | - C64 25 | - C128 26 | - CBM 510 (aka P500) 27 | - the 600/700 family 28 | - newer PET machines (not 2001). 29 | - the Apple ]\[+ and successors. 30 | - the Atari 8-bit machines. 31 | - the Atari 2600 console. 32 | - the Atari 5200 console. 33 | - GEOS for the C64, C128 and Apple //e. 34 | - the Bit Corporation Gamate console. 35 | - the NEC PC-Engine (aka TurboGrafx-16) console. 36 | - the Nintendo Entertainment System (NES) console. 37 | - the Watara Supervision console. 38 | - the VTech Creativision console. 39 | - the Oric Atmos. 40 | - the Oric Telestrat. 41 | - the Lynx console. 42 | - the Ohio Scientific Challenger 1P. 43 | 44 | The libraries are fairly portable, so creating a version for other 6502s 45 | shouldn't be too much work. 46 | -------------------------------------------------------------------------------- /cc65/ar65/error.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ar65/error.c -------------------------------------------------------------------------------- /cc65/ar65/error.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ar65/error.h -------------------------------------------------------------------------------- /cc65/asminc/atari_pokey.inc: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------- 2 | ; POKEY Address Equates 3 | ;------------------------------------------------------------------------- 4 | 5 | ; Read Addresses 6 | 7 | POT0 = POKEY + $00 ;potentiometer 0 8 | POT1 = POKEY + $01 ;potentiometer 1 9 | POT2 = POKEY + $02 ;potentiometer 2 10 | POT3 = POKEY + $03 ;potentiometer 3 11 | POT4 = POKEY + $04 ;potentiometer 4 12 | POT5 = POKEY + $05 ;potentiometer 5 13 | POT6 = POKEY + $06 ;potentiometer 6 14 | POT7 = POKEY + $07 ;potentiometer 7 15 | 16 | ALLPOT = POKEY + $08 ;potentiometer port status 17 | KBCODE = POKEY + $09 ;keyboard code 18 | RANDOM = POKEY + $0A ;random number generator 19 | SERIN = POKEY + $0D ;serial port input 20 | IRQST = POKEY + $0E ;IRQ interrupt status 21 | SKSTAT = POKEY + $0F ;serial port and keyboard status 22 | 23 | ; Write Addresses 24 | 25 | AUDF1 = POKEY + $00 ;channel 1 audio frequency 26 | AUDC1 = POKEY + $01 ;channel 1 audio control 27 | 28 | AUDF2 = POKEY + $02 ;channel 2 audio frequency 29 | AUDC2 = POKEY + $03 ;channel 2 audio control 30 | 31 | AUDF3 = POKEY + $04 ;channel 3 audio frequency 32 | AUDC3 = POKEY + $05 ;channel 3 audio control 33 | 34 | AUDF4 = POKEY + $06 ;channel 4 audio frequency 35 | AUDC4 = POKEY + $07 ;channel 4 audio control 36 | 37 | AUDCTL = POKEY + $08 ;audio control 38 | STIMER = POKEY + $09 ;start timers 39 | SKRES = POKEY + $0A ;reset SKSTAT status 40 | POTGO = POKEY + $0B ;start potentiometer scan sequence 41 | SEROUT = POKEY + $0D ;serial port output 42 | IRQEN = POKEY + $0E ;IRQ interrupt enable 43 | SKCTL = POKEY + $0F ;serial port and keyboard control 44 | -------------------------------------------------------------------------------- /cc65/asminc/target.inc: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | 19 | ; Assembly include file depending on the target 20 | ; --------------------------------------------- 21 | 22 | .ifdef __ATARI5200__ 23 | .include "atari5200.inc" 24 | .global MEMTOP, GPRIOR 25 | .globalzp COLCRS, ROWCRS 26 | .else 27 | .include "atari.inc" 28 | RTCLOK1 = $13 29 | RTCLOK2 = $14 30 | .endif 31 | 32 | ; vi:syntax=asm_ca65 33 | -------------------------------------------------------------------------------- /cc65/ca65/ea.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ca65/ea.h -------------------------------------------------------------------------------- /cc65/ca65/ea65.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ca65/ea65.h -------------------------------------------------------------------------------- /cc65/ca65/easw16.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ca65/easw16.h -------------------------------------------------------------------------------- /cc65/ca65/enum.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ca65/enum.h -------------------------------------------------------------------------------- /cc65/ca65/struct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ca65/struct.h -------------------------------------------------------------------------------- /cc65/common/fragdefs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/fragdefs.h -------------------------------------------------------------------------------- /cc65/common/inline.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/inline.h -------------------------------------------------------------------------------- /cc65/common/optdefs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/optdefs.h -------------------------------------------------------------------------------- /cc65/common/segnames.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/segnames.c -------------------------------------------------------------------------------- /cc65/common/segnames.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/segnames.h -------------------------------------------------------------------------------- /cc65/common/va_copy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/va_copy.h -------------------------------------------------------------------------------- /cc65/common/xmalloc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/xmalloc.c -------------------------------------------------------------------------------- /cc65/common/xmalloc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/common/xmalloc.h -------------------------------------------------------------------------------- /cc65/ld65/dbgfile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ld65/dbgfile.h -------------------------------------------------------------------------------- /cc65/ld65/error.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ld65/error.h -------------------------------------------------------------------------------- /cc65/ld65/o65.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/cc65/ld65/o65.h -------------------------------------------------------------------------------- /compiler/LICENSE: -------------------------------------------------------------------------------- 1 | FastBasic - Fast basic interpreter for the Atari 8-bit computers 2 | Copyright (C) 2017-2025 Daniel Serpell 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along 15 | with this program. If not, see 16 | 17 | In addition to the permissions in the GNU General Public License, the 18 | authors give you unlimited permission to link the compiled version of 19 | this file into combinations with other programs, and to distribute those 20 | combinations without any restriction coming from the use of this file. 21 | (The General Public License restrictions do apply in other respects; for 22 | example, they cover modification of the file, and distribution when not 23 | linked into a combine executable.) 24 | 25 | -------------------------------------------------------------------------------- /compiler/a5200.tgt: -------------------------------------------------------------------------------- 1 | # Atari 5200 console 2 | syntax a5200.syn basic.syn dli.syn pm.syn gr-a5200.syn sound.syn extended.syn 3 | config fastbasic-a5200.cfg 4 | ca65 -tatari5200 5 | library fastbasic-5200.lib 6 | extension .bin 7 | 8 | -------------------------------------------------------------------------------- /compiler/a800.tgt: -------------------------------------------------------------------------------- 1 | # Atari 8-bit computers, base file 2 | syntax a800.syn basic.syn dli.syn fileio.syn pm.syn graphics.syn sound.syn extended.syn sio.syn 3 | config fastbasic.cfg 4 | ca65 -tatari 5 | library fastbasic-int.lib 6 | extension .xex 7 | -------------------------------------------------------------------------------- /compiler/atari-5200.tgt: -------------------------------------------------------------------------------- 1 | # Atari 5200 console 2 | include a5200 3 | 4 | -------------------------------------------------------------------------------- /compiler/atari-cart-fp.tgt: -------------------------------------------------------------------------------- 1 | # Atari 8-bit computers, with floating point for cartridge output 2 | include atari-fp 3 | config fastbasic-cart.cfg 4 | library fastbasic-cart-fp.lib 5 | extension .rom 6 | -------------------------------------------------------------------------------- /compiler/atari-cart-int.tgt: -------------------------------------------------------------------------------- 1 | # Atari 8-bit computers, integer-only for cartridge output 2 | include atari-int 3 | config fastbasic-cart.cfg 4 | library fastbasic-cart-int.lib 5 | extension .rom 6 | -------------------------------------------------------------------------------- /compiler/atari-cart.tgt: -------------------------------------------------------------------------------- 1 | # Alias for atari-cart-fp 2 | include atari-cart-fp 3 | -------------------------------------------------------------------------------- /compiler/atari-fp.tgt: -------------------------------------------------------------------------------- 1 | # Atari 8-bit computer, with floating point 2 | include a800 3 | syntax float.syn fujinet.syn 4 | library fastbasic-fp.lib 5 | extension .xex 6 | -------------------------------------------------------------------------------- /compiler/atari-int.tgt: -------------------------------------------------------------------------------- 1 | # Atari 8-bit computers, integer only 2 | include a800 3 | -------------------------------------------------------------------------------- /compiler/default.tgt: -------------------------------------------------------------------------------- 1 | # Default target: atari-fp 2 | include atari-fp 3 | -------------------------------------------------------------------------------- /compiler/utf8.manifest: -------------------------------------------------------------------------------- 1 | UTF-8 2 | -------------------------------------------------------------------------------- /disk/dos/bwdos-license.txt: -------------------------------------------------------------------------------- 1 | BW-DOS sources from: 2 | https://github.com/dmsc/bwdos-mads 3 | 4 | Original BW-DOS 1.3 by BEWESOFT 5 | Modifications by Holger Janz and Daniel Serpell. 6 | 7 | Sources released to public in Jun 2023. 8 | 9 | From: 10 | https://forums.atariage.com/topic/351486-bw-dos-v130/page/4/#comment-5319115 11 | 12 | I'm Jiří Bernášek, the only author of all Atari 8-bit software signed BEWESOFT, 13 | including BW-DOS up to version 1.30, and I release it all to the Public Domain, 14 | including sources where available. 15 | 16 | -------------------------------------------------------------------------------- /disk/dos/copy.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/disk/dos/copy.com -------------------------------------------------------------------------------- /disk/dos/efast.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/disk/dos/efast.com -------------------------------------------------------------------------------- /disk/dos/efast.txt: -------------------------------------------------------------------------------- 1 | Fast E: accelerator 2 | ------------------- 3 | 4 | Written by DMSC, loosely based on HYP.COM by Doug Wokoun and John Harris. 5 | 6 | Last version available over https://github.com/dmsc/e-accelerator 7 | -------------------------------------------------------------------------------- /disk/dos/pause.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/disk/dos/pause.com -------------------------------------------------------------------------------- /disk/dos/xbw14d.dos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/disk/dos/xbw14d.dos -------------------------------------------------------------------------------- /help.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/help.txt -------------------------------------------------------------------------------- /readme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/readme -------------------------------------------------------------------------------- /samples/fp/ahlbench.bas: -------------------------------------------------------------------------------- 1 | 2 | start_time = TIME 3 | ' AHL'S SIMPLE BENCHMARK 4 | FOR N=1 TO 100 5 | A%=N 6 | FOR I=1 TO 10 7 | A%=SQR(A%):R%=R%+RND() 8 | NEXT I 9 | FOR I=1 TO 10 10 | A%=A%^2:R%=R%+RND() 11 | NEXT I 12 | S%=S%+A% 13 | NEXT N 14 | 15 | PRINT "ACCURACY ";ABS(1010-S%/5) 16 | PRINT "RANDOM ";ABS(1000-R%) 17 | end_time = TIME 18 | SC = end_time - start_time 19 | ? SC/60;" SECONDS" 20 | 21 | -------------------------------------------------------------------------------- /samples/fp/draw.bas: -------------------------------------------------------------------------------- 1 | ' Graphics sample 2 | gr. 8+16 3 | color 1 4 | 5 | ' Sample line drawing 6 | for i=0 to 100 step 3 7 | plot 100-i,0 8 | dr. 0,i 9 | next i 10 | 11 | ' Plotting a function (in FP) 12 | for i=120 to 300 13 | y% = i * 0.05 - 11 14 | y% = y% * y% * (y% + 5) 15 | plot i, 160 - int(y%) 16 | next i 17 | -------------------------------------------------------------------------------- /samples/fp/fedora.bas: -------------------------------------------------------------------------------- 1 | 2 | ' Record start time 3 | ETIME%=0 4 | @GetTime 5 | STIME%=ETIME% 6 | 7 | DIM RR(320) 8 | FOR I=0 TO 320:RR(I)=193:NEXT I 9 | 10 | GRAPHICS 8+16 11 | SETCOLOR 2,0,0 12 | COLOR 1 13 | 14 | XP=144:XR%=4.71238905:XF%=XR%/XP 15 | 16 | FOR ZI=64 TO -64 STEP -1 17 | ZT%=ZI*2.25:ZS%=ZT%*ZT% 18 | XL=INT(SQR(20736-ZS%)) 19 | FOR XI=0 TO XL 20 | SXT% = SIN(SQR(XI*XI+ZS%)*XF%) 21 | YY = INT(SXT%*(123.2-89.6*SXT%*SXT%)) 22 | X1=XI+ZI+160:Y1=90-YY+ZI 23 | IF RR(X1)>Y1 24 | RR(X1)=Y1 25 | PLOT X1,Y1 26 | ENDIF 27 | X1=-XI+ZI+160 28 | IF RR(X1)>Y1 29 | RR(X1)=Y1 30 | PLOT X1,Y1 31 | ENDIF 32 | NEXT XI 33 | NEXT ZI 34 | 35 | ' Read End time 36 | @GetTime 37 | ETIME%=ETIME%-STIME% 38 | 39 | ' Enable text window 40 | GRAPHICS 8+32 : SE.2,0,0 41 | 42 | ' Convert to seconds (NTSC, use 49.86074 for PAL) 43 | ESEC = INT(ETIME%/59.92271 + 0.5) 44 | EHOUR = ESEC / 3600 45 | EMIN = (ESEC MOD 3600) / 60 46 | ESEC = ESEC MOD 60 47 | 48 | ? "ELLAPSED:";EHOUR;":";EMIN;":";ESEC 49 | GET KEY 50 | 51 | PROC GetTime 52 | REPEAT 53 | QT = PEEK(18) 54 | ETIME% = TIME 55 | UNTIL QT = PEEK(18) 56 | IF ETIME%<0 57 | QT = QT + 1 58 | ENDIF 59 | ETIME% = 65536.0 * QT + ETIME% 60 | ENDPROC 61 | -------------------------------------------------------------------------------- /samples/fp/mastodon.bas: -------------------------------------------------------------------------------- 1 | ' A Mastodon Client in FastBASIC 2 | 3 | ' N: Unit to use 4 | unit=8 5 | 6 | ' URL to Mastodon Server 7 | url$="N:HTTPS://oldbytes.space/api/v1/timelines/public?limit=1"$9B 8 | 9 | ' QUERY string 10 | query$="" 11 | 12 | ' QUERY result 13 | DIM result(1024) BYTE 14 | 15 | ' JSON channel mode 16 | JSON_MODE=1 17 | 18 | ' PROCEDURES ''''''''''''''''''''''''' 19 | PROC nprinterror 20 | NSTATUS unit 21 | PRINT "ERROR- "; PEEK($02ED) 22 | ENDPROC 23 | 24 | PROC nsetchannelmode mode 25 | SIO $71, unit, $FC, $00, 0, $1F, 0, 12, JSON_MODE 26 | ENDPROC 27 | 28 | PROC nparsejson 29 | SIO $71, unit, $50, $00, 0, $1f, 0, 12, 0 30 | ENDPROC 31 | 32 | PROC njsonquery 33 | SIO $71, unit, $51, $80, &query$+1, $1f, 256, 12, 0 34 | ENDPROC 35 | 36 | PROC showresult 37 | @njsonquery 38 | NSTATUS unit 39 | 40 | IF PEEK($02ED) > 128 41 | PRINT "Could not fetch query:" 42 | PRINT query$ 43 | EXIT 44 | ENDIF 45 | 46 | BW=DPEEK($02EA) 47 | NGET unit, &result, BW 48 | BPUT #0, &result, BW 49 | ENDPROC 50 | 51 | PROC mastodon 52 | ' Open connection 53 | NOPEN unit, 12, 0, url$ 54 | 55 | ' If not successful, then exit. 56 | IF SERR()<>1 57 | PRINT "Could not open connection." 58 | @nprinterror 59 | EXIT 60 | ENDIF 61 | 62 | ' Change channel mode to JSON 63 | @nsetchannelmode JSON_MODE 64 | 65 | ' Ask FujiNet to parse JSON 66 | @nparsejson 67 | 68 | ' If not successful, then exit. 69 | IF SErr()<>1 70 | PRINT "Could not parse JSON." 71 | @nprinterror 72 | EXIT 73 | ENDIF 74 | 75 | ' Show latest post 76 | query$="N:/0/account/display_name"$9B 77 | @showresult 78 | query$="N:/0/created_at"$9B 79 | @showresult 80 | query$="N:/0/content"$9B 81 | @showresult 82 | 83 | NCLOSE unit 84 | 85 | PRINT 86 | PRINT " ---- " 87 | PRINT 88 | 89 | ENDPROC 90 | 91 | ' MAIN PROGRAM ''''''''''''''''''''''' 92 | DO 93 | @mastodon 94 | PAUSE 1800 95 | LOOP 96 | -------------------------------------------------------------------------------- /samples/fp/nc.bas: -------------------------------------------------------------------------------- 1 | ' -- #FUJINET NETCAT Example -- 2 | 3 | ' Default unit # for connection 4 | CONN=2 5 | MODE=12 6 | TRANS=0 7 | 8 | ' RX Buffer 9 | DIM BUF(8192) BYTE 10 | 11 | ' Procedures ''''''''''''''''''''''''' 12 | PROC BANNER 13 | PRINT "** NETCAT IN FASTBASIC **" 14 | PRINT 15 | ENDPROC 16 | 17 | PROC GETCONN 18 | URL$="N:" 19 | INPUT "URL: ", C$ 20 | URL$=+C$ 21 | INPUT "TRANS (0=none, 1=CR, 2=LF, 3=CR/LF): ", TRANS 22 | ENDPROC 23 | 24 | PROC INTCLR 25 | POKE $D302, PEEK($D302) & 127 26 | ENDPROC 27 | 28 | PROC CONNECT 29 | PRINT "Connecting to:" 30 | PRINT URL$ 31 | NOPEN CONN,MODE,TRANS,URL$ 32 | NSTATUS CONN 33 | ENDPROC 34 | 35 | PROC IN 36 | ' Clear interrupt and get status 37 | @INTCLR 38 | NSTATUS CONN 39 | 40 | ' Check if we need to read data 41 | BW = DPEEK($02EA) 42 | WHILE BW 43 | ' Needs to handle the case where 44 | ' BW > 32767, giving negative. 45 | IF BW > 8192 OR BW < 000 46 | LN = 8192 47 | ELSE 48 | LN = BW 49 | ENDIF 50 | 51 | NGET CONN,&BUF, LN 52 | BPUT #0, &BUF, LN 53 | BW = BW - LN 54 | WEND 55 | ENDPROC 56 | 57 | PROC OUT 58 | GET K 59 | NPUT CONN, &K, 1 60 | ENDPROC 61 | 62 | PROC NC 63 | DO 64 | IF PEEK($D302) & 128 65 | @IN 66 | ENDIF 67 | 68 | IF PEEK($02EC) = 0 69 | PRINT "Disconnected." 70 | NCLOSE CONN 71 | EXIT 72 | ENDIF 73 | 74 | IF KEY() THEN @OUT 75 | LOOP 76 | ENDPROC 77 | 78 | '''''''''''''''''''''''' 79 | ' Main Program 80 | 81 | POKE 65,0 ' quiet SIO 82 | 83 | @BANNER 84 | @GETCONN 85 | @CONNECT 86 | 87 | IF SErr() <> 1 88 | NSTATUS CONN 89 | PRINT "Could not Make Connection" 90 | PRINT "ERROR- "; PEEK($02ED) 91 | NCLOSE CONN 92 | ELSE 93 | PRINT "Connected!" 94 | @NC 95 | ENDIF 96 | 97 | POKE 65,3 ' noisy SIO 98 | -------------------------------------------------------------------------------- /samples/int/dli.bas: -------------------------------------------------------------------------------- 1 | ' Define the DLI: set background 2 | ' color to $24 = dark red. 3 | DLI SET d1 = $24 INTO $D01A 4 | ' Setups screen 5 | GRAPHICS 0 6 | ' Alter the Display List, adds 7 | ' a DLI at line 11 on the screen 8 | POKE DPEEK(560) + 16, 130 9 | ' Activate DLI 10 | DLI d1 11 | ' Wait for any keyu 12 | ? "Press a Key" : GET K 13 | ' Disable the DLI 14 | DLI 15 | 16 | ? "Again..." 17 | GET K 18 | 19 | ' An array with color values 20 | DATA Colors() BYTE = $24,$46,$68 21 | ' Define the DLI: set background color 22 | ' from the Color() array and text back 23 | ' with value $8A in the same line and 24 | ' black in the next line 25 | DLI SET d2 = Colors INTO $D01A, 26 | DLI = $8A INTO $D018, 27 | DLI = $00 WSYNC INTO $D018 28 | ' Setups screen 29 | GRAPHICS 0 30 | ' Adds DLI at three lines: 31 | POKE DPEEK(560) + 13, 130 32 | POKE DPEEK(560) + 16, 130 33 | POKE DPEEK(560) + 19, 130 34 | ' Activate DLI 35 | DLI d2 36 | ' Wait for any keyu 37 | ? "Press a Key" : GET K 38 | ' Disable the DLI 39 | DLI 40 | 41 | ? "Again..." 42 | GET K 43 | 44 | ' Player shapes, positions and colors 45 | DATA p1() BYTE = $E7,$81,$81,$E7 46 | DATA p2() BYTE = $18,$3C,$3C,$18 47 | DATA pos() BYTE = $40,$60,$80,$A0 48 | DATA c1() BYTE = $28,$88,$C8,$08 49 | DATA c2() BYTE = $2E,$80,$CE,$06 50 | ' Our DLI writes the position and 51 | ' colors to Player 1 and Player 2 52 | DLI SET d3 = pos INTO $D000 INTO $D001, 53 | DLI = c1 INTO $D012, c2 INTO $D013 54 | GRAPHICS 0 : PMGRAPHICS 2 55 | ' Setup our 4 DLI and Players 56 | FOR I = 8 TO 20 STEP 4 57 | POKE DPEEK(560) + I, 130 58 | MOVE ADR(p1), PMADR(0)+I*4+5,4 59 | MOVE ADR(p2), PMADR(1)+I*4+5,4 60 | NEXT 61 | ' Activate DLI 62 | DLI d3 63 | ? "Press a Key" 64 | REPEAT 65 | PAUSE 66 | pos(0) = pos(0) + 2 67 | pos(1) = pos(1) + 1 68 | pos(2) = pos(2) - 1 69 | pos(3) = pos(3) - 2 70 | UNTIL KEY() 71 | DLI 72 | 73 | ? "Key to end..." 74 | GET K 75 | 76 | -------------------------------------------------------------------------------- /samples/int/iospeed.bas: -------------------------------------------------------------------------------- 1 | ' Test speed of block I/O versus 2 | ' line oriented I/O. 3 | 4 | ' Get free memory 5 | DIM A(0) byte 6 | max = FRE() 7 | 8 | ? "---------------" 9 | ? "Memory:", max 10 | 11 | ' Test BGET speed: 12 | ? "--- Read with BGET --" 13 | ? "Err:", 14 | st = TIME 15 | OPEN #1, 4, 0, "D:CARRERA3.BAS" 16 | ? ERR(), 17 | BGET #1, ADR(A), max 18 | ? ERR(), 19 | total = DPEEK($358) 20 | CLOSE #1 21 | ? ERR() 22 | ? "Read:", total 23 | 24 | ' Count lines! 25 | ptr = ADR(A) 26 | pend = ptr + total 27 | lines = 0 28 | 29 | WHILE ptr < pend 30 | IF PEEK(ptr) = $9b 31 | INC lines 32 | ENDIF 33 | INC ptr 34 | WEND 35 | et = TIME 36 | ? "Lines:", lines 37 | ? "Time:", et-st 38 | 39 | ' Test INPUT speed: 40 | line$ = "" 41 | lines = 0 42 | ? "--- Read with INPUT --" 43 | ? "Err:", 44 | st = TIME 45 | OPEN #1, 4, 0, "D:CARRERA3.BAS" 46 | ? ERR(), 47 | WHILE ERR() < 128 48 | INPUT #1, line$ 49 | INC lines 50 | WEND 51 | ? ERR(), 52 | CLOSE #1 53 | ? ERR() 54 | et = TIME 55 | ? "Lines:", lines 56 | ? "Time:", et-st 57 | 58 | ' Test GET speed: 59 | ? "--- Read with GET --" 60 | ? "Err:", 61 | st = TIME 62 | OPEN #1, 4, 0, "D:CARRERA3.BAS" 63 | ? ERR(), 64 | 65 | ' Count lines while reading 66 | total = 0 67 | lines = 0 68 | WHILE ERR() < 128 69 | GET #1, x 70 | IF x = $9b 71 | INC lines 72 | ENDIF 73 | INC total 74 | WEND 75 | ? ERR(), 76 | CLOSE #1 77 | ? ERR() 78 | 79 | et = TIME 80 | ? "Read:", total 81 | ? "Lines:", lines 82 | ? "Time:", et-st 83 | 84 | -------------------------------------------------------------------------------- /samples/int/pmtest.bas: -------------------------------------------------------------------------------- 1 | ' P/M test program 2 | 3 | graphics 0 ' Setups graphics mode 4 | pmgraphics 2 ' And P/M mode 5 | P0Mem = pmadr(0) ' Get player 0 address 6 | oldPos = P0Mem ' and into "old position" 7 | 8 | mset P0Mem, 128, 0 ' Clears P/M 0 Memory 9 | setcolor -4, 1, 15 10 | 11 | ' P/M data and blank (to clear P/M) 12 | DATA PMdata() byte = $38,$44,$54,$44,$38 13 | 14 | ' Initial Conditions 15 | xPos = 6400 : yPos = 2560 16 | xSpd = 64 : ySpd = 0 17 | 18 | repeat 19 | xPos = xPos + xSpd : yPos = yPos + ySpd 20 | ySpd = ySpd + 2 21 | if (ySpd > 0) and (yPos > 12800) 22 | ySpd = -ySpd 23 | xSpd = Rand(512) - 256 24 | endif 25 | if xSpd > 0 26 | if xPos > 25600 Then xSpd = -xSpd 27 | else 28 | if xPos < 6400 Then xSpd = -xSpd 29 | endif 30 | @MovePm ' Move P/M Graphics 31 | until Key() 32 | 33 | graphics 0 34 | 35 | END 36 | 37 | proc MovePm 38 | x = xPos / 128 : y = P0Mem + yPos / 128 39 | poke $D01A,$74 ' Change background color 40 | pause 41 | pmhpos 0, x ' Set new horizontal position 42 | mset oldPos, 5, 0 ' Clear old sprite 43 | move adr(PMdata), y, 5 ' Draw at new vertical pos. 44 | oldPos = y 45 | endproc 46 | -------------------------------------------------------------------------------- /samples/int/sieve.bas: -------------------------------------------------------------------------------- 1 | ? "Starting!" 2 | NumIter = 10 3 | sTime = TIME 4 | ' Arrays are initialized to 0 5 | DIM A(8190) Byte 6 | FOR Iter= 1 TO NumIter 7 | MSET Adr(A), 8190, 0 8 | Count = 0 9 | FOR I = 0 TO 8190 10 | IF NOT A(I) 11 | Prime = I + I + 3 12 | FOR K = I + Prime TO 8190 STEP Prime 13 | A(K) = 1 14 | NEXT K 15 | INC Count 16 | ENDIF 17 | NEXT I 18 | NEXT Iter 19 | 20 | eTime = TIME 21 | ? "End." 22 | ? "Elapsed time: "; eTime-sTime; " in "; NumIter; " iterations." 23 | ? "Found "; Count; " primes." 24 | -------------------------------------------------------------------------------- /src/compiler/codestat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // codestat.h: Generate code statistics 20 | 21 | #include "codew.h" 22 | #include 23 | 24 | void do_opstat(std::vector &code); 25 | -------------------------------------------------------------------------------- /src/compiler/compile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // compile.h: Main compiler class 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace syntax 26 | { 27 | class sm_list; 28 | } 29 | 30 | class compiler 31 | { 32 | public: 33 | std::string segname; 34 | bool do_debug; 35 | bool optimize; 36 | bool show_stats; 37 | bool show_text; 38 | unsigned short_text; 39 | 40 | compiler(); 41 | int compile_file(std::string input_filename, std::string output_filename, 42 | const syntax::sm_list &sl, std::string listing_filename); 43 | }; 44 | -------------------------------------------------------------------------------- /src/compiler/ifile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // ifile.h: Opens included file 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | // Opens "fname" searching first in the same path as the current file 27 | std::unique_ptr open_include_file(std::string current_file, 28 | std::string fname); 29 | -------------------------------------------------------------------------------- /src/compiler/looptype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // looptype.h: Defines types of loops and variables 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | enum LoopType 26 | { 27 | // First entries can't use "EXIT" 28 | LT_PROC_DATA = 0, 29 | LT_EXIT, 30 | // From here, loops don't push jump destinations 31 | LT_LAST_JUMP = 32, 32 | LT_PROC_2, 33 | LT_DO_LOOP, 34 | LT_REPEAT, 35 | LT_WHILE_1, 36 | LT_FOR_1, 37 | // And from here, loops push destinations and are ignored by EXIT 38 | LT_WHILE_2 = 128, 39 | LT_FOR_2, 40 | LT_IF, 41 | LT_ELSE, 42 | LT_ELIF 43 | }; 44 | 45 | std::string get_loop_name(enum LoopType l); 46 | LoopType get_looptype(std::string t); 47 | 48 | bool loop_add_indent(enum LoopType l); 49 | -------------------------------------------------------------------------------- /src/compiler/parser-actions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // parser-actions.h: parser functions called from the parsing tables 20 | #pragma once 21 | #include 22 | 23 | class parse; 24 | bool call_parsing_action(const std::string name, parse &s); 25 | -------------------------------------------------------------------------------- /src/compiler/peephole.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // peephole.h: Peephole optimizer 20 | 21 | #pragma once 22 | 23 | #include "codew.h" 24 | #include 25 | 26 | void do_peephole(std::vector &code); 27 | -------------------------------------------------------------------------------- /src/compiler/synt-emit-asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-emit-asm.h: emit parser as an ASM file 20 | #pragma once 21 | #include "synt-sm-list.h" 22 | 23 | namespace syntax 24 | { 25 | const int max_emit_bytes = 28; 26 | bool syntax_emit_asm(std::ostream &hdr, std::ostream &out, sm_list &sml); 27 | } // namespace syntax 28 | -------------------------------------------------------------------------------- /src/compiler/synt-optimize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-optimize.h: Optimizer for the parsing tables 20 | #pragma once 21 | #include "synt-sm-list.h" 22 | 23 | namespace syntax 24 | { 25 | bool syntax_optimize(sm_list &sml, bool verbose, bool merge); 26 | } // namespace syntax 27 | -------------------------------------------------------------------------------- /src/compiler/synt-parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-parser.h: Parse a syntax file 20 | #pragma once 21 | #include "synt-sm-list.h" 22 | 23 | namespace syntax 24 | { 25 | class parse_state; 26 | 27 | class syntax_parser 28 | { 29 | private: 30 | parse_state &p; 31 | sm_list &sl; 32 | bool parse_sm_name(const std::string &name); 33 | 34 | public: 35 | // Constructor, from a parser state 36 | syntax_parser(parse_state &p, sm_list &sl); 37 | // Parse one file 38 | bool parse_file(); 39 | // Show final summary of parser files 40 | void show_summary() const; 41 | }; 42 | } // namespace syntax 43 | -------------------------------------------------------------------------------- /src/compiler/synt-preproc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-preproc.h: Pre-processor for the syntax files 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace syntax 27 | { 28 | class preproc 29 | { 30 | private: 31 | std::set defs; 32 | 33 | public: 34 | // Reads from an input stream, pro-process and stores 35 | // the result in a string. 36 | std::string read_input(std::istream &in) const; 37 | // Adds a new definition 38 | void add_def(std::string def); 39 | }; 40 | }; // namespace syntax 41 | -------------------------------------------------------------------------------- /src/compiler/synt-sm-list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-sm-list.h: List of parsing tables, tokens and externals 20 | #pragma once 21 | #include "synt-sm.h" 22 | #include "synt-symlist.h" 23 | #include "synt-wlist.h" 24 | #include 25 | #include 26 | 27 | namespace syntax 28 | { 29 | class wordlist; 30 | // List of syntax tables 31 | class sm_list 32 | { 33 | public: 34 | std::map> sms; 35 | wordlist tok; 36 | wordlist ext; 37 | symlist syms; 38 | sm_list() : tok(0), ext(128) {} 39 | }; 40 | } // namespace syntax 41 | -------------------------------------------------------------------------------- /src/compiler/synt-symlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-symlist.h: Parse a list of symbols 20 | #pragma once 21 | #include 22 | #include 23 | 24 | namespace syntax 25 | { 26 | class parse_state; 27 | 28 | class symlist 29 | { 30 | private: 31 | std::map list; 32 | 33 | public: 34 | static const int sym_import = 1 << 24; 35 | static const int sym_importzp = 2 << 24; 36 | // Constructor, with a parsing state, the wordlist name and the starting ID 37 | symlist() {} 38 | // Access map from names to values. 39 | const std::map &map() const { return list; } 40 | // Parse from parse_state 41 | bool parse(parse_state &p); 42 | }; 43 | } // namespace syntax 44 | -------------------------------------------------------------------------------- /src/compiler/synt-wlist.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-wlist.cc: Parse the syntax word lists 20 | #include "synt-wlist.h" 21 | #include "synt-pstate.h" 22 | 23 | using namespace syntax; 24 | 25 | bool wordlist::parse(parse_state &p) 26 | { 27 | p.skip_comments(); 28 | sentry s(p); 29 | 30 | while(p.end_line()) 31 | ; 32 | if(!p.ch('{')) 33 | return false; 34 | // Read all tokens 35 | while(1) 36 | { 37 | p.skip_comments(); 38 | p.space(); 39 | 40 | if(p.ch('}')) 41 | break; 42 | 43 | auto tok = p.read_ident(); 44 | if(tok.empty()) 45 | { 46 | p.error("missing identifier"); 47 | return false; 48 | } 49 | else 50 | { 51 | if(list.end() != list.find(tok)) 52 | p.error("word already exists '" + tok + "'"); 53 | else 54 | list[tok] = n++; 55 | } 56 | 57 | if(!p.end_line() && !(p.skip_comments() && p.ch(','))) 58 | { 59 | p.error("expected a ',' or newline"); 60 | return false; 61 | } 62 | } 63 | return true; 64 | } 65 | -------------------------------------------------------------------------------- /src/compiler/synt-wlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // synt-wlist.h: Parse the syntax word lists 20 | #pragma once 21 | #include 22 | #include 23 | 24 | namespace syntax 25 | { 26 | class parse_state; 27 | 28 | class wordlist 29 | { 30 | private: 31 | int n; 32 | std::map list; 33 | 34 | public: 35 | // Constructor, with a parsing state, the wordlist name and the starting ID 36 | wordlist(int start) : n(start) {} 37 | // Returns next ID 38 | int next() const { return n; } 39 | // Access map from names to ID. 40 | const std::map &map() const { return list; } 41 | // Parse from parse_state 42 | bool parse(parse_state &p); 43 | }; 44 | } // namespace syntax 45 | -------------------------------------------------------------------------------- /src/compiler/target.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | * Copyright (C) 2017-2025 Daniel Serpell 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see 17 | */ 18 | 19 | // target.h: read target definitions 20 | #pragma once 21 | #include "synt-sm-list.h" 22 | #include 23 | #include 24 | #include 25 | 26 | namespace syntax 27 | { 28 | class sm_list; 29 | } 30 | 31 | class target 32 | { 33 | private: 34 | syntax::sm_list s; 35 | std::string lib_name; 36 | std::string cfg_name; 37 | std::string bin_extension; 38 | std::vector ca65_args_; 39 | 40 | public: 41 | target(); 42 | void load(std::vector target_folder, 43 | std::vector syntax_folder, std::string fname); 44 | const syntax::sm_list &sl() const { return s; } 45 | std::string lib() const { return lib_name; } 46 | std::string cfg() const { return cfg_name; } 47 | std::string bin_ext() const { return bin_extension; } 48 | const std::vector &ca65_args() const { return ca65_args_; } 49 | }; 50 | -------------------------------------------------------------------------------- /src/countlines.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | 19 | ; Support code for the Editor 20 | ; --------------------------- 21 | 22 | .export COUNT_LINES 23 | .importzp tmp1, tmp2 24 | 25 | 26 | .proc COUNT_LINES 27 | bend = tmp1 28 | ptr = tmp2 29 | pla 30 | tax 31 | pla 32 | sta bend 33 | pla 34 | sta ptr+1 35 | pla 36 | tay 37 | lda #0 38 | sta ptr 39 | 40 | loop: lda (ptr), y 41 | cpy bend 42 | bne :+ 43 | cpx ptr+1 44 | beq end 45 | : iny 46 | bne :+ 47 | inc ptr+1 48 | : cmp #$9B 49 | bne loop 50 | end: tya 51 | ldx ptr+1 52 | rts 53 | .endproc 54 | 55 | 56 | ; vi:syntax=asm_ca65 57 | -------------------------------------------------------------------------------- /src/errors.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | 19 | ; Parser error messages 20 | ; --------------------- 21 | 22 | .export error_msg_list 23 | 24 | ; Keep in line with error definitions 25 | .code 26 | error_msg_list = * - 1 27 | .macro def_error name, msg 28 | ::name = <(* - error_msg_list) 29 | .exportzp name 30 | .repeat .strlen(msg)-1, I 31 | .byte .strat(msg, I) * 2 32 | .endrepeat 33 | .byte .strat(msg, .strlen(msg)-1) * 2 + 1 34 | .endmacro 35 | def_error ERR_LABEL, "undef label" 36 | def_error ERR_TOO_LONG, "too long" 37 | def_error ERR_LOOP, "bad loop" 38 | def_error ERR_PARSE, "parse error" 39 | def_error ERR_NO_ELOOP, "no end loop/proc/if" 40 | 41 | .if (* - error_msg_list) > 255 42 | .error "Error, too many error messages" 43 | .endif 44 | .code 45 | 46 | ; vi:syntax=asm_ca65 47 | -------------------------------------------------------------------------------- /src/interp/a5200/getkey.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; GET from keyboard 28 | ; ----------------- 29 | 30 | .importzp next_instruction 31 | .import CH 32 | .export get_key 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_GETKEY 37 | jsr get_key 38 | jmp next_instruction 39 | .endproc 40 | 41 | .proc get_key 42 | lda CH 43 | cmp #$FF 44 | beq get_key 45 | 46 | ldx #$FF 47 | stx CH 48 | inx 49 | rts 50 | .endproc 51 | 52 | .include "deftok.inc" 53 | deftoken "GETKEY" 54 | 55 | ; vi:syntax=asm_ca65 56 | 57 | -------------------------------------------------------------------------------- /src/interp/a800/iochn.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Set I/O channel to A 28 | ; -------------------- 29 | 30 | .export IOCHN_16 31 | .importzp IOCHN, next_instruction 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_IOCHN 36 | jsr IOCHN_16 37 | stx IOCHN 38 | jmp next_instruction 39 | .endproc 40 | 41 | .proc IOCHN_16 42 | asl 43 | asl 44 | asl 45 | asl 46 | tax 47 | rts 48 | .endproc 49 | 50 | .include "deftok.inc" 51 | deftoken "IOCHN" 52 | 53 | ; vi:syntax=asm_ca65 54 | -------------------------------------------------------------------------------- /src/interp/absneg.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; ABS / NEG routines 28 | ; ------------------ 29 | 30 | .import neg_AX 31 | .importzp next_instruction 32 | 33 | .segment "RUNTIME" 34 | 35 | EXE_ABS: ; AX = ABS(AX) 36 | cpx #0 37 | bpl xit 38 | EXE_NEG: ; AX = -AX 39 | jsr neg_AX 40 | xit: jmp next_instruction 41 | 42 | .include "deftok.inc" 43 | deftoken "ABS" 44 | deftoken "NEG" 45 | 46 | ; vi:syntax=asm_ca65 47 | -------------------------------------------------------------------------------- /src/interp/addsub.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Add / Sub routines 28 | ; ------------------ 29 | 30 | .import neg_AX, stack_l, stack_h 31 | .importzp next_ins_incsp 32 | 33 | .segment "RUNTIME" 34 | 35 | EXE_SUB: 36 | jsr neg_AX 37 | ; Fall through 38 | .proc EXE_ADD ; AX = (SP+) + AX 39 | clc 40 | adc stack_l, y 41 | pha 42 | txa 43 | adc stack_h, y 44 | tax 45 | pla 46 | jmp next_ins_incsp 47 | .endproc 48 | 49 | .include "deftok.inc" 50 | deftoken "ADD" 51 | deftoken "SUB" 52 | 53 | ; vi:syntax=asm_ca65 54 | -------------------------------------------------------------------------------- /src/interp/atari/color.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; COLOR zeropage variable 28 | ; ----------------------- 29 | 30 | .exportzp COLOR 31 | 32 | .zeropage 33 | 34 | COLOR: .res 1 35 | 36 | ; vi:syntax=asm_ca65 37 | -------------------------------------------------------------------------------- /src/interp/atari/pause.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Pause for a number of jiffies 28 | ; ----------------------------- 29 | 30 | .importzp next_instruction 31 | 32 | .include "target.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_PAUSE 37 | tay 38 | iny 39 | inx 40 | wait: lda RTCLOK2 41 | : cmp RTCLOK2 42 | beq :- 43 | dey 44 | bne wait 45 | dex 46 | bne wait 47 | jmp next_instruction 48 | .endproc 49 | 50 | .include "deftok.inc" 51 | deftoken "PAUSE" 52 | 53 | ; vi:syntax=asm_ca65 54 | -------------------------------------------------------------------------------- /src/interp/atari/position.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; POSITION: setup ROW and COLUMN for PLOT/PRINT 28 | ; --------------------------------------------- 29 | 30 | .import stack_l, stack_h 31 | .importzp next_ins_incsp 32 | 33 | .include "target.inc" 34 | 35 | .segment "RUNTIME" 36 | 37 | .proc EXE_POSITION 38 | 39 | sta ROWCRS 40 | 41 | ldx stack_l, y 42 | stx COLCRS 43 | ldx stack_h, y 44 | stx COLCRS+1 45 | 46 | jmp next_ins_incsp 47 | .endproc 48 | 49 | .include "deftok.inc" 50 | deftoken "POSITION" 51 | 52 | ; vi:syntax=asm_ca65 53 | -------------------------------------------------------------------------------- /src/interp/atari/soundoff.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Silence all sound channels (SOUND without parameters) 28 | ; ----------------------------------------------------- 29 | 30 | .export SOUND_OFF 31 | .importzp next_instruction 32 | 33 | .include "target.inc" 34 | 35 | .segment "RUNTIME" 36 | 37 | .proc SOUND_OFF 38 | ldy #7 39 | lda #0 40 | : sta AUDF1, y 41 | dey 42 | bpl :- 43 | rts 44 | .endproc 45 | 46 | ; vi:syntax=asm_ca65 47 | -------------------------------------------------------------------------------- /src/interp/atari/time.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; TIME function, returns current time in jiffies 28 | ; ---------------------------------------------- 29 | 30 | .importzp next_instruction 31 | 32 | .include "target.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_TIME 37 | retry: ldx RTCLOK1 38 | lda RTCLOK2 39 | cpx RTCLOK1 40 | bne retry 41 | jmp next_instruction 42 | .endproc 43 | 44 | .include "deftok.inc" 45 | deftoken "TIME" 46 | 47 | ; vi:syntax=asm_ca65 48 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_abs.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Floating Point Absolute and Negative 28 | ; ------------------------------------ 29 | 30 | .importzp next_instruction 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_ABS 37 | asl FR0 38 | lsr FR0 39 | jmp next_instruction 40 | .endproc 41 | 42 | .proc EXE_FP_NEG 43 | lda FR0 44 | eor #$80 45 | sta FR0 46 | jmp next_instruction 47 | .endproc 48 | 49 | .include "deftok.inc" 50 | deftoken "FP_ABS" 51 | deftoken "FP_NEG" 52 | 53 | ; vi:syntax=asm_ca65 54 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_coef.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Floating Point coefficients 28 | ; --------------------------- 29 | 30 | .export fp_sin_coef, fp_pi1_2, fp_180pi, fp_90 31 | 32 | .segment "RUNTIME" 33 | 34 | ; Coefficients of SIN function, pi/2, 90 and 180/pi. 35 | fp_sin_coef: 36 | .byte $3E,$01,$51,$58,$00,$00 37 | .byte $BE,$46,$74,$16,$00,$00 38 | .byte $3F,$07,$96,$90,$12,$54 39 | .byte $BF,$64,$59,$63,$88,$21 40 | fp_pi1_2: 41 | .byte $40,$01,$57,$07,$96,$33 42 | fp_90: 43 | .byte $40,$90,$00,$00,$00,$00 44 | fp_180pi: 45 | .byte $40,$57,$29,$57,$79,$51 46 | 47 | ; vi:syntax=asm_ca65 48 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_div.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Floating Point Division 28 | ; ----------------------- 29 | 30 | .import check_fp_err, pop_fr1 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_DIV 37 | jsr pop_fr1 38 | jsr FDIV 39 | jmp check_fp_err 40 | .endproc 41 | 42 | .include "deftok.inc" 43 | deftoken "FP_DIV" 44 | 45 | ; vi:syntax=asm_ca65 46 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_exp.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Natural Exponent function 28 | ; ------------------------- 29 | 30 | .import check_fp_err 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_EXP 37 | jsr EXP 38 | jmp check_fp_err 39 | .endproc 40 | 41 | .include "deftok.inc" 42 | deftoken "FP_EXP" 43 | 44 | ; vi:syntax=asm_ca65 45 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_exp10.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Base 10 exponentiation 28 | ; ---------------------- 29 | 30 | .import check_fp_err 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_EXP10 37 | jsr EXP10 38 | jmp check_fp_err 39 | .endproc 40 | 41 | .include "deftok.inc" 42 | deftoken "FP_EXP10" 43 | 44 | ; vi:syntax=asm_ca65 45 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_intfp.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Integer to Floating Point 28 | ; ------------------------- 29 | 30 | .import push_fr0, int_to_fp 31 | .importzp next_instruction 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_INT_FP ; Convert AX to FP 36 | pha 37 | ; Save FP stack 38 | jsr push_fr0 39 | ; Restore A 40 | pla 41 | ; Convert to FP 42 | jsr int_to_fp 43 | jmp next_instruction 44 | .endproc 45 | 46 | .include "deftok.inc" 47 | deftoken "INT_FP" 48 | 49 | ; vi:syntax=asm_ca65 50 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_load.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Load Floating Point number from address 28 | ; --------------------------------------- 29 | 30 | .import push_fr0 31 | .importzp next_instruction 32 | 33 | .include "atari.inc" 34 | 35 | .segment "RUNTIME" 36 | 37 | .proc EXE_FP_LOAD 38 | stx FLPTR+1 39 | sta FLPTR 40 | jsr push_fr0 41 | jsr FLD0P 42 | jmp next_instruction 43 | .endproc 44 | 45 | .include "deftok.inc" 46 | deftoken "FP_LOAD" 47 | 48 | ; vi:syntax=asm_ca65 49 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_log.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Natural LOG function 28 | ; -------------------- 29 | 30 | .import check_fp_err 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_LOG 37 | jsr LOG 38 | jmp check_fp_err 39 | .endproc 40 | 41 | .include "deftok.inc" 42 | deftoken "FP_LOG" 43 | 44 | ; vi:syntax=asm_ca65 45 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_log10.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Decimal LOG function 28 | ; -------------------- 29 | 30 | .import check_fp_err 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_LOG10 37 | jsr LOG10 38 | jmp check_fp_err 39 | .endproc 40 | 41 | .include "deftok.inc" 42 | deftoken "FP_LOG10" 43 | 44 | ; vi:syntax=asm_ca65 45 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_mul.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Floating Point Multiplication 28 | ; ----------------------------- 29 | 30 | .import check_fp_err, pop_fr1 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_MUL 37 | jsr pop_fr1 38 | jsr FMUL 39 | jmp check_fp_err 40 | .endproc 41 | 42 | .include "deftok.inc" 43 | deftoken "FP_MUL" 44 | 45 | ; vi:syntax=asm_ca65 46 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_set1.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Store 1 into FR0 (floating point register 0) 28 | ; -------------------------------------------- 29 | 30 | .export FP_SET_1 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | ; Load 1.0 to FR0 37 | .proc FP_SET_1 38 | jsr ZFR0 39 | lda #$40 40 | sta FR0 41 | lda #$01 42 | sta FR0+1 43 | rts 44 | .endproc 45 | 46 | 47 | ; vi:syntax=asm_ca65 48 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_sgn.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Floating Point SGN 28 | ; ------------------ 29 | 30 | .importzp next_instruction 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_SGN 37 | asl FR0 38 | beq zero 39 | ldy #$80 40 | sty FR0 41 | ror FR0 42 | ldy #$01 43 | sty FR0+1 44 | ldy #0 45 | sty FR0+2 46 | sty FR0+3 47 | sty FR0+4 48 | sty FR0+5 49 | zero: jmp next_instruction 50 | .endproc 51 | 52 | .include "deftok.inc" 53 | deftoken "FP_SGN" 54 | 55 | ; vi:syntax=asm_ca65 56 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_store.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Store Floating Point number to address 28 | ; -------------------------------------- 29 | 30 | .import pop_fr0 31 | .importzp next_instruction, saddr 32 | 33 | .include "atari.inc" 34 | 35 | .segment "RUNTIME" 36 | 37 | .proc EXE_FP_STORE 38 | ldx saddr 39 | ldy saddr+1 40 | jsr FST0R 41 | ; Pop FP stack 42 | jsr pop_fr0 43 | jmp next_instruction 44 | .endproc 45 | 46 | .include "deftok.inc" 47 | deftoken "FP_STORE" 48 | 49 | ; vi:syntax=asm_ca65 50 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_str.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Convert Floating Point number to string 28 | ; --------------------------------------- 29 | 30 | .import pop_fr0, fp_to_str 31 | .importzp next_instruction 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_FP_STR ; AX = STRING (FP_STACK) 36 | jsr fp_to_str 37 | pha 38 | jsr pop_fr0 39 | pla 40 | jmp next_instruction 41 | .endproc 42 | 43 | .include "deftok.inc" 44 | deftoken "FP_STR" 45 | 46 | ; vi:syntax=asm_ca65 47 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_sub.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Floating Point Subtraction 28 | ; -------------------------- 29 | 30 | .import check_fp_err, pop_fr1 31 | 32 | .include "atari.inc" 33 | 34 | .segment "RUNTIME" 35 | 36 | .proc EXE_FP_SUB 37 | jsr pop_fr1 38 | jsr FSUB 39 | jmp check_fp_err 40 | .endproc 41 | 42 | .include "deftok.inc" 43 | deftoken "FP_SUB" 44 | 45 | ; vi:syntax=asm_ca65 46 | -------------------------------------------------------------------------------- /src/interp/atarifp/fp_val.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Convert string to floating point 28 | ; -------------------------------- 29 | 30 | .import push_fr0, get_str_eol 31 | .importzp IOERROR, next_instruction 32 | 33 | .include "atari.inc" 34 | 35 | .segment "RUNTIME" 36 | 37 | .proc EXE_FP_VAL 38 | jsr get_str_eol 39 | jsr push_fr0 40 | jsr AFP 41 | bcc :+ 42 | lda #18 43 | sta IOERROR 44 | : jmp next_instruction 45 | .endproc 46 | 47 | .include "deftok.inc" 48 | deftoken "FP_VAL" 49 | 50 | ; vi:syntax=asm_ca65 51 | -------------------------------------------------------------------------------- /src/interp/bitand.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Bitwise AND 28 | ; ----------- 29 | 30 | .import stack_l, stack_h 31 | .importzp next_ins_incsp 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_BIT_AND ; AX = (SP+) & AX 36 | and stack_l, y 37 | pha 38 | txa 39 | and stack_h, y 40 | tax 41 | pla 42 | jmp next_ins_incsp 43 | .endproc 44 | 45 | .include "deftok.inc" 46 | deftoken "BIT_AND" 47 | 48 | ; vi:syntax=asm_ca65 49 | -------------------------------------------------------------------------------- /src/interp/bitexor.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Bitwise EXOR 28 | ; ------------ 29 | 30 | .import stack_l, stack_h 31 | .importzp next_ins_incsp 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_BIT_EXOR ; AX = (SP+) ^ AX 36 | eor stack_l, y 37 | pha 38 | txa 39 | eor stack_h, y 40 | tax 41 | pla 42 | jmp next_ins_incsp 43 | .endproc 44 | 45 | .include "deftok.inc" 46 | deftoken "BIT_EXOR" 47 | 48 | ; vi:syntax=asm_ca65 49 | -------------------------------------------------------------------------------- /src/interp/bitor.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Bitwise OR 28 | ; ---------- 29 | 30 | .import stack_l, stack_h 31 | .importzp next_ins_incsp 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_BIT_OR ; AX = (SP+) | AX 36 | ora stack_l, y 37 | pha 38 | txa 39 | ora stack_h, y 40 | tax 41 | pla 42 | jmp next_ins_incsp 43 | .endproc 44 | 45 | .include "deftok.inc" 46 | deftoken "BIT_OR" 47 | 48 | ; vi:syntax=asm_ca65 49 | -------------------------------------------------------------------------------- /src/interp/dpoke.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Writes a 16-bit value to an address 28 | ; ----------------------------------- 29 | 30 | .importzp next_instruction, saddr 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_DPOKE ; DPOKE SADDR, AX 35 | ldy #0 36 | sta (saddr), y 37 | iny 38 | txa 39 | sta (saddr), y 40 | jmp next_instruction 41 | .endproc 42 | 43 | .include "deftok.inc" 44 | deftoken "DPOKE" 45 | 46 | ; vi:syntax=asm_ca65 47 | -------------------------------------------------------------------------------- /src/interp/for_exit.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Exit from FOR/NEXT 28 | ; ------------------ 29 | 30 | .export next_ins_incsp_2 31 | .importzp next_ins_incsp, sptr 32 | 33 | 34 | .segment "RUNTIME" 35 | 36 | ; FOR_EXIT: Remove the FOR arguments from the stack! 37 | .proc EXE_FOR_EXIT 38 | inc sptr 39 | .endproc ; Fall through 40 | 41 | .proc next_ins_incsp_2 42 | inc sptr 43 | jmp next_ins_incsp 44 | .endproc 45 | 46 | .include "deftok.inc" 47 | deftoken "FOR_EXIT" 48 | 49 | ; vi:syntax=asm_ca65 50 | -------------------------------------------------------------------------------- /src/interp/land.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Logical AND 28 | ; ----------- 29 | 30 | .import stack_l 31 | .importzp next_ins_incsp 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_L_AND ; A = A & (SP+) 36 | and stack_l, y 37 | jmp next_ins_incsp 38 | .endproc 39 | 40 | .include "deftok.inc" 41 | deftoken "L_AND" 42 | 43 | ; vi:syntax=asm_ca65 44 | -------------------------------------------------------------------------------- /src/interp/lnot.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Logical NOT 28 | ; ----------- 29 | 30 | .importzp next_instruction 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_L_NOT ; A = !A 35 | eor #1 36 | jmp next_instruction 37 | .endproc 38 | 39 | .include "deftok.inc" 40 | deftoken "L_NOT" 41 | 42 | ; vi:syntax=asm_ca65 43 | -------------------------------------------------------------------------------- /src/interp/lor.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Logical OR 28 | ; ---------- 29 | 30 | .import stack_l 31 | .importzp next_ins_incsp 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_L_OR ; A = A | (SP+) 36 | ora stack_l, y 37 | jmp next_ins_incsp 38 | .endproc 39 | 40 | .include "deftok.inc" 41 | deftoken "L_OR" 42 | 43 | ; vi:syntax=asm_ca65 44 | -------------------------------------------------------------------------------- /src/interp/negax.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Negate AX 28 | ; --------- 29 | 30 | .export neg_AX 31 | 32 | .segment "RUNTIME" 33 | 34 | ; Negate AX value : MUST PRESERVE Y 35 | .proc neg_AX 36 | clc 37 | eor #$FF 38 | adc #1 39 | pha 40 | txa 41 | eor #$FF 42 | adc #0 43 | tax 44 | pla 45 | rts 46 | .endproc 47 | 48 | ; vi:syntax=asm_ca65 49 | -------------------------------------------------------------------------------- /src/interp/peekb.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Reads an 8-bit value from a constant address 28 | ; -------------------------------------------- 29 | 30 | .importzp cptr 31 | .import inc_cptr_1 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_BYTE_PEEK ; AX = PEEK(read 1 byte from op) 36 | ldx #0 37 | lda (cptr, x) 38 | tay 39 | lda 0, y 40 | jmp inc_cptr_1 41 | .endproc 42 | 43 | .include "deftok.inc" 44 | deftoken "BYTE_PEEK" 45 | 46 | ; vi:syntax=asm_ca65 47 | -------------------------------------------------------------------------------- /src/interp/poke.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Writes an 8-bit value to an address 28 | ; ----------------------------------- 29 | 30 | .importzp next_instruction, saddr 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_POKE ; POKE SADDR, A 35 | ldy #0 36 | sta (saddr), y 37 | jmp next_instruction 38 | .endproc 39 | 40 | .include "deftok.inc" 41 | deftoken "POKE" 42 | 43 | ; vi:syntax=asm_ca65 44 | -------------------------------------------------------------------------------- /src/interp/pop.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Stack pop 28 | ; --------- 29 | 30 | .importzp next_ins_incsp 31 | .import stack_l, stack_h 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_POP ; pop AX from stack 36 | lda stack_l, y 37 | ldx stack_h, y 38 | jmp next_ins_incsp 39 | .endproc 40 | 41 | .include "deftok.inc" 42 | deftoken "POP" 43 | 44 | ; vi:syntax=asm_ca65 45 | -------------------------------------------------------------------------------- /src/interp/push.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Stack push 28 | ; ---------- 29 | 30 | .import pushAX 31 | .importzp next_instruction 32 | 33 | .segment "RUNTIME" 34 | 35 | .proc EXE_PUSH ; push AX into stack 36 | jsr pushAX 37 | jmp next_instruction 38 | .endproc 39 | 40 | .include "deftok.inc" 41 | deftoken "PUSH" 42 | 43 | ; vi:syntax=asm_ca65 44 | -------------------------------------------------------------------------------- /src/interp/put.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; PUT character or PUT EOL 28 | ; ------------------------ 29 | 30 | .import putc 31 | .importzp next_instruction 32 | 33 | .segment "RUNTIME" 34 | 35 | EXE_PUT: ; PUT character 36 | jsr putc 37 | jmp next_instruction 38 | 39 | .include "deftok.inc" 40 | deftoken "PUT" 41 | 42 | ; vi:syntax=asm_ca65 43 | -------------------------------------------------------------------------------- /src/interp/putbyte.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; PUT character from code 28 | ; ----------------------- 29 | 30 | .import putc, inc_cptr_1 31 | .importzp cptr 32 | 33 | .segment "RUNTIME" 34 | 35 | EXE_BYTE_PUT: ; PUT constant byte 36 | ldx #0 37 | lda (cptr, x) 38 | jsr putc 39 | jmp inc_cptr_1 40 | 41 | .include "deftok.inc" 42 | deftoken "BYTE_PUT" 43 | 44 | ; vi:syntax=asm_ca65 45 | -------------------------------------------------------------------------------- /src/interp/return.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Return from subroutine 28 | ; ---------------------- 29 | 30 | .importzp next_instruction, cptr 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_CNRET 35 | eor #1 36 | .endproc ; Fall through 37 | 38 | .proc EXE_CRET 39 | lsr 40 | bcs skip 41 | .endproc ; Fall through 42 | 43 | .proc EXE_RET 44 | pla 45 | sta cptr+1 46 | pla 47 | sta cptr 48 | ::skip: 49 | jmp next_instruction 50 | .endproc 51 | 52 | .include "deftok.inc" 53 | deftoken "RET" 54 | deftoken "CRET" 55 | deftoken "CNRET" 56 | 57 | ; vi:syntax=asm_ca65 58 | -------------------------------------------------------------------------------- /src/interp/sgn.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; SGN, extract sign 28 | ; ----------------- 29 | 30 | .importzp next_instruction 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_SGN 35 | cpx #0 36 | bmi neg 37 | bne pos 38 | tax 39 | beq xit 40 | pos: lda #1 41 | ldx #0 42 | beq xit 43 | neg: lda #$FF 44 | tax 45 | xit: jmp next_instruction 46 | .endproc 47 | 48 | .include "deftok.inc" 49 | deftoken "SGN" 50 | 51 | ; vi:syntax=asm_ca65 52 | -------------------------------------------------------------------------------- /src/interp/shl8.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; SHL8, shift left by 8 (multiply by 256) 28 | ; --------------------------------------- 29 | 30 | .importzp next_instruction 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_SHL8 35 | tax 36 | lda #0 37 | jmp next_instruction 38 | .endproc 39 | 40 | .include "deftok.inc" 41 | deftoken "SHL8" 42 | 43 | ; vi:syntax=asm_ca65 44 | -------------------------------------------------------------------------------- /src/interp/ushl.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Shift Left (multiplies by 2) 28 | ; ---------------------------- 29 | 30 | .importzp next_instruction 31 | 32 | .segment "RUNTIME" 33 | 34 | .proc EXE_USHL ; AX = AX * 2 (UNSIGNED) 35 | asl 36 | tay 37 | txa 38 | rol 39 | tax 40 | tya 41 | jmp next_instruction 42 | .endproc 43 | 44 | .include "deftok.inc" 45 | deftoken "USHL" 46 | 47 | ; vi:syntax=asm_ca65 48 | -------------------------------------------------------------------------------- /src/standalone.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | ; Copyright (C) 2017-2025 Daniel Serpell 4 | ; 5 | ; This program is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU General Public License as published by 7 | ; the Free Software Foundation, either version 2 of the License, or 8 | ; (at your option) any later version. 9 | ; 10 | ; This program is distributed in the hope that it will be useful, 11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ; GNU General Public License for more details. 14 | ; 15 | ; You should have received a copy of the GNU General Public License along 16 | ; with this program. If not, see 17 | ; 18 | ; In addition to the permissions in the GNU General Public License, the 19 | ; authors give you unlimited permission to link the compiled version of 20 | ; this file into combinations with other programs, and to distribute those 21 | ; combinations without any restriction coming from the use of this file. 22 | ; (The General Public License restrictions do apply in other respects; for 23 | ; example, they cover modification of the file, and distribution when not 24 | ; linked into a combine executable.) 25 | 26 | 27 | ; Standalone interpreter variables 28 | ; -------------------------------- 29 | 30 | ; Main bytecode symbol 31 | .exportzp array_ptr, BASIC_TOP 32 | 33 | .zeropage 34 | 35 | ; Zero page variables: 36 | array_ptr: .res 2 ; Top of array memory 37 | BASIC_TOP= array_ptr 38 | 39 | ; vi:syntax=asm_ca65 40 | -------------------------------------------------------------------------------- /src/syntax/a5200.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | # Constants used in Atari 8-bit target 20 | # ------------------------------------ 21 | 22 | SYMBOLS { 23 | # Used in SOUND 24 | AUDF1 = $E800 25 | AUDCTL = $E808 26 | SKCTL = $E80F 27 | # Used in GRAPHICS 28 | COLOR0 = $0C 29 | # Used in base file 30 | PADDL0 = $11 31 | STICK0 = $21C 32 | STRIG0 = $220 33 | STRIG0B = $224 34 | PTRIG0 = $224 35 | CH = import 36 | # Used in TIME function: 37 | RTCLOK1 = 1 38 | RTCLOK2 = 2 39 | # Used in DLI 40 | WSYNC = $D40A 41 | NMIEN = $D40E 42 | VDSLST = $206 43 | COLRSH = importzp 44 | # Used in P/M 45 | HPOSP0 = $C000 46 | } 47 | 48 | # vi:syntax=perl 49 | -------------------------------------------------------------------------------- /src/syntax/a800.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | # Constants used in Atari 8-bit target 20 | # ------------------------------------ 21 | 22 | SYMBOLS { 23 | # Used in SOUND 24 | AUDF1 = $D200 25 | AUDCTL = $D208 26 | SKCTL = $D20F 27 | # Used in GRAPHICS 28 | COLOR0 = $02C4 29 | FILDAT = $02FD 30 | # Used in base file 31 | PADDL0 = $0270 32 | STICK0 = $0278 33 | PTRIG0 = $027C 34 | STRIG0 = $0284 35 | CH = $02FC 36 | # Used in TIME function: 37 | RTCLOK1 = 19 38 | RTCLOK2 = 20 39 | # Used in DLI 40 | WSYNC = $D40A 41 | NMIEN = $D40E 42 | VDSLST = $200 43 | COLRSH = $4F 44 | # Used in P/M 45 | HPOSP0 = $D000 46 | } 47 | 48 | # vi:syntax=perl 49 | -------------------------------------------------------------------------------- /src/syntax/extended.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | # Syntax for extended commands, available only in the cross-compiler. 20 | 21 | EXTERN { 22 | E_DATA_FILE 23 | E_DATA_SET_ROM_SEG 24 | E_DATA_SET_SEGMENT 25 | E_COUNT_PARAM 26 | E_PROC_CHECK 27 | } 28 | 29 | # Reda DATA statements from a file: 30 | DATA_FILE: 31 | "File" DATA_EXT_TYPE E_LABEL_SET_TYPE "\"" E_DATA_FILE 32 | 33 | # Expands data types with "file" data 34 | DATA_TYPE: 35 | TYPE_BYTE DATA_FILE 36 | TYPE_WORD DATA_FILE 37 | 38 | # Reda DATA statements location (ROM or RAM): 39 | DATA_EXT_TYPE: 40 | "ROM" E_DATA_SET_ROM_SEG 41 | "[" E_DATA_SET_SEGMENT "]" 42 | 43 | # In the cross-compiler, we count parameters to detect program errors: 44 | # Count parameters before EXEC 45 | EXEC_PARAM_MORE:< 46 | E_COUNT_PARAM 47 | 48 | # Count parameters before PROC 49 | OPT_PROC_VAR:< 50 | E_COUNT_PARAM 51 | 52 | # Check number of parameters after PROC 53 | OPT_PROC_VAR: 54 | E_PROC_CHECK 55 | 56 | # vi:syntax=perl 57 | -------------------------------------------------------------------------------- /src/syntax/gr-a5200.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | # Graphic support statements for the Atari 5200 20 | 21 | TOKENS { 22 | TOK_GRAPHICS, TOK_DRAWTO, TOK_PLOT, TOK_LOCATE 23 | } 24 | 25 | SYMBOLS { 26 | COLOR = importzp 27 | } 28 | 29 | # Compatibility: Allows I/O channel number 6 in PRINT 30 | IO_CHAN_N6: (only I/O channel 6 supported) 31 | "6" 32 | 33 | IO_CHAN: I/O channel number 34 | "#" IO_CHAN_N6 35 | 36 | IO_CHAN_OPT: 37 | IO_CHAN "," 38 | 39 | # Used only for CLS #6 40 | IO_CHAN_OPT_NOCOMMA: 41 | IO_CHAN 42 | 43 | # Third parameter to LOCATE needs an address to store the value 44 | LOC_VAR: comma 45 | "," ARRAY_BYTE_ADDR emit { TOK_SADDR, TOK_LOCATE, TOK_POKE } 46 | "," VAR_WORD_LVALUE_SADDR emit { TOK_LOCATE, TOK_DPOKE } 47 | 48 | STATEMENT: 49 | "Graphics" emit { TOK_0, TOK_PMGRAPHICS } EXPR emit TOK_GRAPHICS 50 | "Color" EXPR emit { TOK_BYTE_POKE, COLOR } 51 | "PLot" POSITION emit { TOK_PLOT } 52 | "LOCate" POSITION LOC_VAR 53 | "DRawto" POSITION emit { TOK_DRAWTO } 54 | "SEtcolor" EXPR emit { TOK_PUSH_NUM, &COLOR0, TOK_ADD, TOK_SADDR } EXPR_AB emit TOK_POKE 55 | 56 | # vi:syntax=perl 57 | -------------------------------------------------------------------------------- /src/syntax/graphics.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | # Graphic support statements specific to the Atari 8-bit computers 20 | # NOTE: in the Atari 8-bit this depends on file I/O, as uses I/O channel 6. 21 | 22 | TOKENS { 23 | TOK_GRAPHICS, TOK_DRAWTO 24 | } 25 | 26 | SYMBOLS { 27 | COLOR = importzp 28 | DRAWLN = $11 29 | FILLIN = $12 30 | } 31 | 32 | STATEMENT: 33 | "Graphics" emit { TOK_0, TOK_PMGRAPHICS, TOK_BYTE, 6, TOK_CLOSE } EXPR emit TOK_GRAPHICS 34 | "Color" EXPR emit { TOK_BYTE_POKE, COLOR } 35 | "FColor" EXPR emit { TOK_NUM_POKE, &FILDAT } 36 | "LOCate" POSITION emit { TOK_BYTE, 6, TOK_IOCHN } GET_EXPR 37 | "PLot" POSITION emit { TOK_BYTE, 6, TOK_IOCHN, TOK_BYTE_PEEK, COLOR, TOK_PUT } IO_CHAN0 38 | "DRawto" POSITION emit { TOK_BYTE, DRAWLN, TOK_DRAWTO } 39 | "FIllto" POSITION emit { TOK_BYTE, FILLIN, TOK_DRAWTO } 40 | "SEtcolor" EXPR emit { TOK_PUSH_NUM, &COLOR0, TOK_ADD, TOK_SADDR } EXPR_AB emit TOK_POKE 41 | 42 | # vi:syntax=perl 43 | -------------------------------------------------------------------------------- /src/syntax/pm.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | # P/M statements 20 | TOKENS { 21 | TOK_PMGRAPHICS 22 | } 23 | 24 | SYMBOLS { 25 | PMGMODE = import 26 | PMGBASE = import 27 | } 28 | 29 | INT_FUNCTIONS: 30 | "PMadr" T_EXPR emit { TOK_PUSH_BYTE, 4, TOK_ADD, TOK_PUSH_NUM, &PMGMODE, \ 31 | TOK_PEEK, TOK_USHL, TOK_MUL, TOK_PUSH_NUM, &PMGBASE, \ 32 | TOK_PEEK, TOK_SHL8, TOK_ADD } 33 | STATEMENT: 34 | "PMGraphics" EXPR emit TOK_PMGRAPHICS 35 | "PMhpos" EXPR emit { TOK_PUSH_NUM, &HPOSP0, TOK_ADD, TOK_SADDR } "," EXPR emit TOK_POKE 36 | 37 | # vi:syntax=perl 38 | -------------------------------------------------------------------------------- /src/syntax/sio.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | STATEMENT: 20 | "SIo" EXPR emit { TOK_NUM_POKE, &$300 } \ 21 | "," EXPR emit { TOK_NUM_POKE, &$301 } \ 22 | "," EXPR emit { TOK_NUM_POKE, &$302 } \ 23 | "," EXPR emit { TOK_NUM_POKE, &$303 } \ 24 | "," emit { TOK_NUM, &$304, TOK_SADDR } EXPR emit { TOK_DPOKE } \ 25 | "," EXPR emit { TOK_NUM_POKE, &$306 } \ 26 | "," emit { TOK_NUM, &$308, TOK_SADDR } EXPR emit { TOK_DPOKE } \ 27 | "," EXPR emit { TOK_NUM_POKE, &$30A } \ 28 | "," EXPR emit { TOK_NUM_POKE, &$30B } \ 29 | emit { TOK_NUM, &$E459, TOK_USR_ADDR, TOK_USR_CALL } 30 | 31 | INT_FUNCTIONS: 32 | "SErr()" emit { TOK_NUM, &$303, TOK_PEEK } -------------------------------------------------------------------------------- /src/syntax/sound.syn: -------------------------------------------------------------------------------- 1 | # 2 | # FastBasic - Fast basic interpreter for the Atari 8-bit computers 3 | # Copyright (C) 2017-2025 Daniel Serpell 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program. If not, see 17 | # 18 | 19 | SYMBOLS { 20 | SOUND_OFF = import 21 | } 22 | 23 | # SOUND statement, three possibilities: 24 | # SOUND voice, freq, distort, vol 25 | # SOUND voice 26 | # SOUND 27 | SOUND: 28 | SOUND_S1 "," EXPR emit TOK_PUSH EXPR_AB \ 29 | emit { TOK_SHL8, TOK_ADD, TOK_DPOKE, TOK_0, TOK_NUM_POKE, &AUDCTL, \ 30 | TOK_BYTE, 3, TOK_NUM_POKE, &SKCTL } 31 | SOUND_S1 emit { TOK_0, TOK_DPOKE } 32 | emit { TOK_NUM, &SOUND_OFF, TOK_USR_ADDR, TOK_USR_CALL } 33 | 34 | SOUND_S1: 35 | EXPR emit { TOK_USHL, TOK_PUSH_NUM, &AUDF1, TOK_ADD, TOK_SADDR } 36 | 37 | 38 | STATEMENT: 39 | "Sound" SOUND 40 | 41 | # vi:syntax=perl 42 | -------------------------------------------------------------------------------- /startup.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/startup.bat -------------------------------------------------------------------------------- /testsuite/README.md: -------------------------------------------------------------------------------- 1 | FastBasic test suite 2 | -------------------- 3 | 4 | To run the testsuite, you need "git" to download the 6502 simulator and type 5 | `make test` from the parent directory. 6 | 7 | -------------------------------------------------------------------------------- /testsuite/tests/abbrev.chk: -------------------------------------------------------------------------------- 1 | Name: Test for function abbreviations 2 | Test: run-fp 3 | Input: 4 | HELLO 5 | NEXT LINE 6 | . 7 | Output: 8 | Start 9 | 2468 10 | 1 11 | 2468 12 | 1 A 65 13 | 1 14 | 2468 15 | 1 1 16 | 10 17 | 1 3 18 | 1 3 19 | 1 10 20 | 1 21 | X 22 | 3 23 | 12547 24 | ABLLO 25 | SCREEN: set graphics 0 26 | SCREEN: plot 4,5 color 6 27 | SCREEN: draw to 7,8 color 6 28 | SCREEN: fill to 10,20 color 6, fill color 8 29 | SCREEN: draw to 15,30 color 6 30 | SCREEN: set graphics 0 with text window 31 | SCREEN: locate 1,2 32 | 33 | -2 34 | 2 35 | 1 36 | X 37 | 2 38 | 4 39 | P1 40 | N 41 | ?EXT LINE 42 | BBBBB 43 | 3 44 | 65536 45 | 65537 46 | R 47 | W2 48 | W1 49 | A0 50 | FP-FUN 51 | 2 52 | 1 53 | 98 54 | 1.1 55 | 0 56 | 1 57 | 10 58 | 1 59 | 2 60 | 1 61 | 0.1 62 | 1 63 | INT-FUN 64 | 0 65 | 1 66 | 1 67 | 128 68 | 10 69 | 1 70 | 123 71 | 5 72 | 15 73 | 3 74 | 1024 75 | 0 76 | 22 77 | 22 78 | 3 79 | 123 80 | 49 81 | OPER 82 | 100 83 | 110 84 | 100 85 | 110 86 | 010 87 | 2653 88 | 0 89 | -------------------------------------------------------------------------------- /testsuite/tests/addr2str.bas: -------------------------------------------------------------------------------- 1 | ' Convert address to strings 2 | 3 | x = ADR("Hello") 4 | ? $( x ), peek(x) 5 | 6 | data y() byte = 5, $57, $6f, $72, $6c, $64 7 | 8 | ? $( ADR(y) ) 9 | -------------------------------------------------------------------------------- /testsuite/tests/addr2str.chk: -------------------------------------------------------------------------------- 1 | Name: String at address "$()" 2 | Test: run 3 | Output: 4 | Hello 5 5 | World 6 | -------------------------------------------------------------------------------- /testsuite/tests/ahlbench.bas: -------------------------------------------------------------------------------- 1 | 2 | ' Based on AHL's simple benchmark 3 | S%=0 4 | FOR N=1 TO 100 5 | A%=N 6 | FOR I=1 TO 10 7 | A%=SQR(A%) 8 | NEXT I 9 | FOR I=1 TO 10 10 | A%=A%^2 11 | NEXT I 12 | S%=S%+A% 13 | NEXT N 14 | 15 | chk% = 5e-4 16 | exec check 17 | 18 | S%=0 19 | FOR N=1 TO 100 20 | A%=N 21 | FOR I=1 TO 5 22 | A%=A%^0.4 23 | NEXT I 24 | FOR I=1 TO 5 25 | A%=A%^2.5 26 | NEXT I 27 | S%=S%+A% 28 | NEXT N 29 | 30 | chk% = 1e-4 31 | exec check 32 | 33 | S%=0 34 | FOR N=1 TO 100 35 | A%=N/250.0 36 | FOR I=1 TO 10 37 | A%=SIN(A%)/COS(A%) 38 | NEXT I 39 | FOR I=1 TO 10 40 | A%=ATN(A%) 41 | NEXT I 42 | S%=S%+A% 43 | NEXT N 44 | 45 | S%=S%*250 46 | chk% = 5e-5 47 | exec check 48 | 49 | 50 | proc check 51 | ? "Accuracy: "; 52 | accuracy% = ABS(1010-S%/5) 53 | if accuracy% < chk% 54 | ? "OK" 55 | else 56 | ? "BAD "; accuracy% 57 | endif 58 | endproc 59 | -------------------------------------------------------------------------------- /testsuite/tests/ahlbench.chk: -------------------------------------------------------------------------------- 1 | Name: Test floating-point calculations 2 | Test: run-fp 3 | Max-Cycles: 250000000 4 | Output: 5 | Accuracy: OK 6 | Accuracy: OK 7 | Accuracy: OK 8 | -------------------------------------------------------------------------------- /testsuite/tests/arrays.bas: -------------------------------------------------------------------------------- 1 | ' Test for array operations 2 | ? "Start" 3 | 4 | dim arr1( 19 ) , arr2(9) byte 5 | 6 | arr1(0) = 1 7 | for i = 1 to 19 8 | arr1( i ) = arr1(i-1) * i 9 | next i 10 | 11 | for i = 0 to 9 12 | arr2( i ) = i * i * i 13 | next i 14 | 15 | for i=0 to 9 16 | ? arr1(i), arr2(i), arr1(i+2) 17 | next i 18 | 19 | ? arr1(15),arr1(16),arr1(17),arr1(18),arr1(19) 20 | 21 | ' Also test DIM for normal variables 22 | dim ivar, svar$ 23 | ? ivar; svar$ 24 | -------------------------------------------------------------------------------- /testsuite/tests/arrays.chk: -------------------------------------------------------------------------------- 1 | Name: Test array operations 2 | Test: run 3 | Output: 4 | Start 5 | 1 0 2 6 | 1 1 6 7 | 2 8 24 8 | 6 27 120 9 | 24 64 720 10 | 120 125 5040 11 | 720 216 -25216 12 | 5040 87 -30336 13 | -25216 0 24320 14 | -30336 217 5376 15 | 22528 -32768 -32768 0 0 16 | 0 17 | -------------------------------------------------------------------------------- /testsuite/tests/big-num.bas: -------------------------------------------------------------------------------- 1 | 2 | ? 111111111111111111111111111111 3 | -------------------------------------------------------------------------------- /testsuite/tests/big-num.chk: -------------------------------------------------------------------------------- 1 | Name: Check parsing of numbers too big 2 | Test: run-fp 3 | Output: 4 | 1.111111111E+29 5 | -------------------------------------------------------------------------------- /testsuite/tests/bug2.bas: -------------------------------------------------------------------------------- 1 | A%=123 2 | ?A% 3 | ?STR$(A%) 4 | ?LEN(STR$(A%)) 5 | B$=STR$(A%) 6 | ?B$ 7 | ?LEN(B$) 8 | -------------------------------------------------------------------------------- /testsuite/tests/bug2.chk: -------------------------------------------------------------------------------- 1 | Name: Check floating-point STR$ function 2 | Test: run-fp 3 | Output: 4 | 123 5 | 123 6 | 3 7 | 123 8 | 3 9 | -------------------------------------------------------------------------------- /testsuite/tests/color.bas: -------------------------------------------------------------------------------- 1 | 2 | ? "Start" 3 | 4 | gr. 8 5 | 6 | color 1 7 | plot 0,0 8 | plot 1,0 9 | plot 310,76 10 | drawto 20,30 11 | 12 | gr.9+16 13 | 14 | color 3 15 | plot 3,7 16 | dr. 5,23 17 | 18 | fcolor 7 19 | fillto 45,30 20 | 21 | color 0 22 | plot 10,10 23 | dr. 20,20 24 | 25 | -------------------------------------------------------------------------------- /testsuite/tests/color.chk: -------------------------------------------------------------------------------- 1 | Name: Test COLOR, FCOLOR and PLOT statements 2 | Test: run 3 | Output: 4 | Start 5 | SCREEN: set graphics 8 with text window 6 | SCREEN: plot 0,0 color 1 7 | SCREEN: plot 1,0 color 1 8 | SCREEN: plot 310,76 color 1 9 | SCREEN: draw to 20,30 color 1 10 | SCREEN: set graphics 9 11 | SCREEN: plot 3,7 color 3 12 | SCREEN: draw to 5,23 color 3 13 | SCREEN: fill to 45,30 color 3, fill color 7 14 | SCREEN: plot 10,10 color 0 15 | SCREEN: draw to 20,20 color 0 16 | -------------------------------------------------------------------------------- /testsuite/tests/cstring.bas: -------------------------------------------------------------------------------- 1 | ?"Basic String" 2 | ?"Using "" inside" 3 | ?"Str";"12" 4 | ?"Str""";"12" 5 | ?"Str"$31"2" 6 | ?"Str"$31$32 7 | ?"Str"$31;"2" 8 | 9 | -------------------------------------------------------------------------------- /testsuite/tests/cstring.chk: -------------------------------------------------------------------------------- 1 | Name: Check for parsing of string constants 2 | Test: run 3 | Output: 4 | Basic String 5 | Using " inside 6 | Str12 7 | Str"12 8 | Str12 9 | Str12 10 | Str12 11 | -------------------------------------------------------------------------------- /testsuite/tests/data-file.bas: -------------------------------------------------------------------------------- 1 | ' Test DATA FILE inclusion 2 | ? "Start" 3 | 4 | DATA fb() bytefile "data-file.bas" 5 | DATA fw() wordfile "data-file.bas" 6 | 7 | ? fb(0), fb(1) 8 | ? fw(0) 9 | -------------------------------------------------------------------------------- /testsuite/tests/data-file.chk: -------------------------------------------------------------------------------- 1 | Name: Test DATA FILE inclusion 2 | Test: run-cross 3 | Output: 4 | Start 5 | 39 32 6 | 8231 7 | -------------------------------------------------------------------------------- /testsuite/tests/data-in-proc.bas: -------------------------------------------------------------------------------- 1 | ' Test for DATA/PROC inside PROC 2 | ? "Start" 3 | exec x 4 | 5 | ' Define a DATA inside the PROC 6 | proc x 7 | data y() = 1,2 8 | ? y(0) 9 | endproc 10 | 11 | ' Define a PROC and call twice 12 | proc z 13 | proc a 14 | ? y(1) 15 | endproc 16 | exec a 17 | exec a 18 | endproc 19 | 20 | exec z 21 | 22 | -------------------------------------------------------------------------------- /testsuite/tests/data-in-proc.chk: -------------------------------------------------------------------------------- 1 | Name: Test for DATA inside PROC 2 | Test: run 3 | Output: 4 | Start 5 | 1 6 | 2 7 | 2 8 | -------------------------------------------------------------------------------- /testsuite/tests/data-rom.bas: -------------------------------------------------------------------------------- 1 | ' Test DATA in ROM segments 2 | ? "Start" 3 | 4 | DATA rfb() ROM = 1,2,3,4,5 5 | DATA rfw() BYTE ROM = 1,2,3,4,5,6 6 | DATA dfw() BYTE = 7, 8, 9 7 | DATA other() [RUNTIME] = 128, 129, 130, 131 8 | 9 | ? rfb(0), rfb(1) 10 | ? rfw(0), other(1) 11 | ' Check that the DATA addresses are in different segments 12 | ? ABS(ADR(dfw) - ADR(rfw)) > 10 13 | 14 | -------------------------------------------------------------------------------- /testsuite/tests/data-rom.chk: -------------------------------------------------------------------------------- 1 | Name: Test DATA ROM 2 | Test: run-cross 3 | Output: 4 | Start 5 | 1 2 6 | 1 129 7 | 1 8 | -------------------------------------------------------------------------------- /testsuite/tests/diskio.bas: -------------------------------------------------------------------------------- 1 | ? "Start" 2 | open #1, 8, 0, "D:XXX" 3 | ? #1, "hola" 4 | ? #1, "chao"; 5 | ? ERR() 6 | close #1 7 | 8 | ? "INPUT" 9 | open #2, 4, 0, "D:XXX" 10 | input #2, A$ 11 | ? ERR() 12 | ? A$ 13 | input #2, A$ 14 | ? ERR() 15 | ? A$ 16 | close #2 17 | ? ERR() 18 | 19 | ? "BGET 9" 20 | A$ = "XXXXYYYYZZZZ" 21 | open #2, 4, 0, "D:XXX" 22 | bget #2, adr(A$) + 1, 9 23 | ? ERR() 24 | close #2 25 | ? ERR() 26 | ? A$ 27 | 28 | ? "BGET 32" 29 | A$ = "XXXXYYYYZZZZ" 30 | open #2, 4, 0, "D:XXX" 31 | bget #2, adr(A$) + 1, 32 32 | ? ERR() 33 | close #2 34 | ? ERR() 35 | ? A$ 36 | 37 | ' Write a big string 38 | open #1, 8, 0, "D:XXX" 39 | ? #1, "Big 1: "; 40 | FOR I=0 TO 19 41 | ? #1, ""; 42 | NEXT 43 | ? #1, 44 | ? #1, "Big 2: "; 45 | FOR I=0 TO 25 46 | ? #1, ""; 47 | NEXT 48 | ? #1, 49 | close #1 50 | 51 | ? "BIG INPUT" 52 | open #2, 4, 0, "D:XXX" 53 | input #2, A$ 54 | ? ERR() 55 | ? A$, LEN(A$) 56 | input #2, A$ 57 | ? ERR() 58 | ? A$, LEN(A$) 59 | close #2 60 | ? ERR() 61 | 62 | -------------------------------------------------------------------------------- /testsuite/tests/diskio.chk: -------------------------------------------------------------------------------- 1 | Name: Check D: input/output 2 | Test: run 3 | Output: 4 | Start 5 | 1 6 | INPUT 7 | 1 8 | hola 9 | 136 10 | chao 11 | 1 12 | BGET 9 13 | 1 14 | 1 15 | hola 16 | chaoZZZ 17 | BGET 32 18 | 136 19 | 1 20 | hola 21 | chaoZZZ 22 | BIG INPUT 23 | 1 24 | Big 1: 217 25 | 137 26 | Big 2: 10 3 | 4 | -------------------------------------------------------------------------------- /testsuite/tests/err-bad-pos.chk: -------------------------------------------------------------------------------- 1 | Name: Check error reporting in cross-compiler. 2 | Test: compile-error 3 | Error: parse error at line 2 column 6 4 | Error-pos: 2:6 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-else.bas: -------------------------------------------------------------------------------- 1 | 2 | A=1 3 | IFA=0 4 | ? "OK" 5 | ' This should be parsed as a variable, not as ELSE A=1: 6 | ELSEA=1 7 | ENDIF 8 | 9 | ? A,ELSEA 10 | -------------------------------------------------------------------------------- /testsuite/tests/err-else.chk: -------------------------------------------------------------------------------- 1 | Name: Check proper parsing of ELSE 2 | Test: run 3 | Output: 4 | 1 0 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-endif.bas: -------------------------------------------------------------------------------- 1 | 2 | A=1 3 | IFA=1 4 | ? "OK" 5 | ' This should be parsed as a variable, not as ENDIF A=1: 6 | ENDIFA=1 7 | 8 | ? A,ENDIFA 9 | -------------------------------------------------------------------------------- /testsuite/tests/err-endif.chk: -------------------------------------------------------------------------------- 1 | Name: Check proper parsing of ENDIF 2 | Test: compile-error 3 | Error: no end loop/proc/if at line 8 column 0 4 | Error-pos: 9:0 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-1.bas: -------------------------------------------------------------------------------- 1 | 2 | LOOP 3 | 4 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-1.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of loop errors 2 | Test: compile-error 3 | Error: bad loop at line 2 column 0 4 | Error-pos: 2:4 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-2.bas: -------------------------------------------------------------------------------- 1 | ' Open WHILE/WEND loop and close with DO/LOOP. 2 | WHILE 1 3 | LOOP 4 | 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-2.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of loop errors 2 | Test: compile-error 3 | Error: bad loop at line 3 column 0 4 | Error-pos: 3:4 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-3.bas: -------------------------------------------------------------------------------- 1 | ' Try to exit with no loop: 2 | EXIT 3 | 4 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-3.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of loop errors 2 | Test: compile-error 3 | Error: bad loop at line 2 column 1 4 | Error-pos: 2:4 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-4.bas: -------------------------------------------------------------------------------- 1 | ' EXIR from DATA 2 | DATA A() = 1,2, 3 | EXIT 4 | DATA 3,4 5 | 6 | 7 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-4.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of loop errors 2 | Test: compile-error 3 | Error: bad loop at line 3 column 1 4 | Error-pos: 3:4 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-5.bas: -------------------------------------------------------------------------------- 1 | ' Open too many loop: 2 | DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO 3 | DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO 4 | DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO 5 | 6 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-5.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of loop errors 2 | Test: compile-error 3 | Error: bad loop at line 4 column 31 4 | Error-pos: 6:0 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-6.bas: -------------------------------------------------------------------------------- 1 | ' Open too many loop: 2 | DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO 3 | DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:DO 4 | DO:DO:DO:DO:DO:DO:DO:DO:DO:DO:EXIT 5 | 6 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop-6.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of loop errors 2 | Test: compile-error 3 | Error: bad loop at line 4 column 31 4 | Error-pos: 6:0 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop.bas: -------------------------------------------------------------------------------- 1 | DO 2 | ? "DO" 3 | ' This should parse as a variable, not "LOOP A=1" 4 | LOOPA=1 5 | 6 | ? LOOPA 7 | -------------------------------------------------------------------------------- /testsuite/tests/err-loop.chk: -------------------------------------------------------------------------------- 1 | Name: Check proper parsing of LOOP 2 | Test: compile-error 3 | Error: no end loop/proc/if at line 6 column 0 4 | Error-pos: 7:0 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-memory.bas: -------------------------------------------------------------------------------- 1 | 2 | ? "Start" 3 | dim array(10000) ' 20k should be ok 4 | ? "Ok" 5 | dim toobig(20000) ' 40k more, force memory error 6 | ? "Bad" 7 | 8 | -------------------------------------------------------------------------------- /testsuite/tests/err-memory.chk: -------------------------------------------------------------------------------- 1 | Name: Check memory runtime error 2 | Test: run 3 | Output: 4 | Start 5 | Ok 6 | 7 | Memory Error 8 | -------------------------------------------------------------------------------- /testsuite/tests/err-next.bas: -------------------------------------------------------------------------------- 1 | ' Test for error parsing variables that start with NEXT 2 | ? "Start" 3 | NEXT_TIME=1 4 | ? NEXT_TIME 5 | 6 | -------------------------------------------------------------------------------- /testsuite/tests/err-next.chk: -------------------------------------------------------------------------------- 1 | Name: Test for error parsing variables that start with NEXT 2 | Test: run 3 | Output: 4 | Start 5 | 1 6 | -------------------------------------------------------------------------------- /testsuite/tests/err-parse-bug.bas: -------------------------------------------------------------------------------- 1 | zi=1 : s=100-xi 2 | -------------------------------------------------------------------------------- /testsuite/tests/err-parse-bug.chk: -------------------------------------------------------------------------------- 1 | Name: Check infinite loop bug in parser 2 | Test: compile-error 3 | Error: parse error at line 1 column 15 4 | Error-pos: 1:15 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-parse-overflow.bas: -------------------------------------------------------------------------------- 1 | 2 | ' This line compiles ok 3 | data x()=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53 4 | 5 | ' This produces overflow in parser - but should not crash compiler! 6 | data y()=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55 7 | 8 | 9 | -------------------------------------------------------------------------------- /testsuite/tests/err-parse-overflow.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of parser overflow 2 | Test: compile-error-native 3 | Error: too long at line 6 4 | -------------------------------------------------------------------------------- /testsuite/tests/err-string1.bas: -------------------------------------------------------------------------------- 1 | 2 | A$="1234 3 | 4 | 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-string1.chk: -------------------------------------------------------------------------------- 1 | Name: Check unclosed string 2 | Test: compile-error 3 | Error: parse error at line 2 column 8 4 | Error-pos: 2:3 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-string2.bas: -------------------------------------------------------------------------------- 1 | 2 | A$="123"$2"45"$X"67" 3 | -------------------------------------------------------------------------------- /testsuite/tests/err-string2.chk: -------------------------------------------------------------------------------- 1 | Name: Check bad hex escape in string 2 | Test: compile-error 3 | Error: parse error at line 2 column 14 4 | Error-pos: 2:3 5 | -------------------------------------------------------------------------------- /testsuite/tests/err-vdata.bas: -------------------------------------------------------------------------------- 1 | ' Test for error parsing variables that start with DATA 2 | ? "Start" 3 | X=1234 4 | DATAVAR=DPEEK(&X) 5 | ? DATAVAR 6 | 7 | -------------------------------------------------------------------------------- /testsuite/tests/err-vdata.chk: -------------------------------------------------------------------------------- 1 | Name: Test for error parsing variables that start with DATA 2 | Test: run 3 | Output: 4 | Start 5 | 1234 6 | -------------------------------------------------------------------------------- /testsuite/tests/err-wend.bas: -------------------------------------------------------------------------------- 1 | A=0 2 | WHILE A=0 3 | ? "WHILE" 4 | ' This should parse as a variable, not "LOOP A=1" 5 | WENDA=1 6 | 7 | ? WENDA 8 | -------------------------------------------------------------------------------- /testsuite/tests/err-wend.chk: -------------------------------------------------------------------------------- 1 | Name: Check proper parsing of WEND 2 | Test: compile-error 3 | Error: no end loop/proc/if at line 7 column 0 4 | Error-pos: 8:0 5 | -------------------------------------------------------------------------------- /testsuite/tests/errlong.bas: -------------------------------------------------------------------------------- 1 | 2 | ' This line is OK 3 | ?"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456", 4 | 5 | ' This line is too long 6 | ?"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 7 | 8 | ' End 9 | 10 | -------------------------------------------------------------------------------- /testsuite/tests/errlong.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of output line too long 2 | Test: compile-error-native 3 | Error: too long at line 6 column 251 4 | -------------------------------------------------------------------------------- /testsuite/tests/execdata.bas: -------------------------------------------------------------------------------- 1 | ' Test for using a DATA array in EXEC parameter 2 | DATA Arr() = 1234,5678 3 | @Test Arr(0) 4 | @Test Arr(1) 5 | ? "Ok" 6 | 7 | PROC Test X 8 | ? X 9 | ENDPROC 10 | 11 | -------------------------------------------------------------------------------- /testsuite/tests/execdata.chk: -------------------------------------------------------------------------------- 1 | Name: Test for using a DATA array in EXEC parameter 2 | Test: run 3 | Output: 4 | 1234 5 | 5678 6 | Ok 7 | -------------------------------------------------------------------------------- /testsuite/tests/floatadr.bas: -------------------------------------------------------------------------------- 1 | ' Procedure to sum N elements of an array: 2 | PROC SUM P N 3 | SUM% = 0 4 | WHILE N>0 5 | DEC N 6 | SUM% = SUM% + %(P) 7 | P = P + 6 8 | WEND 9 | ENDPROC 10 | 11 | DIM A%(2) 12 | A%(0) = 0.125 13 | A%(1) = 0.0625 14 | ' Test storing into pointer 15 | %(&A%+12)= 0.03125 16 | 17 | @SUM &A%, 3 18 | ? SUM% 19 | 20 | ' Test address of data arrays 21 | DATA B%() = -0.125, 0.0625, 0.03125 22 | @SUM &B%, 3 23 | ? SUM% 24 | 25 | 26 | ' Test address of variables 27 | X%=1234.5 28 | @SUM &X%, 1 29 | ? SUM% 30 | 31 | ' Test access to individual data array values 32 | X%=B%(1) 33 | ? X% 34 | -------------------------------------------------------------------------------- /testsuite/tests/floatadr.chk: -------------------------------------------------------------------------------- 1 | Name: Test for using address of floating point vars 2 | Test: run-fp 3 | Output: 4 | 0.21875 5 | -0.03125 6 | 1234.5 7 | 0.0625 8 | -------------------------------------------------------------------------------- /testsuite/tests/fp-array.bas: -------------------------------------------------------------------------------- 1 | ' Test for floating point arrays 2 | ? "Start" 3 | dim A%(5), Fib%(300) 4 | 5 | Fib%(0) = 1 6 | Fib%(1) = 1 7 | for i=0 to 5 8 | A%(i) = i * 0.1 9 | next 10 | ? Fib%(0), A%(5) 11 | 12 | ' Calculate fibonacci sequence 13 | for i=2 to 300 14 | Fib%(i) = Fib%(i-1) + Fib%(i-2) 15 | next 16 | ? Fib%(300) 17 | ? adr(Fib%) - adr(A%) 18 | 19 | ' Also test DIM for normal float variables 20 | dim FV% 21 | ? FV% : FV%=1.25 : ? FV% 22 | -------------------------------------------------------------------------------- /testsuite/tests/fp-array.chk: -------------------------------------------------------------------------------- 1 | Name: Test floating point arrays 2 | Test: run-fp 3 | Output: 4 | Start 5 | 1 0.5 6 | 3.59579298E+62 7 | 36 8 | 0 9 | 1.25 10 | -------------------------------------------------------------------------------- /testsuite/tests/fp-fun.bas: -------------------------------------------------------------------------------- 1 | ' Test floating-point functions 2 | ? "Start" 3 | A%=0 4 | ? SGN(1.1) 5 | ? SGN(-1.1) 6 | ? SGN(-A%) 7 | ? EXP(0) 8 | ? LOG(1) 9 | ? LOG10(10) 10 | ? EXP10(1) 11 | ? ABS(-1.1) 12 | ? ABS(1.1) 13 | ? ABS(A%) 14 | ? ABS(-A%) 15 | ? SQR(100.0) 16 | ? SQR(16.0) 17 | ? SQR(81.0) 18 | ? "VAL" 19 | ? 0.0 + VAL("1.1") 20 | ? 0.0 + VAL("1E+10") 21 | ? 0.0 + VAL("-1E-10") 22 | RAD 23 | ? "RAD" 24 | ? ATN(0) 25 | ? INT(ATN(1) * 1000000 - 785398) 26 | ? INT(ATN(-1) * 1000000 + 785398) 27 | ? INT(ATN(2) * 1000000 - 1107149) 28 | ? SIN(0) 29 | ? INT(SIN(0.0001) * 1000000000 - 100000) 30 | ? INT(SIN(0.1) * 10000000 - 998334) 31 | ? INT(SIN(100) * 1000000 + 506366) 32 | ? COS(0) 33 | DEG 34 | ? "DEG" 35 | ? INT(ATN(1) * 1000000 - 45000000) 36 | ? INT(SIN(100) * 10000000 - 9848078) 37 | ? INT(COS(100) * 10000000 + 1736482) 38 | ' Parsing of FP print 39 | ? .1, 1.E1, (1E2) 40 | ' Parsing of FP comparison 41 | ? 1 < 1.1, 1.1 > 1 42 | 43 | -------------------------------------------------------------------------------- /testsuite/tests/fp-fun.chk: -------------------------------------------------------------------------------- 1 | Name: Test floating-point functions 2 | Test: run-fp 3 | Output: 4 | Start 5 | 1 6 | -1 7 | 0 8 | 1 9 | 0 10 | 1 11 | 10 12 | 1.1 13 | 1.1 14 | 0 15 | 0 16 | 10 17 | 4 18 | 9 19 | VAL 20 | 1.1 21 | 1E+10 22 | -1E-10 23 | RAD 24 | 0 25 | 0 26 | 0 27 | 0 28 | 0 29 | 0 30 | 0 31 | 0 32 | 1 33 | DEG 34 | 0 35 | 0 36 | 0 37 | 0.1 10 100 38 | 1 1 39 | -------------------------------------------------------------------------------- /testsuite/tests/fp-input.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "INPUT" 2 | ? "Start" 3 | input a% 4 | ? err(), a% 5 | input ; b% 6 | ? err(), b% 7 | input a% 8 | ? err() 9 | -------------------------------------------------------------------------------- /testsuite/tests/fp-input.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "INPUT" 2 | Test: run-fp 3 | Input: 4 | 1 5 | 2 6 | . 7 | Output: 8 | Start 9 | ?1 1 10 | 1 2 11 | ?18 12 | -------------------------------------------------------------------------------- /testsuite/tests/fpcomp.bas: -------------------------------------------------------------------------------- 1 | ' Test floating point comparisons 2 | ? "Start" 3 | 4 | for i=0 to 10 5 | x% = 0.1 * i 6 | ? x%, x% < 0.5 , x% <= 0.5 , x% = 0.5, x% >= 0.5 , x% > 0.5 7 | next i 8 | -------------------------------------------------------------------------------- /testsuite/tests/fpcomp.chk: -------------------------------------------------------------------------------- 1 | Name: Test floating-point comparisons 2 | Test: run-fp 3 | Output: 4 | Start 5 | 0 1 1 0 0 0 6 | 0.1 1 1 0 0 0 7 | 0.2 1 1 0 0 0 8 | 0.3 1 1 0 0 0 9 | 0.4 1 1 0 0 0 10 | 0.5 0 1 1 1 0 11 | 0.6 0 0 0 1 1 12 | 0.7 0 0 0 1 1 13 | 0.8 0 0 0 1 1 14 | 0.9 0 0 0 1 1 15 | 1 0 0 0 1 1 16 | -------------------------------------------------------------------------------- /testsuite/tests/fpint.bas: -------------------------------------------------------------------------------- 1 | 2 | a% = 0.1 : exec pconv 3 | a% = 0.5 : exec pconv 4 | a% = 123.499 : exec pconv 5 | a% = 123.500 : exec pconv 6 | a% = 32767.4999 : exec pconv 7 | a% = 32767.5000 : exec pconv 8 | 9 | proc pconv 10 | i1 = int(a%) : e1 = err() 11 | i2 = int(-a%) : e2 = err() 12 | ? a%, i1, e1, i2, e2 13 | endproc 14 | -------------------------------------------------------------------------------- /testsuite/tests/fpint.chk: -------------------------------------------------------------------------------- 1 | Name: Test FP to integer conversion 2 | Test: run-fp 3 | Output: 4 | 0.1 0 0 0 0 5 | 0.5 1 1 -1 1 6 | 123.499 123 1 -123 1 7 | 123.5 124 1 -124 1 8 | 32767.4999 32767 1 -32767 1 9 | 32767.5 -32768 3 -32768 3 10 | -------------------------------------------------------------------------------- /testsuite/tests/func-chr.bas: -------------------------------------------------------------------------------- 1 | ' Test for function "CHR$" 2 | ? "Start" 3 | ? " ->";CHR$(65);CHR$(66);CHR$(67);"<- " 4 | ? " ->";CHR$(65);CHR$(66),CHR$(67);"<- " 5 | A$=CHR$(65) 6 | ? A$="A", A$=CHR$(65), CHR$(65)=CHR$(65) 7 | ? A$="B", A$=CHR$(66), CHR$(65)=CHR$(66) 8 | -------------------------------------------------------------------------------- /testsuite/tests/func-chr.chk: -------------------------------------------------------------------------------- 1 | Name: Test function "CHR$" 2 | Test: run 3 | Output: 4 | Start 5 | ->ABC<- 6 | ->AB C<- 7 | 1 1 1 8 | 0 0 1 9 | -------------------------------------------------------------------------------- /testsuite/tests/index.bas: -------------------------------------------------------------------------------- 1 | 2 | A$="TEST.STRING INDEXING" 3 | 4 | ? A$[2] 5 | ? A$[2,10][3] 6 | ? A$[2,2][4] 7 | ? A$[2][3] 8 | 9 | ? A$ 10 | ? A$[1] 11 | ? A$[1,5] 12 | ? A$[2] 13 | ? A$[2,5] 14 | ? A$[10] 15 | ? A$[1,256] 16 | for i=-1 to 22 : ? i, ">"; A$[i] ; "<" : next i 17 | 18 | for i=1 to 22 : ? i, ">"; A$[i,2] ; "<" : next i 19 | 20 | for i=-1 to 22 : ? i, ">"; A$[2,i] ; "<" : next i 21 | 22 | for i=1 to 20 : ? i, i*i, str$(i*i)[2,1] : next i 23 | 24 | A$ = "Test Sub String"[6,3] 25 | ? ">";A$;"<" 26 | A$ = STR$(31415)[3,2] 27 | ? ">";A$;"<" 28 | 29 | A$="Hola" : ? A$ 30 | A$=+" y " : ? A$ 31 | A$ =+ "chao" : ? A$ 32 | 33 | for i=1 to 25 : A$ =+ "-abcde->" : A$ =+ STR$(i*i) : ? A$ : next i 34 | -------------------------------------------------------------------------------- /testsuite/tests/indexopt.bas: -------------------------------------------------------------------------------- 1 | 2 | A$="Hello World" 3 | 4 | ? A$ 5 | ? ASC(A$) = 65 6 | ? A$ 7 | 8 | X = 3 9 | 10 | ? 1 + X + 1 11 | ? X + 1 + 2 12 | 13 | for i=1 to LEN(A$) 14 | ? A$[i,1], PEEK(ADR(A$)+i), ASC(A$[i]), 15 | if i > 1 16 | ? ASC( A$[i-1][2] ) 17 | else 18 | ? 19 | endif 20 | next i 21 | 22 | for i=1 to LEN(A$) 23 | ? ASC( A$[i,1]) 24 | next i 25 | 26 | 27 | -------------------------------------------------------------------------------- /testsuite/tests/indexopt.chk: -------------------------------------------------------------------------------- 1 | Name: Check string index optimizations 2 | Test: run 3 | Output: 4 | Hello World 5 | 0 6 | Hello World 7 | 5 8 | 6 9 | H 72 72 10 | e 101 101 101 11 | l 108 108 108 12 | l 108 108 108 13 | o 111 111 111 14 | 32 32 32 15 | W 87 87 87 16 | o 111 111 111 17 | r 114 114 114 18 | l 108 108 108 19 | d 100 100 100 20 | 72 21 | 101 22 | 108 23 | 108 24 | 111 25 | 32 26 | 87 27 | 111 28 | 114 29 | 108 30 | 100 31 | -------------------------------------------------------------------------------- /testsuite/tests/longstr.bas: -------------------------------------------------------------------------------- 1 | A$="this is a really long string, with more that 250 bytes of length in the line.... abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 "" and even included quotes "", testing if parser can handle it. also, the editor should cope with this." 2 | ? A$ 3 | 4 | -------------------------------------------------------------------------------- /testsuite/tests/longstr.chk: -------------------------------------------------------------------------------- 1 | Name: Check for parsing of long strings 2 | Test: run 3 | Output: 4 | this is a really long string, with more that 250 bytes of length in the line.... abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 " and even included quotes ", testing if parser can handle it. also, the editor should cope with this. 5 | -------------------------------------------------------------------------------- /testsuite/tests/looperr.bas: -------------------------------------------------------------------------------- 1 | 2 | do 3 | ? "In loop" 4 | 5 | -------------------------------------------------------------------------------- /testsuite/tests/looperr.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of missing loop end 2 | Test: compile-error 3 | Error: no end loop/proc/if 4 | Error-pos: 5:0 5 | -------------------------------------------------------------------------------- /testsuite/tests/manyvars.chk: -------------------------------------------------------------------------------- 1 | Name: Test for more than 128 variables 2 | Test: run 3 | Output: 4 | Start 5 | 1000 1064 1127 1128 1160 1199 6 | 1161 7 | -------------------------------------------------------------------------------- /testsuite/tests/memerror.bas: -------------------------------------------------------------------------------- 1 | ' Test for out of memory error 2 | ? "Start" 3 | DIM X(15000) 4 | F = FRE() 5 | DIM A(F-2) BYTE 6 | ? "Ok" 7 | DIM B(0) BYTE 8 | 9 | -------------------------------------------------------------------------------- /testsuite/tests/memerror.chk: -------------------------------------------------------------------------------- 1 | Name: Test for out of memory error 2 | Test: run 3 | Output: 4 | Start 5 | Ok 6 | 7 | Memory Error 8 | -------------------------------------------------------------------------------- /testsuite/tests/misc-fp.bas: -------------------------------------------------------------------------------- 1 | ' Test miscellaneous floating-point functions 2 | ? "Start" 3 | A%=VAL("-0.123") : ? A% 4 | A%=VAL("1E+10") : ? A% 5 | A%=12.45 : B=INT(A%) : ? ERR(),B 6 | A%=12.50 : B=INT(A%) : ? ERR(),B 7 | A%=-12.45 : B=INT(A%) : ? ERR(),B 8 | A%=-12.50 : B=INT(A%) : ? ERR(),B 9 | A%=32767.0 : B=INT(A%) : ? ERR(),B 10 | A%=32767.5 : B=INT(A%) : ? ERR(),B 11 | A%=65535.5 : B=INT(A%) : ? ERR(),B 12 | 13 | A%=8E+97 : A% = A%+2E+97 : X%=0 : @check 14 | A%=2 : A% = A%^280 : X%=1.94266889E+84 : @check ' Valid 15 | A%=2 : A% = A%^329 : X%=0 : @check ' Overflow on square 16 | A%=5 : A% = A%^141 : X%=0 : @check ' Overflow on multiplication 17 | A%=2 : A% = A%^-30 : X%=9.31322574615E-10 : @check ' Valid small 18 | A%=2 : A% = A%^-326 : X%=0 : @check ' Underflow -> 0 19 | A%=2 : A% = A%^0 : X%=1 : @check ' One 20 | 21 | A%=2 : A% = SQR(A%) : X%=1.41421356237 : @check 22 | A%=-2 : A% = SQR(A%) : X%=-2 : @check 23 | A%=0 : A% = SQR(A%) : X%=0 : @check 24 | 25 | ' Many random numbers 26 | FOR I=0 TO 199 : A%=RND() : IF A%<0 OR A%>=1 THEN EXIT : NEXT 27 | ? I 28 | 29 | DEG 30 | A%=ATN(1) : X%=45 : @check 31 | A%=SIN(1) : X%=.01745240643728 : @check 32 | A%=SIN(-1) : X%=-.01745240643728 : @check 33 | A%=COS(1) : X%=.99984769515639 : @check 34 | A%=COS(-1) : X%=.99984769515639 : @check 35 | A%=COS(1E12) : X%=0 : @check ' Arg too big 36 | RAD 37 | A%=ATN(1) : X%=.78539816339 : @check 38 | A%=SIN(1) : X%=.841470984807896: @check 39 | A%=SIN(-1) : X%=-.841470984807896: @check 40 | A%=COS(1) : X%=.54030230586814 : @check 41 | A%=COS(-1) : X%=.54030230586814 : @check 42 | A%=COS(1234) : X%=-.798549 : @check 43 | 44 | 45 | 46 | 47 | PROC check 48 | ? ERR(), 49 | X% = (A% - X%)/X% 50 | IF X% < -0.000001 OR X% > 0.000001 51 | ? "BAD", A% 52 | ELSE 53 | ? "OK" 54 | ENDIF 55 | ENDPROC 56 | -------------------------------------------------------------------------------- /testsuite/tests/misc-fp.chk: -------------------------------------------------------------------------------- 1 | Name: Test miscellaneous floating-point functions 2 | Test: run-fp 3 | Output: 4 | Start 5 | -0.123 6 | 1E+10 7 | 1 12 8 | 1 13 9 | 1 -12 10 | 1 -13 11 | 1 32767 12 | 3 -32768 13 | 3 5376 14 | 3 BAD 1E+98 15 | 1 OK 16 | 3 BAD 1 17 | 3 BAD 1 18 | 1 OK 19 | 1 OK 20 | 1 OK 21 | 1 OK 22 | 3 OK 23 | 1 OK 24 | 200 25 | 1 OK 26 | 1 OK 27 | 1 OK 28 | 1 OK 29 | 1 OK 30 | 3 BAD 1.11111111E+10 31 | 1 OK 32 | 1 OK 33 | 1 OK 34 | 1 OK 35 | 1 OK 36 | 1 OK 37 | -------------------------------------------------------------------------------- /testsuite/tests/misc-int.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "" 2 | ? "Start" 3 | A=0 4 | ? SGN(A) 5 | A=123 6 | ? SGN(A) 7 | A=-512 8 | ? SGN(A) 9 | A=1234 10 | B=1234 11 | ? A/B 12 | A=-123 13 | B=5 14 | ? A/B, A MOD B 15 | A=123 16 | B=-5 17 | ? A/B, A MOD B 18 | A=0 19 | B=0 20 | ? A/B, A MOD B 21 | A=256 22 | B=255 23 | ? A/B, A MOD B 24 | A=VAL("66500") : B=ERR() 25 | ? A, B 26 | ' Test integer overflow conditions in comparisons: 27 | ? -20000 < 15000, -10000 < 15000, -20000 < -30000, -20000 < -15000 28 | ? 20000 < 15000, 10000 < 15000, 20000 < -30000, 20000 < -15000 29 | ? -20000 > 15000, -10000 > 15000, -20000 > -30000, -20000 > -15000 30 | ? 20000 > 15000, 10000 > 15000, 20000 > -30000, 20000 > -15000 31 | ' Test for strings > 128 characters into VAL 32 | S$="000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123400000000000000" 33 | ? VAL(S$) 34 | ? VAL("-0") 35 | A=3281 : B=2928 : ? A!B, A&B, A EXOR B 36 | -------------------------------------------------------------------------------- /testsuite/tests/misc-int.chk: -------------------------------------------------------------------------------- 1 | Name: Test miscellaneous integer functions 2 | Test: run 3 | Output: 4 | Start 5 | 0 6 | 1 7 | -1 8 | 1 9 | -24 -3 10 | -24 3 11 | -1 0 12 | 1 1 13 | 771 18 14 | 1 1 0 1 15 | 0 1 0 0 16 | 0 0 1 0 17 | 1 0 1 1 18 | 12340 19 | 0 20 | 4081 2128 1953 21 | -------------------------------------------------------------------------------- /testsuite/tests/mset.bas: -------------------------------------------------------------------------------- 1 | 2 | A$ = "Long string, filled with characters." 3 | ? A$ 4 | 5 | for i = 10 to 15 6 | mset Adr(A$) + i, 35 - 2 * i, i + Asc("A") - 10 7 | ? A$ 8 | next 9 | 10 | -------------------------------------------------------------------------------- /testsuite/tests/mset.chk: -------------------------------------------------------------------------------- 1 | Name: Test MSET statement 2 | Test: run 3 | Output: 4 | Long string, filled with characters. 5 | Long striAAAAAAAAAAAAAAA characters. 6 | Long striABBBBBBBBBBBBBA characters. 7 | Long striABCCCCCCCCCCCBA characters. 8 | Long striABCDDDDDDDDDCBA characters. 9 | Long striABCDEEEEEEEDCBA characters. 10 | Long striABCDEFFFFFEDCBA characters. 11 | -------------------------------------------------------------------------------- /testsuite/tests/operator.bas: -------------------------------------------------------------------------------- 1 | ' Test for logical AND/OR chaining 2 | ? "Start" 3 | 4 | ' First number is converted to boolean, second and third parameters are 5 | ' parsed from number to comparisons: 6 | ? 1 AND 1<2 AND 3<4 7 | ? 1 OR 1<2 AND 3<4 8 | ? 1 AND 1<2 OR 4<3 9 | 10 | -------------------------------------------------------------------------------- /testsuite/tests/operator.chk: -------------------------------------------------------------------------------- 1 | Name: Test for logical AND/OR chaining 2 | Test: run 3 | Output: 4 | Start 5 | 1 6 | 1 7 | 1 8 | -------------------------------------------------------------------------------- /testsuite/tests/opt-poke.bas: -------------------------------------------------------------------------------- 1 | ' Test optimizations on "POKE" and "DPOKE" statements 2 | ? "Start" 3 | 4 | ' Test using compile time constants, constant numbers 5 | ' are tested in stmt-poke.bas 6 | 7 | I=$34 8 | 9 | POKE @@TMPCHR, 10 : ? PEEK(@@TMPCHR) 10 | POKE @@TMPCHR, I : ? PEEK(@@TMPCHR) 11 | POKE @RUNAD, 10 : ? PEEK(@RUNAD) 12 | POKE @RUNAD, I : ? PEEK(@RUNAD) 13 | 14 | I=$5432 15 | DPOKE @@TMPCHR, 10 : ? DPEEK(@@TMPCHR) 16 | DPOKE @@TMPCHR, 500 : ? DPEEK(@@TMPCHR) 17 | DPOKE @@TMPCHR, I : ? DPEEK(@@TMPCHR) 18 | DPOKE @RUNAD, 10 : ? DPEEK(@RUNAD) 19 | DPOKE @RUNAD, 500 : ? DPEEK(@RUNAD) 20 | DPOKE @RUNAD, I : ? DPEEK(@RUNAD) 21 | 22 | -------------------------------------------------------------------------------- /testsuite/tests/opt-poke.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "POKE"/"DPOKE" 2 | Test: run-cross 3 | Output: 4 | Start 5 | 10 6 | 52 7 | 10 8 | 52 9 | 10 10 | 500 11 | 21554 12 | 10 13 | 500 14 | 21554 15 | -------------------------------------------------------------------------------- /testsuite/tests/parsehex.bas: -------------------------------------------------------------------------------- 1 | ' Parse some numbers 2 | ? $0 3 | ? $000000ABCD 4 | ? $FFFF 5 | ? $ 6 | 7 | -------------------------------------------------------------------------------- /testsuite/tests/parsehex.chk: -------------------------------------------------------------------------------- 1 | Name: Check parsing of HEX numbers 2 | Test: compile-error 3 | Error: parse error at line 5 column 3 4 | Error-pos: 5:3 5 | -------------------------------------------------------------------------------- /testsuite/tests/parsehex2.bas: -------------------------------------------------------------------------------- 1 | ' Parse more hex numbers 2 | ? $00000 3 | ? $10FFF 4 | 5 | -------------------------------------------------------------------------------- /testsuite/tests/parsehex2.chk: -------------------------------------------------------------------------------- 1 | Name: Check parsing of HEX numbers (2) 2 | Test: compile-error 3 | Error: parse error at line 3 column 3 4 | Error-pos: 3:3 5 | -------------------------------------------------------------------------------- /testsuite/tests/print-color.bas: -------------------------------------------------------------------------------- 1 | GR.1 2 | 3 | ? #6, 123 4 | ? #6, COLOR(32) 123 5 | ? #6, COLOR(128) 123 6 | ? #6, COLOR(160) 123 7 | 8 | ? #6, "HOLA" 9 | ? #6, COLOR(32) "HOLA" 10 | ? #6, COLOR(128) "HOLA" 11 | ? #6, COLOR(160) "HOLA" 12 | 13 | ? "NORMAL" TAB(4) COLOR(128) "INVERSE" COLOR(0) "." 14 | 15 | ? "NORMAL" COLOR(128) RTAB(20) "INVERSE" COLOR(0) "." 16 | 17 | ? 3, COLOR(32) "LOWERCASE" , "ALSO" , 18 | ? "NORMAL" 19 | 20 | ' Test small strings 21 | ? #6, "NORMAL "; COLOR(0); "X" 22 | ? #6, "COLOR32 "; COLOR(32); "X" 23 | ? #6, "NORMAL "; COLOR(0); "AB" 24 | ? #6, "COLOR32 "; COLOR(32); "AB" 25 | -------------------------------------------------------------------------------- /testsuite/tests/print-color.chk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/testsuite/tests/print-color.chk -------------------------------------------------------------------------------- /testsuite/tests/proc-line.bas: -------------------------------------------------------------------------------- 1 | ' Test PROC in same line with other code 2 | ? "Start" 3 | proc x: ? "x" : endproc : exec x : proc y : ? "y" : endproc : exec y 4 | 5 | -------------------------------------------------------------------------------- /testsuite/tests/proc-line.chk: -------------------------------------------------------------------------------- 1 | Name: Test PROC in same line as other statements 2 | Test: run 3 | Output: 4 | Start 5 | x 6 | y 7 | -------------------------------------------------------------------------------- /testsuite/tests/procerr.bas: -------------------------------------------------------------------------------- 1 | 2 | ? "Before" 3 | exec missing 4 | ? "After" 5 | 6 | -------------------------------------------------------------------------------- /testsuite/tests/procerr.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of missing PROC 2 | Test: compile-error 3 | Error: undef label 4 | -------------------------------------------------------------------------------- /testsuite/tests/procerr2.bas: -------------------------------------------------------------------------------- 1 | 2 | proc test1 3 | endproc 4 | 5 | 6 | proc test1 7 | endproc 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /testsuite/tests/procerr2.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of already defined PROC 2 | Test: compile-error 3 | Error: parse error at line 6 column 10 4 | Error-pos: 6:10 5 | -------------------------------------------------------------------------------- /testsuite/tests/procerr3.bas: -------------------------------------------------------------------------------- 1 | ' Define one DATA array 2 | DATA test1() = 1 3 | 4 | ' And try to define a PROC with the same name 5 | proc test1 6 | endproc 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /testsuite/tests/procerr3.chk: -------------------------------------------------------------------------------- 1 | Name: Check detection of PROC / DATA clash 2 | Test: compile-error 3 | Error: parse error at line 5 column 10 4 | Error-pos: 5:10 5 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-clr.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "CLR" 2 | ? "Start" 3 | 4 | n = 0 5 | f = fre() 6 | 7 | ' Dim inside a PROC to call multiple times 8 | proc dima 9 | ? "---- DIM "; n; " ----" 10 | ? "Before: "; f-fre() 11 | dim a(n) 12 | ? "After: "; f-fre() 13 | endproc 14 | 15 | n=10 : exec dima 16 | n=10 : exec dima 17 | 18 | ? "---- CLR ----" 19 | clr 20 | 21 | ? f, n, adr(a) 22 | 23 | f = fre() 24 | n=100 : exec dima 25 | 26 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-clr.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "CLR" 2 | Test: run 3 | Output: 4 | Start 5 | ---- DIM 10 ---- 6 | Before: 0 7 | After: 22 8 | ---- DIM 10 ---- 9 | Before: 22 10 | After: 44 11 | ---- CLR ---- 12 | 0 0 0 13 | ---- DIM 100 ---- 14 | Before: 0 15 | After: 202 16 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-cls.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "CLS" 2 | ? "Start" 3 | gr.1 4 | cls 5 | cls #6 6 | ? "Ok" 7 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-cls.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "CLS" 2 | Test: run 3 | Output: 4 | Start 5 | SCREEN: set graphics 1 with text window 6 | }SCREEN: plot 1,1 color 125 7 | Ok 8 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-data.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "DATA" 2 | ? "Start" 3 | 4 | data arr1() byte = 1,2,3,4,254,255,0, 5 | data byte = 123,134,65,$ff,$0A 6 | 7 | 8 | data arr2() word = -7,-5,-3,-1,0,7, 9 | data = 123,$5678,65535 10 | 11 | data arr3() = 1,2,3,4 12 | 13 | ? "1: "; arr1(0); 14 | for i=1 to 11 : ? ", "; arr1(i); : next 15 | ? : ? "2: "; arr2(0); 16 | for i=1 to 8 : ? ", "; arr2(i); : next 17 | 18 | a = adr(arr1) 19 | ? : ? "1: "; peek(a); 20 | for i=1 to 11 : a = a + 1 : ? ", "; peek(a); : next 21 | a = adr(arr2) 22 | ? : ? "2: "; dpeek(a); 23 | for i=1 to 8 : a = a + 2: ? ", "; dpeek(a); : next 24 | ? 25 | 26 | data arr4() b. = "String", arr1, "Code" 27 | ? $(ADR(arr4)) 28 | ? adr(arr1) - dpeek(ADR(arr4)+1+LEN($(ADR(arr4)))) 29 | 30 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-data.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "DATA" 2 | Test: run 3 | Output: 4 | Start 5 | 1: 1, 2, 3, 4, 254, 255, 0, 123, 134, 65, 255, 10 6 | 2: -7, -5, -3, -1, 0, 7, 123, 22136, -1 7 | 1: 1, 2, 3, 4, 254, 255, 0, 123, 134, 65, 255, 10 8 | 2: -7, -5, -3, -1, 0, 7, 123, 22136, -1 9 | String 10 | 0 11 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-deg.bas: -------------------------------------------------------------------------------- 1 | ' Test for statements "DEG" and "RAD" 2 | ? "Start" 3 | ? int(sin(1)*1000), int(cos(1)*1000) 4 | deg 5 | ? int(sin(1)*1000), int(cos(1)*1000) 6 | rad 7 | ? int(sin(1)*1000), int(cos(1)*1000) 8 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-deg.chk: -------------------------------------------------------------------------------- 1 | Name: Test statements "DEG" and "RAD" 2 | Test: run-fp 3 | Output: 4 | Start 5 | 841 540 6 | 17 1000 7 | 841 540 8 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-dli.bas: -------------------------------------------------------------------------------- 1 | ' Test for "DLI" statements 2 | ? "Start" 3 | 4 | DLI SET d1 = $24 INTO $D01A 5 | DLI SET d2 = $12 INTO $D018 INTO $D019 INTO $D01A 6 | DLI SET d3 = $12 INTO $D018 WSYNC INTO $D019 WSYNC WSYNC WSYNC INTO $D01A 7 | DLI SET d4 = $12 INTO $D018, $23 WSYNC INTO $D019 8 | 9 | DATA var() BYTE = 1, 2, 3, 4 10 | DLI SET d5 = var INTO $D01A 11 | DLI SET d6 = var WSYNC INTO $D01A 12 | DLI SET d7 = var INTO $D01A, 13 | DLI = $12 WSYNC INTO $D018 14 | 15 | ' Write contents of generated DLI machine code - should not change between versions 16 | for i=0 to 18 17 | ? d1(i);","; 18 | next 19 | ? 20 | for i=0 to 24 21 | ? d2(i);","; 22 | next 23 | ? 24 | for i=0 to 36 25 | ? d3(i);","; 26 | next 27 | ? 28 | 29 | ' Very bit DLI statement: 30 | DLI SET big = 1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1,2I.2,1I.1 31 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-dli.chk: -------------------------------------------------------------------------------- 1 | Name: Test "DLI" statements 2 | Test: run 3 | Output: 4 | Start 5 | 72,138,72,166,79,169,36,141,10,212,141,26,208,230,79,104,170,104,64, 6 | 72,138,72,166,79,169,18,141,10,212,141,24,208,141,25,208,141,26,208,230,79,104,170,104,64, 7 | 72,138,72,166,79,169,18,141,10,212,141,24,208,141,10,212,141,25,208,141,10,212,141,10,212,141,10,212,141,26,208,230,79,104,170,104,64, 8 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-getk.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "" 2 | ? "Start" 3 | get a 4 | get b 5 | get c 6 | e = err() 7 | ? "Get: "; a, b, c, e 8 | get a 9 | e = err() 10 | ? "Get: "; a, e 11 | get a 12 | e = err() 13 | ? "Get: "; a, e 14 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-getk.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "GET" from keyboard 2 | Test: run 3 | Input: 4 | ABC 5 | . 6 | Output: 7 | Start 8 | Get: 65 66 67 1 9 | Get: 155 1 10 | Get: 12 136 11 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-incdec.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "" 2 | ? "Start" 3 | A=3 4 | B=5 5 | inc a 6 | inc b 7 | ? a,b 8 | dec a 9 | inc b 10 | ? a,b 11 | dim arr1(2) 12 | arr1(0) = -1 13 | arr1(1) = 0 14 | arr1(2) = 1 15 | ? arr1(0), arr1(1), arr1(2) 16 | inc arr1(0) : inc arr1(1) : inc arr1(2) 17 | ? arr1(0), arr1(1), arr1(2) 18 | dec arr1(0) : dec arr1(1) : dec arr1(2) 19 | ? arr1(0), arr1(1), arr1(2) 20 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-incdec.chk: -------------------------------------------------------------------------------- 1 | Name: Test statements "INC" and "DEC" 2 | Test: run 3 | Output: 4 | Start 5 | 4 6 6 | 3 7 7 | -1 0 1 8 | 0 1 2 9 | -1 0 1 10 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-input.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "INPUT" 2 | ? "Start" 3 | input a 4 | ? err(), a 5 | input ; a 6 | ? err(), a 7 | input "Prompt:", a 8 | ? err(), a 9 | input a 10 | ? err(), a 11 | input a 12 | ? err(), a 13 | input a 14 | ? err(), a 15 | input s$ 16 | ? err(), s$ 17 | input s$ 18 | ? err(), s$ 19 | 20 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-input.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "INPUT" 2 | Test: run 3 | Input: 4 | 1234 5 | 2345 6 | 3456 7 | 8 | 65535 9 | 65536 10 | hello 11 | . 12 | Output: 13 | Start 14 | ?1 1234 15 | 1 2345 16 | Prompt: 1 3456 17 | ?18 0 18 | ?1 -1 19 | ?18 0 20 | ?1 hello 21 | ?136 22 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-locate.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "LOCATE" 2 | gr. 7 3 | ? "Start" 4 | color 1 5 | plot 10,10 6 | locate 0,0,a : ? a 7 | locate 10,10,a : ? a 8 | 9 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-locate.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "LOCATE" 2 | Test: run 3 | Output: 4 | SCREEN: set graphics 7 with text window 5 | Start 6 | SCREEN: plot 10,10 color 1 7 | SCREEN: locate 0,0 8 | 9 | 0 10 | SCREEN: locate 10,10 11 | 12 | 1 13 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-move.bas: -------------------------------------------------------------------------------- 1 | ' Test for statements "MOVE" and "-MOVE" 2 | ? "Start" 3 | s1$ = "initial string number 1, all lowercase" 4 | 5 | ' Nondestructive moves 6 | ? s1$ 7 | move adr(s1$)+8, adr(s1$)+5, 7 8 | ? s1$ 9 | -move adr(s1$)+5, adr(s1$)+8, 7 10 | ? s1$ 11 | 12 | ' Destructive moves 13 | s1$ = "initial string number 1, all lowercase" 14 | ? s1$ 15 | move adr(s1$)+5, adr(s1$)+8, 7 16 | ? s1$ 17 | s1$ = "initial string number 1, all lowercase" 18 | -move adr(s1$)+8, adr(s1$)+5, 7 19 | ? s1$ 20 | 21 | ' Fill big areas 22 | dim a(519) byte 23 | 24 | exec sum_a 25 | 26 | ' Test lengths about 256 / MOVE 27 | for x=249 to 260 28 | mset adr(a), 519, 0 29 | a(0) = 12 30 | move adr(a), adr(a)+1, x 31 | exec sum_a 32 | next 33 | 34 | ' Test special case in calculation of division by 255: 35 | for x=505 to 515 : a(x) = x-505 : next 36 | ? a(508);a(509);a(510);a(511);a(512) 37 | -move adr(a), adr(a)+1, 511 38 | ? a(508);a(509);a(510);a(511);a(512) 39 | 40 | ' Test addresses about 256 / MOVE 41 | ad = ((adr(a) + 265) & $FF00) - adr(a) 42 | for x=ad-3 to ad+3 43 | mset adr(a), 519, 0 44 | a(x+1) = 1 45 | move adr(a)+x, adr(a)+2+x, 32 46 | for i=ad-10 to ad+42 : ? a(i); : next 47 | ? 48 | next 49 | 50 | ' Test lengths about 256 / -MOVE 51 | for x=249 to 260 52 | mset adr(a), 519, 0 53 | a(x) = 12 54 | -move adr(a)+1, adr(a), x 55 | exec sum_a 56 | next 57 | 58 | ' Test addresses about 256 / -MOVE 59 | ad = ((adr(a) + 265) & $FF00) - adr(a) 60 | for x=ad-3 to ad+3 61 | mset adr(a), 519, 0 62 | a(x+33) = 1 63 | -move adr(a)+2+x, adr(a)+x, 32 64 | for i=ad-10 to ad+42 : ? a(i); : next 65 | ? 66 | next 67 | 68 | 69 | proc sum_a 70 | s = 0 71 | for i=0 to 519 72 | s = s + a(i) 73 | next 74 | ? s 75 | endproc 76 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-move.chk: -------------------------------------------------------------------------------- 1 | Name: Test statements "MOVE" and "-MOVE" 2 | Test: run 3 | Output: 4 | Start 5 | initial string number 1, all lowercase 6 | init stringing number 1, all lowercase 7 | init st string number 1, all lowercase 8 | initial string number 1, all lowercase 9 | initialialiali number 1, all lowercase 10 | initginginging number 1, all lowercase 11 | 0 12 | 3000 13 | 3012 14 | 3024 15 | 3036 16 | 3048 17 | 3060 18 | 3072 19 | 3084 20 | 3096 21 | 3108 22 | 3120 23 | 3132 24 | 34567 25 | 23457 26 | 00000000101010101010101010101010101010101000000000000 27 | 00000000010101010101010101010101010101010100000000000 28 | 00000000001010101010101010101010101010101010000000000 29 | 00000000000101010101010101010101010101010101000000000 30 | 00000000000010101010101010101010101010101010100000000 31 | 00000000000001010101010101010101010101010101010000000 32 | 00000000000000101010101010101010101010101010101000000 33 | 3000 34 | 3012 35 | 3024 36 | 3036 37 | 3048 38 | 3060 39 | 3072 40 | 3084 41 | 3096 42 | 3108 43 | 3120 44 | 3132 45 | 00000000101010101010101010101010101010101000000000000 46 | 00000000010101010101010101010101010101010100000000000 47 | 00000000001010101010101010101010101010101010000000000 48 | 00000000000101010101010101010101010101010101000000000 49 | 00000000000010101010101010101010101010101010100000000 50 | 00000000000001010101010101010101010101010101010000000 51 | 00000000000000101010101010101010101010101010101000000 52 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-poke.bas: -------------------------------------------------------------------------------- 1 | ' Test for "POKE" and "DPOKE" statements 2 | ? "Start" 3 | dim A(10), B(1) 4 | addr = Adr(A) 5 | 6 | B(0) = 12345 7 | for i=0 to 10 8 | dpoke addr+2*i, i*i 9 | next i 10 | 11 | for i=0 to 10 12 | ? A(i); " "; 13 | next i 14 | ? 15 | 16 | if B(0) <> 12345 17 | ? "corrupted B" 18 | endif 19 | 20 | xstr$="Test String" 21 | addr = Adr(xstr$) 22 | 23 | for i=1 to 10 24 | poke addr+i, 65 + i 25 | next i 26 | 27 | ? xstr$ 28 | 29 | ' Check POKE of constant numbers 30 | POKE 80, 1 31 | ? PEEK(80) 32 | POKE 1536, 2 33 | ? PEEK(1536) 34 | DPOKE 80, 1234 35 | ? DPEEK(80) 36 | DPOKE 1536, 1234 37 | ? DPEEK(1536) 38 | 39 | ' And also with variables 40 | I = $1234 41 | POKE 80, I : ? PEEK(80) : INC I 42 | DPOKE 80, I : ? DPEEK(80) : INC I 43 | POKE 1536, I : ? PEEK(1536) : INC I 44 | DPOKE 1536, I : ? DPEEK(1536) : INC I 45 | 46 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-poke.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "POKE"/"DPOKE" 2 | Test: run 3 | Output: 4 | Start 5 | 0 1 4 9 16 25 36 49 64 81 100 6 | BCDEFGHIJKg 7 | 1 8 | 2 9 | 1234 10 | 1234 11 | 52 12 | 4661 13 | 54 14 | 4663 15 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-print.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "PRINT" 2 | ? "Start" 3 | ' Tests print to I/O channel and return to channel 0 afterwards 4 | gr.1 5 | ? "->1" 6 | ? #6, 7 | ? "->2" 8 | ? #6,"a" 9 | ? "->3" 10 | ? #6,"b"; 11 | ? "->4" 12 | ? #6,"c", 13 | exec print1 14 | ? "->5" 15 | ' Test combinations of separators 16 | ? ,1,2;;;3;,;,4 17 | ? 18 | ? , 19 | ? ; 20 | ? "-" 21 | 22 | ? "A",1 23 | ? "AB",1 24 | ? "ABC",1 25 | ? "ABCD",1 26 | ? "ABCDE",1 27 | ? "ABCDEF",1 28 | ? "ABCDEFG",1 29 | ? "ABCDEFGH",1 30 | ? "ABCDEFGHI",1 31 | ? "ABCDEFGHIJ",1 32 | ? "ABCDEFGHIJK",1 33 | 34 | ? "A" tab(4) 1 35 | ? "AB" tab(4) 1 36 | ? "ABC" tab(4) 1 37 | ? "ABCD" tab(4) 1 38 | ? "ABCDE" tab(4) 1 39 | ? "ABCDEF" tab(4) 1 40 | ? "ABCDEFG" tab(4) 1 41 | ? "ABCDEFGH" tab(4) 1 42 | ? "ABCDEFGHI" tab(4) 1 43 | 44 | ? "A" rtab(4) 1 45 | ? "A" rtab(4) 12 46 | ? "A" rtab(4) 123 47 | ? "A" rtab(4) 1234 48 | ? "AB" rtab(4) 1 49 | ? "AB" rtab(4) 12 50 | ? "AB" rtab(4) 123 51 | ? "AB" rtab(4) 1234 52 | ? "ABC" rtab(4) 1 53 | ? "ABC" rtab(4) 12 54 | ? "ABC" rtab(4) 123 55 | ? "ABC" rtab(4) 1234 56 | ? "ABCD" rtab(4) 1 57 | ? "ABCD" rtab(4) 12 58 | ? "ABCD" rtab(4) 123 59 | ? "ABCD" rtab(4) 1234 60 | ? "ABCDE" rtab(4) 1 61 | ? "ABCDE" rtab(4) 12 62 | ? "ABCDE" rtab(4) 123 63 | ? "ABCDE" rtab(4) 1234 64 | ? "ABCDEF" rtab(4) 1 65 | ? "ABCDEF" rtab(4) 12 66 | ? "ABCDEF" rtab(4) 123 67 | ? "ABCDEF" rtab(4) 1234 68 | ? "ABCDEFG" rtab(4) 1 69 | ? "ABCDEFG" rtab(4) 12 70 | ? "ABCDEFG" rtab(4) 123 71 | ? "ABCDEFG" rtab(4) 1234 72 | ? "ABCDEFGH" rtab(4) 1 73 | ? "ABCDEFGH" rtab(4) 12 74 | ? "ABCDEFGH" rtab(4) 123 75 | ? "ABCDEFGH" rtab(4) 1234 76 | ? "ABCDEFGHI" rtab(4) 1 77 | ? "ABCDEFGHI" rtab(4) 12 78 | ? "ABCDEFGHI" rtab(4) 123 79 | ? "ABCDEFGHI" rtab(4) 1234 80 | ? "ABCDEFGHI" rtab(4) 12345 81 | ? "ABCDEFGHI" rtab(4) "123456" 82 | 83 | ? rtab(4) "x"; rtab(4) "yy"; 84 | ? "e" 85 | 86 | ' Test without separators (extension) 87 | ?1"-"2 88 | A=123 89 | ?1A 90 | ?"x"A"y" 91 | 92 | proc print1 93 | ? "in proc" 94 | endproc 95 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-print.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "PRINT" 2 | Test: run 3 | Output: 4 | Start 5 | SCREEN: set graphics 1 with text window 6 | ->1 7 | SCREEN: plot 0,2 color 155 8 | ->2 9 | SCREEN: plot 0,3 color 97 10 | SCREEN: plot 0,3 color 155 11 | ->3 12 | SCREEN: plot 0,4 color 98 13 | ->4 14 | SCREEN: plot 0,5 color 99 15 | SCREEN: plot 0,5 color 32 16 | SCREEN: plot 0,5 color 32 17 | SCREEN: plot 0,5 color 32 18 | SCREEN: plot 0,5 color 32 19 | SCREEN: plot 0,5 color 32 20 | SCREEN: plot 0,5 color 32 21 | SCREEN: plot 0,5 color 32 22 | SCREEN: plot 0,5 color 32 23 | SCREEN: plot 0,5 color 32 24 | SCREEN: plot 0,5 color 32 25 | in proc 26 | ->5 27 | 1 23 4 28 | 29 | - 30 | A 1 31 | AB 1 32 | ABC 1 33 | ABCD 1 34 | ABCDE 1 35 | ABCDEF 1 36 | ABCDEFG 1 37 | ABCDEFGH 1 38 | ABCDEFGHI 1 39 | ABCDEFGHIJ 1 40 | ABCDEFGHIJK 1 41 | A 1 42 | AB 1 43 | ABC 1 44 | ABCD 1 45 | ABCDE 1 46 | ABCDEF 1 47 | ABCDEFG 1 48 | ABCDEFGH 1 49 | ABCDEFGHI 1 50 | A 1 51 | A 12 52 | A 123 53 | A 1234 54 | AB 1 55 | AB 12 56 | AB 123 57 | AB 1234 58 | ABC 1 59 | ABC 12 60 | ABC 123 61 | ABC 1234 62 | ABCD 1 63 | ABCD 12 64 | ABCD 123 65 | ABCD 1234 66 | ABCDE 1 67 | ABCDE 12 68 | ABCDE 123 69 | ABCDE 1234 70 | ABCDEF 1 71 | ABCDEF 12 72 | ABCDEF 123 73 | ABCDEF 1234 74 | ABCDEFG 1 75 | ABCDEFG 12 76 | ABCDEFG 123 77 | ABCDEFG 1234 78 | ABCDEFGH 1 79 | ABCDEFGH 12 80 | ABCDEFGH 123 81 | ABCDEFGH 1234 82 | ABCDEFGHI 1 83 | ABCDEFGHI 12 84 | ABCDEFGHI 123 85 | ABCDEFGHI 1234 86 | ABCDEFGHI 12345 87 | ABCDEFGHI 123456 88 | x yye 89 | 1-2 90 | 1123 91 | x123y 92 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-setcolor.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "SETCOLOR" 2 | ? "Start" 3 | 4 | ' Simple tests, test optimizer 5 | setcolor 2,7,6 6 | ? peek($2C6) 7 | 8 | j = 0 9 | for col=0 to 4 10 | for i=col to 15 step 4 11 | ? col;" ";i;" ";j;": "; 12 | setcolor col, i, j 13 | ? peek($2C4+col) 14 | j = (j + 3) & 15 15 | next 16 | next 17 | 18 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-setcolor.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "SETCOLOR" 2 | Test: run 3 | Output: 4 | Start 5 | 118 6 | 0 0 0: 0 7 | 0 4 3: 67 8 | 0 8 6: 134 9 | 0 12 9: 201 10 | 1 1 12: 28 11 | 1 5 15: 95 12 | 1 9 2: 146 13 | 1 13 5: 213 14 | 2 2 8: 40 15 | 2 6 11: 107 16 | 2 10 14: 174 17 | 2 14 1: 225 18 | 3 3 4: 52 19 | 3 7 7: 119 20 | 3 11 10: 186 21 | 3 15 13: 253 22 | 4 4 0: 64 23 | 4 8 3: 131 24 | 4 12 6: 198 25 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-sio.bas: -------------------------------------------------------------------------------- 1 | ' Test SIO statement 2 | ? "Start" 3 | DIM buf1(128) byte, buf2(128) byte 4 | ' Write some data into buffer 5 | FOR i=0 TO 128 : buf1(i)=255-i : NEXT 6 | 7 | ' Try reading buf1 from sector 0 (invalid) 8 | SIO $31, 1, $52, 64, &buf1, 15, 128, 0, 0 9 | ? SERR() 10 | ' Write buf1 to emulated sector 719 11 | SIO $31, 1, $50, 128, &buf1, 15, 128, 719 & 255, 719/256 12 | ? SERR() 13 | ' Write buf2 to emulated sector 720 14 | SIO $31, 1, $50, 128, &buf2, 15, 128, 720 & 255, 720/256 15 | ? SERR() 16 | ' Read buf2 from emulated sector 719 17 | SIO $31, 1, $52, 64, &buf2, 15, 128, 719 & 255, 719/256 18 | ? SERR() 19 | ' Read buf1 from emulated sector 720 20 | SIO $31, 1, $52, 64, &buf1, 15, 128, 720 & 255, 720/256 21 | ? SERR() 22 | 23 | ' Check values of buf1 24 | ? "1:"; 25 | FOR i=0 TO 127 26 | If buf1(i) <> 0 27 | ? " "; i; "="; buf1(i); 28 | Endif 29 | NEXT 30 | ? 31 | 32 | ' Check values of buf2 33 | ? "2:"; 34 | FOR i=0 TO 127 35 | If buf2(i) <> 255-i 36 | ? " "; i; "="; buf2(i); 37 | Endif 38 | NEXT 39 | ? 40 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-sio.chk: -------------------------------------------------------------------------------- 1 | Name: Test SIO statement 2 | Test: run 3 | Output: 4 | Start 5 | 139 6 | 1 7 | 1 8 | 1 9 | 1 10 | 1: 11 | 2: 12 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-sound.bas: -------------------------------------------------------------------------------- 1 | ' Test for statement "SOUND" 2 | ? "Start" 3 | 4 | for i=0 to 30 5 | sound i & 3, i * 7, 10, i & 15 6 | ? i; " "; 7 | next i 8 | ? 9 | 10 | ' Sound off 1 channel 11 | for i=0 to 3 12 | sound i & 3 13 | ? "Off-"; i; " "; 14 | next i 15 | ? 16 | 17 | ' All off 18 | sound 19 | 20 | ? "Ok" 21 | 22 | -------------------------------------------------------------------------------- /testsuite/tests/stmt-sound.chk: -------------------------------------------------------------------------------- 1 | Name: Test statement "SOUND" 2 | Test: run 3 | Output: 4 | Start 5 | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 6 | Off-0 Off-1 Off-2 Off-3 7 | Ok 8 | -------------------------------------------------------------------------------- /testsuite/tests/strarr1.bas: -------------------------------------------------------------------------------- 1 | DIM ar$(99) 2 | ar$(10) = "Some Text" 3 | ar$(30) = "More Text" 4 | for i=0 to 99 5 | if ar$(i) <> "" 6 | ? i ; ":"; ar$(i) 7 | endif 8 | next i 9 | -------------------------------------------------------------------------------- /testsuite/tests/strarr1.chk: -------------------------------------------------------------------------------- 1 | Name: Check string array initialization 2 | Test: run 3 | Output: 4 | 10:Some Text 5 | 30:More Text 6 | -------------------------------------------------------------------------------- /testsuite/tests/strerror.bas: -------------------------------------------------------------------------------- 1 | 2 | ' Tests error in comparison of two sub-strings, 3 | ' as both uses the same memory area! 4 | A$="Dont Work" 5 | IF A$[2,2] = A$[3,3] THEN ? "ERROR - EXPECTED" 6 | 7 | B$=A$[2,2] 8 | IF B$ = A$[3,3] THEN ? "ERROR - UNEXPECTED" 9 | 10 | -------------------------------------------------------------------------------- /testsuite/tests/strerror.chk: -------------------------------------------------------------------------------- 1 | Name: Check for error in string comparison 2 | Test: run 3 | Output: 4 | ERROR - EXPECTED 5 | -------------------------------------------------------------------------------- /testsuite/tests/testif.bas: -------------------------------------------------------------------------------- 1 | ? "Test 1" 2 | a=1 3 | if a=0 4 | ? 0 5 | else 6 | ? "Test 2" 7 | endif 8 | ? "Test 3" 9 | if a=1 10 | ? "Test 4" 11 | else 12 | ? 0 13 | endif 14 | ? "Test 5" 15 | if a=1 16 | ? "Test 6" 17 | endif 18 | ? "Test 7" 19 | if a=0 20 | ? 0 21 | endif 22 | ? "Test 8" 23 | if a=0 then ? 2 24 | if a=1 then ? "Test 9" 25 | ' Test ELIF 26 | for a=10 to 14 27 | if a=10 28 | ? "Test 10" 29 | elif a=11 30 | ? "Test 11" 31 | elif a=12 32 | ? "Test 12" 33 | else 34 | ? "Test 13/14" 35 | endif 36 | next a 37 | ' Test ELIF 2 38 | for a=15 to 17 39 | if a=15 40 | ? "Test 15" 41 | elif a=16 42 | ? "Test 16" 43 | endif 44 | next a 45 | ? "Test "; 46 | if a=17 47 | ? "17" 48 | elif a=18 49 | ? "18" 50 | endif 51 | -------------------------------------------------------------------------------- /testsuite/tests/testif.chk: -------------------------------------------------------------------------------- 1 | Name: Test IF statements 2 | Test: run 3 | Output: 4 | Test 1 5 | Test 2 6 | Test 3 7 | Test 4 8 | Test 5 9 | Test 6 10 | Test 7 11 | Test 8 12 | Test 9 13 | Test 10 14 | Test 11 15 | Test 12 16 | Test 13/14 17 | Test 13/14 18 | Test 15 19 | Test 16 20 | Test 18 21 | -------------------------------------------------------------------------------- /testsuite/tests/testproc.bas: -------------------------------------------------------------------------------- 1 | ' Test PROC/EXEC 2 | 3 | ' Calls a PROC defined after use 4 | for i=0 to 10 5 | exec printLoop 6 | next i 7 | 8 | proc printLoop 9 | if i = 5 10 | ? "Skipping 5!" 11 | exit 12 | endif 13 | ? "Loop: "; i 14 | endproc 15 | 16 | ' Now, define PROC first 17 | proc before 18 | ? "-- test --" 19 | endproc 20 | 21 | exec before 22 | 23 | exec param 123, i * i * i 24 | 25 | ' Proc with a parameter 26 | proc param x y 27 | ? "X="; x 28 | ? "Y="; y 29 | endproc 30 | 31 | ' Proc with a parameter 32 | proc param3 x y z 33 | ? "P="; x, y, z 34 | endproc 35 | 36 | exec param3 1, 2, 3 37 | 38 | -------------------------------------------------------------------------------- /testsuite/tests/testproc.chk: -------------------------------------------------------------------------------- 1 | Name: Check PROC usage 2 | Test: run 3 | Output: 4 | Loop: 0 5 | Loop: 1 6 | Loop: 2 7 | Loop: 3 8 | Loop: 4 9 | Skipping 5! 10 | Loop: 6 11 | Loop: 7 12 | Loop: 8 13 | Loop: 9 14 | Loop: 10 15 | -- test -- 16 | X=123 17 | Y=1331 18 | P=1 2 3 19 | -------------------------------------------------------------------------------- /testsuite/tests/testusr.bas: -------------------------------------------------------------------------------- 1 | ' Example of USR calls 2 | 3 | ' Define a Machine Language routine: 4 | ' PLA / EOR $FF / TAX / PLA / EOR $FF / RTS 5 | data ml() byte = $68,$49,$FF,$AA,$68,$49,$FF,$60 6 | 7 | ' Calls the routine with different values 8 | for i=0 to 1000 step 100 9 | ? i, usr(adr(ml),i) 10 | next i 11 | 12 | -------------------------------------------------------------------------------- /testsuite/tests/testusr.chk: -------------------------------------------------------------------------------- 1 | Name: Check USR usage 2 | Test: run 3 | Output: 4 | 0 -1 5 | 100 -101 6 | 200 -201 7 | 300 -301 8 | 400 -401 9 | 500 -501 10 | 600 -601 11 | 700 -701 12 | 800 -801 13 | 900 -901 14 | 1000 -1001 15 | -------------------------------------------------------------------------------- /testsuite/tests/val.bas: -------------------------------------------------------------------------------- 1 | ? VAL("1234") , VAL("+1234") , VAL("-123") , VAL(" +1") , VAL("-33000") 2 | ? VAL("32768") , VAL("-1234") , VAL("+123") , VAL(" -1") , VAL("33000") 3 | ? VAL("99") , VAL("999") , VAL("9999") 4 | ? VAL("50") , VAL("512") , VAL("5120") 5 | ? VAL("64") , VAL("128") , VAL("256"), VAL("512"), VAL("1024"), VAL("2048"), VAL("4096"), VAL("8192"), VAL("16384"), VAL("32767") 6 | 7 | -------------------------------------------------------------------------------- /testsuite/tests/val.chk: -------------------------------------------------------------------------------- 1 | Name: Check integer VAL function 2 | Test: run 3 | Output: 4 | 1234 1234 -123 1 32536 5 | -32768 -1234 123 -1 -32536 6 | 99 999 9999 7 | 50 512 5120 8 | 64 128 256 512 1024 2048 4096 8192 16384 32767 9 | -------------------------------------------------------------------------------- /testsuite/tests/void.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmsc/fastbasic/19f41d41e527c1044dd99bc2a70cf82aa9148227/testsuite/tests/void.bas -------------------------------------------------------------------------------- /testsuite/tests/void.chk: -------------------------------------------------------------------------------- 1 | Name: Check empty program 2 | Test: run 3 | 4 | -------------------------------------------------------------------------------- /version.mk: -------------------------------------------------------------------------------- 1 | VERSION=4.8beta 2 | --------------------------------------------------------------------------------