SAM BASIC: Difference between revisions

Jump to navigation Jump to search
2,241 bytes added ,  14 June 2020
upperROM, vectors, RSTs and more links...
(Created page with "The '''SAM BASIC''' is an advanced and structured BASIC dialekt. It was written according the demand of the Miles Gordon Technology by Dr. ''Andrew Wright'' for the SAM...")
 
(upperROM, vectors, RSTs and more links...)
 
Line 1: Line 1:
The '''SAM BASIC''' is an advanced and structured BASIC dialekt. It was written according the demand of the [[Miles Gordon Technology]] by Dr. ''Andrew Wright'' for the [[SAM Coupé]] computer.
The '''SAM BASIC''' is an advanced and structured BASIC dialekt. It was written according the demand of the [[Miles Gordon Technology]] by Dr. ''Andrew Wright'' for the [[SAM Coupé]] computer.


At first glance it looks like and also its program editing enviroment, syntax of commands and even some system variables are identical to the [[ZX BASIC]] and [[BETA BASIC]]. Internally it is completely a new programming language, that supports the advanced features of the Coupé (especially graphics modes, colour palette and 64 or 85 characters per line), works with the entire basic memory of 512KB RAM, has 56 mathematical functions and provides hex and binary conversions.  
At first glance it looks like and also its program editing enviroment, syntax of commands and some system variables are identical to the [[ZX BASIC]] and [[BETA BASIC]]. Internally it is a new elaborate programming language, that supports the advanced features of the Coupé (especially graphics modes, colour palette and 64 or 85 characters per line), works with the entire basic memory of 512KB RAM, has 56 mathematical functions and provides hexadecimal and binary conversions.  


The SAM BASIC uses the computer's memory completely and effectively, has an allocation table of every 16KB memory page, respect a marked memory layout, fills memory pages with programs, procedures, functions, variables, arrays, graphics screens and system extensions and protects any part from being overwritten. This means, among other things, that SAM BASIC programs can be up to 480 Kbytes long, with individual string variables up to 65520 characters long and up to 65535 items in one dimension of data arrays.
The SAM BASIC uses the computer's memory completely and effectively, has an allocation table of every 16KB memory page, respect a marked memory layout, fills memory pages with programs, procedures, functions, variables, arrays, graphics screens and system extensions and protects any part from being overwritten. This means, among other things, that SAM BASIC programs can be up to 480 Kbytes long, with individual string variables up to 65520 characters long and up to 65535 items in one dimension of data arrays.
Line 7: Line 7:
The SAM BASIC paging system can be even extended to support more RAM, the maximum that the Coupé's hardware can control is 32 16KB pages.
The SAM BASIC paging system can be even extended to support more RAM, the maximum that the Coupé's hardware can control is 32 16KB pages.


The SAM BASIC takes 32KB in two separate ROM pages, main first page at 0000H and the second, switchable if needed, at C000H. The lower ROM is always paged in unless user-loaded software initiates complex paging operations. The lower ROM pages in the upper ROM as required, for example, to handle floating-point calculations, BEEP or tape operations.
This BASIC takes 32KB in two separate ROM pages, main first page at 0000H and the second, switchable if needed, at C000H. The lower ROM is always paged in unless user-loaded software initiates complex paging operations. The lower ROM pages in the upper ROM as required, for example, to handle floating-point calculations, BEEP or tape operations.


Z80 restarts addresses in the SAM BASIC ROM are partly similar to the ZX Spectrum
The speed of the SAM BASIC is a little slowed down because the ROM needs to hold, in permanently paged RAM, important variables like the PEN colour, screen MODE, the machine stack, information for interrupts, etc. That means that too much code cannot be run in the upper ROM, under the conditions of the Coupé's 32KB paging system. To get round this, some routines need to be copied from the upper ROM to a RAM buffer in the systempage  for execution, although their speed is not critical, the copying process obviously imposes a slight delay. Moreover, several routines are quite convoluted. The PRINT routines, for example, start in the lower ROM, use the upper ROM where this is feasible for the interpretation of characters, and then use the lower ROM again for actually putting data on the screen.
 
Z80 restarts addresses in the SAM BASIC ROM are partly similar to the ZX Spectrum:
* RST 00H - "start-up" code
* RST 00H - "start-up" code
* RST 08H - errors handling
* RST 08H - errors handling
Line 18: Line 20:
* RST 30H - CALL or JP to the upper ROM
* RST 30H - CALL or JP to the upper ROM
* RST 38H - maskable interrupt
* RST 38H - maskable interrupt
Standard SAM BASIC routines and whole commands can be extended or replaced easily, by changing some system variables, so-called VECTORS:
* NMIV - called when the BREAK button is pressed and normally points to an error handler, a temporary stack is provided (speccy emulators change this value to use it as a snapshot button)
* FRAMIV - called by the frame interrupt every 50th of a second
* LINIV  - called when the value in the line interrupt port (249) matches the line, Y-coordinate (any value greater than 191 to the port disables this interrupt)
* MIPV - MIDI input interrupt
* MOPV - MIDI output interrupt
* RST28V - called by the floating point calculator
* RST30V - a user RST for anything users like
* CMDV - called with A=code of character about to be executed or syntax checked (also to add new commands or provide some other actions for existing tokens)
* EVALUV  - called with A=current character in expression to evaluate (to add new functions)
* MTOKV - called if the ROM does not recognise a potential spelled-out keyword
* KURV - called before the BASIC editor's cursor is printed


The expansion named '''MasterBASIC''' brings some speed improvements, more comfortable program editing and tracing and an interrupt-driven video and sound capabilities.
The expansion named '''MasterBASIC''' brings some speed improvements, more comfortable program editing and tracing and an interrupt-driven video and sound capabilities.
Line 26: Line 41:
* [https://sam.speccy.cz/basic/sam-basic_complete_guide.pdf The complete guide to SAM BASIC]
* [https://sam.speccy.cz/basic/sam-basic_complete_guide.pdf The complete guide to SAM BASIC]
* [https://sam.speccy.cz/rom/sam_rom_v3-0_disasm_annotated.pdf SAM BASIC ROM v3.0 annotated]
* [https://sam.speccy.cz/rom/sam_rom_v3-0_disasm_annotated.pdf SAM BASIC ROM v3.0 annotated]
* [https://sam.speccy.cz/coding/mc-fred_05-29.7z Z80 programming tutorial], by Steve Taylor, for the FRED Magazine. Includes examples for Floating Point Calculator, VECTORs, BASIC ROM subroutines and how to add new commands to SAM BASIC etc.
* [https://sam.speccy.cz/systech/sam-coupe_tech-man_v3-0.pdf SAM Coupé Technical Manual v3.0]
* [https://sam.speccy.cz/basic/master-basic_use-man.pdf MasterBASIC User Manual]
* [https://sam.speccy.cz/basic/master-basic_use-man.pdf MasterBASIC User Manual]
* [https://worldofsam.org/ World of SAM]
* [https://worldofsam.org/ World of SAM]
44

edits

Navigation menu