Standard ROM entrypoints?

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
1024MAK
Manic Miner
Posts: 533
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Standard ROM entrypoints?

Post by 1024MAK » Fri Jul 20, 2018 3:46 pm

I think the point that may have been missed is this: the ZX80, ZX81 and ZX Spectrum did not, and do not have an operating system.

The ZX80 ROM is 4K bytes in size and contains BASIC and just enough code to process the keyboard and screen.
The ZX81 ROM is 8K bytes in size. The BASIC was developed from the ZX80 and is enhanced, but again, there is no OS.
Yep, same story with the ZX Spectrum. The ROM is 16k bytes in size. The intent at the time was to include code to handle the forthcoming microdrives (but instead ended up with some unused space). Again, the BASIC was developed from the ZX81 and is enhanced, but again, there is no OS.

Compare this with a Acorn BBC. This has a 16k OS ROM (approx 3/4 k byte is mapped out for the I/O hardware area). Plus one or more sideways ROMs (each up to 16k bytes) containing language(s), filing systems or other programs, one of which is the BASIC. The Master 128 can even be used without BASIC being active as it has a simple command line.

Of course, Z80 code can be made more compact compared to 6502 code. But even so, it's a big difference.

The print RESTART routine when fed with the correct data is the most useful routine, as it can output any character to the screen or the ZX printer. Read the BASIC manual to understand the control codes/control characters that BASIC can use.
In the ROM, there is also a keyboard reading routine. And there is the BASIC bleeper routine.

As alluded to above, the writers of the ROM were aiming for as much functionality as possible in 16k bytes, as that is apparently what Sir Clive wanted. Hence the ROM routines are slow. Hence machine code programmers preferred to write and read from the hardware directly.

The screen is a memory mapped bit-map. The only strange thing being the actual layout.

Apart from the 'unused' space and a couple of other areas which were altered in the 128k, +2, +2A, +2B, +3 and +3B, the 'original' ROM (often called the 48k ROM, even though it's exactly the same as the ROM in the 16k ZX Spectrum) is the same across all ZX Spectrums (there was ONLY one official ZX Spectrum ROM until the Spanish developed the 128k machine). So most useful routines stayed in the same place. In the 128k etc models, it's wise to ensure that this ROM image is mapped in rather than the editor ROM or disk OS ROM.

Mark
0 x

User avatar
Seven.FFF
Manic Miner
Posts: 341
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Standard ROM entrypoints?

Post by Seven.FFF » Fri Jul 20, 2018 5:54 pm

1024MAK wrote:
Fri Jul 20, 2018 3:46 pm
I think the point that may have been missed is this: the ZX80, ZX81 and ZX Spectrum did not, and do not have an operating system.
If you're ever tempted to think it did, you just have to look at the Acorn MOS to readjust your perspective :D

Garry Lancaster's NextZXOS is starting to turn +3eDOS into a useful operating system, with drivers and chained interrupts, and some system services.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

hjalfi
Berk
Posts: 28
Joined: Wed Jul 18, 2018 10:58 am

Re: Standard ROM entrypoints?

Post by hjalfi » Fri Jul 20, 2018 6:35 pm

Yeah, the Acorn MOS is a bit of an unfair comparison; having 16kB BASIC + 16kB OS was unheard of luxury back then (and went a long way to explaining why the BBC Micro was so special, and so expensive).

A better comparison is the Commodore 64. (Also supported by Cowgol! https://pbs.twimg.com/media/DOnxU7CWkAA6a5N.jpg:large) It managed to pack into 20kB an 8kB OS, 8kB standard Microsoft Basic and a whole 4kB of character generator ROM (256 characters compared to the Spectrum's 128). The kernel was pretty crummy --- it wasn't even spelt correctly! --- but it did provide a set of standard entrypoints for console I/O, accessing devices, etc. See http://sta.c64.org/cbm64krnfunc.html. And that's on the 6502, which has maybe 20% worse code density than the Z80 (ref: http://web.eece.maine.edu/~vweaver/pape ... iccd09.pdf).

It'd be totally possible to implement a similar system, complete with Basic, into the Spectrum's 16kB ROM. You could even fit a DOS there --- Microsoft Extended Basic was 8kB of fairly rubbish 8080 code, the CP/M portable kernel is 3.5kB, the CP/M BIOS for talking to the hardware is another 3.5kB, leaving a whole kilobyte left over...
1 x

AndyC
Manic Miner
Posts: 251
Joined: Mon Nov 13, 2017 5:12 am

Re: Standard ROM entrypoints?

Post by AndyC » Sat Jul 21, 2018 6:40 am

hjalfi wrote:
Fri Jul 20, 2018 6:35 pm
A better comparison is the Commodore 64. (Also supported by Cowgol! https://pbs.twimg.com/media/DOnxU7CWkAA6a5N.jpg:large) It managed to pack into 20kB an 8kB OS, 8kB standard Microsoft Basic and a whole 4kB of character generator ROM (256 characters compared to the Spectrum's 128). The kernel was pretty crummy --- it wasn't even spelt correctly! --- but it did provide a set of standard entrypoints for console I/O, accessing devices, etc. See http://sta.c64.org/cbm64krnfunc.html. And that's on the 6502, which has maybe 20% worse code density than the Z80 (ref: http://web.eece.maine.edu/~vweaver/pape ... iccd09.pdf).
True. Though not only is the kernel pretty crappy and limited, the BASIC implementation is massively lacking. Sinclair clearly wanted something the could show off the capabilities of their machine, particularly high res graphics and colour (remembering they're coming form the ZX81). Commodore on the other hand did the cheapest deal possible for a completely uncustomised version of Microsoft Basic (which was abnormal in and of itself, the usual process was to get Microsoft to extend it to cover machine capabilities).
0 x

Post Reply