I'm trying to write some programs from an old magazine that were specified to run on an ZX80/ZX81 but I'm using a Sinclair BASIC interpreter for the Spectrum.
Is there any significant changes in BASIC instructions for those computers?
Retrocomputing Stack Exchange is a question and answer site for vintage-computer hobbyists interested in restoring, preserving, and using the classic computer and gaming systems of yesteryear. It only takes a minute to sign up.Sign up to join this community
Spectrum BASIC is a superset of the earlier BASICs (all the colour commands, etc), so pedantically the answer to the question is the title of the post is "yes, there are significant differences".
However, if you're asking whether a earlier BASIC program can be run on the Spectrum, the answer is mostly yes. Possibly the most notable changes are:
PLOTworks differently on the earlier machines (where it functioned on a 64x44 grid) and the Spectrum (where it functioned on a 256x176 grid). If not corrected,
PLOTstatements will all end up in the bottom-left corner of the Spectrum's screen.
UNPLOTdoes not exist on the Spectrum; it can be emulated with
PLOT INVERSE 1or similar with the same caveats as for
SLOWmode (as it didn't use the Z80 to render the screen); just ignore those commands.
Zare contiguous ranges in both sets so a lot of stuff will work).
(X/4)*4) then you will need to scatter some
INTcalls in the ZX81/Spectrum code.
There was even a utility back in the day, ZX Slowloader, which emulated the ZX81's tape loading routine so ZX81 tapes could be loaded into the Spectrum.
The Spectrum's character set was based on 7-bit ASCII. The main printing sets (20-7F) are nearly pure ASCII, the only differences are that 60="
£" in Speccy, but "
`" in ASCII, likewise 7F is "
©" instead of DEL. My reference¹ shows 5C is "
/" whereas ASCII has "
\" but I think this may be a typo since 2F is also "
/". The Speccy did, however, use the first 32 codes and all codes after 80 for its own purposes. 0D is mapped to ENTER, which matches with ASCII's CR. 80-8F are block graphics, 90-A4 are user-defined graphics and A5 to FF are the tokenised commands for BASIC.
The ZX80's character set has no relation to ASCII:² 00→space, 01→null string, 02-0B→chunky graphics, 0C-1B→"
Z", 40-7F (undefined) 80-BF inverses of 00-3F, D4-FF→tokens and some more punctuation.
Unfortunately I have no reliable copy of the ZX81 mappings. I've found the character code tables for the ZX81 between 007E and 01FB in the ROM.³ As pointed out by Tommy in a comment below, they are similar not quite identical, eg "
<" is at 0x17 on a ZX80 but 0x12 in the ZX81 ROM.
Others have mentioned number representation: ZX80-integer only, ZX81-float only, Speccy-both. The ZX80 could not display a screen and calculate at the same time. The ZX81 had fast mode which was like the ZX80, and slow mode which used the NMI to interrupt calculations and display a screen before returning to calculate during frame fly-back. The Speccy used hardware to handle the screen.
¹Database Publications. The Complete Spectrum. Stockport: Database Publications, 1984. 004.165/SIN.
²Maunder, Bob, Terry Trotter, and Ian Logan. The ZX80 Companion. Second edition. Middlesbrough, England: Linsac, 1980. 004.165/SIN.
³Logan, I., and F. O’Hara. The Complete Timex TS1000 [and] Sinclair ZX81 ROM Disassembly. P.A. Cheddington, Leighton Buzzard, Bedfordshire: Melbourne House Publ, 1982. 005.265/SIN
Question is about translating ZX81 Basic to ZX Spectrum.
It's been about 40 years since I last did this from magazine listings, but the one thing that used to trip me up was not the bulk of the Basic listing but some POKEs and PEEKs. Or little bits of machine code to scroll screens or implement user defined characters etc, were common in ZX81 code
From memory, something like a peek of free RAM was different between the two, so that these didn't translate well without a cheatsheet of common peek/poke locations