Skip to content

a BASIC interpreter for CP/M and the RetroBrew SBC v2, based on the Z80 port of Palo Alto Tiny Basic

License

Notifications You must be signed in to change notification settings

dimitrit/tastybasic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tasty Basic

Introduction

Tasty Basic is a basic interpreter for CP/M and RomWBW (Warthen, 2021), based on the Z80 port of Palo Alto Tiny Basic (Gabbard, 2017; Rauskolb, 1976; Wang, 1976).

Tasty Basic Language

The Tasty Basic language is based on Palo Alto Tiny Basic, as described in the December 1976 issue of Interface Age (Rauskolb, 1976). As such, Tasty Basic shares many of the same limitations as Palo Alto Basic. All numbers are integers and must be less than or equal to 32767, and Tasty Basic supports only 26 variables denoted by letters A through Z.

In addition to Tiny Basic's ABS(n), RND(n) and SIZE functions, Tasty Basic also provides statements and functions to read and write memory locations, and allows interaction with I/O ports.

Statements

Tasty Basic provides two statements to write to memory and I/O ports:

POKE m,n Writes the value n to address location m

OUT m,n Sends the value n to I/O port m

Additionally there are statements to define and read constant values:

DATA m[,n[,...]] Used to store constant values in the program code. Each DATA statement can define one or more numeric constants separated by commas. DATA statements may appear anywhere in the program.

READ m Reads the next available data value and assigns it to variable m, starting with the first item in the first DATA statement.

RESTORE Resets the READ pointer to the first item of the data list, allowing DATA values to be re-read.

CP/M Specific Statements

The CP/M version includes two additional statements that allow Tasty Basic programs to be saved to, and loaded from, disk:

LOAD "filename" Loads the Tasty Basic (.TBA) file with the given filename from the current disk drive into memory. Any existing programs and variables are cleared before the program is loaded.

SAVE "filename" Persists the program currently in memory in a file with the given filename on the current disk drive.

Refer to Tasty Basic files for details of the .TBA file format.

Functions

Tasty Basic provides the following functions to read from and write to memory locations and I/O ports:

IN(m) Returns the byte value read from I/O port m

PEEK(m) Returns the byte value of address location m

USR(i) Accepts a numeric expression i , calls a user-defined machine language routine, and returns the resulting value.

User defined machine language routines

The USR(i) function enables interaction with user defined machine routines. The entry point for these routines is specified using a platform specific vector pointing to a default location as shown below. User defined code may be placed elsewhere in memory by updating the vector values. The value i is passed to the routine in the DE register, which must also contain the result on return.

Platform Vector location Default value
CP/M $0BFE/$0BFF $0C00
RomWBW $13FE/$13FF $1400

Example

The following example shows the bit summation for a given value:

  0000             #IFDEF CPM	
  0C00             	.ORG $0C00	; ie. 3072 dec
  0C00~            #ELSE
  0C00~            	.ORG $1400	; ie. 5120 dec
  0C00             #ENDIF
  0C00             
  0C00 06 00       	LD B,0
  0C02 7A          	LD A,D
  0C03 CD 0E 0C    	CALL COUNT
  0C06 7B          	LD A,E
  0C07 CD 0E 0C    	CALL COUNT
  0C0A 58          	LD E,B
  0C0B 16 00       	LD D,0
  0C0D C9          	RET
  0C0E             COUNT:
  0C0E B7          	OR A
  0C0F C8          	RET Z
  0C10 CB 47       	BIT 0,A
  0C12 28 01       	JR Z,NEXT
  0C14 04          	INC B
  0C15             NEXT:
  0C15 CB 3F       	SRL A
  0C17 18 F5       	JR COUNT
  0C19             
  0C19             	.END
10 REM -- CP/M VERSION
20 REM -- SEE EXAMPLES DIRECTORY FOR OTHER PLATFORMS
30 FOR I=0 TO 24
40 READ A
50 POKE 3072+I,A
60 NEXT I
70 INPUT P
80 LET Q=USR(P)
90 PRINT "THE BIT SUMMATION OF ",#5,P," IS ",#2,Q
100 GOTO 70
110 DATA 6,0,122,205,14,12,123,205,14,12,88,22,0,201
120 DATA 183,200,203,71,40,1,4,203,63,24,245

Note that the Tasty Basic program above is CP/M specific. Examples for other platforms can be found in the examples directory.

Building Tasty Basic

Building Tasty Basic requires the uz80as Z80 assembler v1.12 or later (Giner, 2021). Alternatively, Windows users can use TASM (Telemark Assembler) (Anderson, 1998).

RomWBW version

Tasty Basic is part of the SBCv2 RomWBW distribution. Please refer to the RomWBW github repository for details.

CP/M version

The CP/M version of Tasty Basic can be built using the -dCPM flag:

uz80as -dCPM tastybasic.asm tbasic.com

The resulting tbasic.com command file can be run in CP/M. For example:

B>TBASIC ↵

CP/M TASTY BASIC
28902 BYTES FREE

OK
>10 PRINT "HELLO WORLD ", ↵
>RUN ↵
HELLO WORLD 

OK
>BYE ↵

B>

Example BASIC programs

A small number of example Tasty Basic programs are included in the examples directory. Most of these programs are from BASIC COMPUTER GAMES (Ahl, 1978), and have been modified as required to make them work with Tasty Basic.

License

In line with Wang's (1976) original Tiny Basic source listing and later derived works by Rauskolb (1976) and Gabbard (2017), Tasty Basic is licensed under GPL v3. For license details refer to the enclosed LICENSE file.

References

Ahl, D. H. (Ed.).(1978). BASIC COMPUTER GAMES. New York, NY: Workman Publishing
Anderson, T. N. (1998). The Telemark Assembler (TASM) User's Manual, Version 3.1. Issaquah, WA: Squak Valley Software
b1ackmai1er (2018). SBC V2. Retrieved October 6, 2018, from https://www.retrobrewcomputers.org/doku.php?id=boards:sbc:sbc_v2:start
Gabbard, D. (2017, October 10). TinyBASIC for the z80 – TinyBASIC 2.0g. Retrieved September 29, 2108, from http://retrodepot.net/?p=274
Giner, J. (2021, August 1). Micro Z80 assembler - uz80as. Retrieved September 19, 2021, from https://jorgicor.niobe.org/uz80as/
Rauskolb, P. (1976, December). DR. WANG'S PALO ALTO TINY BASIC. Interface Age, (2)1, 92-108. Retrieved from https://archive.org/stream/InterfaceAge197612/Interface%20Age%201976-12#page/n93/mode/1up
Wang, L-C. (1976). Palo Alto Tiny BASIC. In J. C. Warren Jr. (Ed.), Dr. Dobb's Journal of COMPUTER Calisthenics & Orthodontia (pp. 129-142). Menlo Park, CA: People's Computer Company
Warthen, W. (2021). RomWBW, Z80/Z180 System Software. Retrieved Octover 5, 2021, from https://github.com/wwarthen/RomWBW

About

a BASIC interpreter for CP/M and the RetroBrew SBC v2, based on the Z80 port of Palo Alto Tiny Basic

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published