qlwiki:supercharge

Supercharge

Sinclair QL SuperCharge by Digital Precision

Supercharge is the original QL SuperBASIC compiler from the 1980s. This was written by Simon Goodwin, with the Code Generator for SuperCharge being written by Gerry Jackson, author of SuperForth and marketed by Digital Precision Ltd.

The original version used a software protection system called Lenslok, which meant you had to look at symbols on the screen through a special Lens device and type in what you saw before you could use the program.

Programs compiled with SuperCharge could be distributed free of any royalties, although software houses were required to pay £250 for a site licence (in addition to the cost of the program itself).

Supercharge compiled the majority of SuperBASIC, producing fast executable programs. A later version of Supercharge, called Supercharge Special Edition was also produced. The Special Edition was basically the same program, but without the Lenslock protection used in the original.

According to the advertising, the standard PCW Benchmarks (as per PCW June 1984) showed the following speed improvements:

  • PCW Benchmark 1: SuperBASIC 2.1, SuperCharge (floating point) 0.2, SuperCharge (Integers) 0.06 seconds
  • PCW Benchmark 2: SuperBASIC 6.4, SuperCharge (floating point) 0.3, SuperCharge (Integers) 0.1 seconds
  • PCW Benchmark 3: SuperBASIC 10.7, SuperCharge (floating point) 1.2, SuperCharge (Integers) 0.3 seconds
  • PCW Benchmark 4: SuperBASIC 10.3, SuperCharge (floating point) 0.9, SuperCharge (Integers) 0.3 seconds
  • PCW Benchmark 5: SuperBASIC 13.2, SuperCharge (floating point) 1.0, SuperCharge (Integers) 0.3 seconds
  • PCW Benchmark 6: SuperBASIC 26.1, SuperCharge (floating point) 2.5, SuperCharge (Integers) 0.7 seconds
  • PCW Benchmark 7: SuperBASIC 61.8, SuperCharge (floating point) 4.1, SuperCharge (Integers) 1.0 seconds
  • PCW Benchmark 8: SuperBASIC 25.8, SuperCharge (floating point) 8.6, SuperCharge (Integers) n/a

Some programs compiled with Supercharge may not work on the more modern QL systems, which have differing memory layouts and so on, although some users have produced patches for some of these programs. Compiled programs usually needed a small set of compiler extensions to be included with the program (not linked into the program) to run, linked in by a simple RESPR/LBYTES/CALL or LRESPR command.

The code generator was later expanded greatly to be included in the Turbo compiler.

History of SuperCharge - taken from Simon Goodwin's webpage

"Soon after I finished the first version of Zip (A ZX BASIC compiler for the Sinclair ZX Spectrum) I returned to Aston University and needed to come up with a proposal for a final-year project. Having learned by that time that the only thing you can be sure of delivering on time is something you've finished already, but wanting to do something new and cool if I got the chance, and delve into the Motorola 68008 processor in Sinclair's new QL home computer, I proposed 'a compiler for Sinclair BASIC' as my project."

"With luck this could be a compiler for Sinclair SuperBASIC - the vastly improved, Comal-based interpreter programmed by Jan Jones and built into the QL's ROM, alongside Tony Tebby's Unix-influenced Qdos operating system - but if I got stuck, or busy with something or someone else (maybe even a girlfriend?) I reckoned I could fall back on ZIP and still earn the degree."

"Staff at Quicksilva obtained early Qdos documentation from Sinclair on my behalf, and I got a QL from the second batch at the end of May 1984, then another one which worked (the first lasted only 45 minutes) in June. I made steady progress, first writing code on my 128K microdrive-based system to read the tokenised program source from QL memory - then routines to parse the result and generate corresponding code in the form of calls to intermediate code and stack operations expressed in Reserve Polish Notation. This text output was written to microdrive tape and later - once I got onto Metacomco's Macro Assembler beta-test program - converted into 68000 machine code by expanding the text, via assembler macros. "

"This was enough to prove the symbols table and expression evaluation code, and get benchmarks compiled and running as standalone multi-tasking processes, but the generated code was far too verbose to give me any chance of making the compiled compiler fit on the machine. Like Zip, this was a four-pass compiler, working from tokenised source in the interpreter's memory. The first pass collected information about the whole source, to enable robust error checks later on. The second pass converted the source into an intermediate code and reported all errors. Only if that worked - and most programs submitted for compilation fail at this point - were two more passes used to translate the intermediate code and fix up cross-references to make a stand-alone code file. The use of compilation from memory made the extra pre-pass fast, and the separate code-generation phase simplified the design and allowed the machine code library to overlay the compiler, making best use of limited RAM and the microdrives - good for large block loads but slow for sequential filing. "

"The following spring a demo to my supervisor went well and that and the report earned me a first class honours for the project. By the time I graduated I was looking for a publisher, who could turn the compiler into a product as Quicksilva were no longer interested in the QL and in the throes of selling out to Argus Press."

"Freddy Vachha was setting up Digital Precision as a specialist QL publisher at the time, and set me up with a 720K CST 5.25" floppy disk system, 256K extra RAM from Simplex Data, and an advance which I immediately spent on the HiFi system I'd always wanted but never been able to afford…."

"It took another year to develop the academic project into a commercial product - QL Supercharge, £60 boxed with a 100 page manual (written in Scripsit on my Video Genie, printed with a Juki 6100 daisywheel printer). The compiler ran overnight for weeks, parsing itself in slow interpreted BASIC, usually to fall over in the small hours with some unanticipated problem. The aim was to get it to compile itself, and after weeks of trying it got all the way to the end and emitted a complete intermediate file. A few weeks later that assembled into an executable program. It took weeks more to get that to compile itself, and further weeks to get the compiled compiler to match the compiled compiled compiler! Compiler bootstrapping is not as simple, or as easy, as academics often make it seem. "

"To meet the challenge to get from intermediate to executable code, Freddy enlisted Ferranti CPU designer and Open University lecturer Gerry Jackson, author of SuperForth, DP's first QL compiler, to write a custom code-generator to take the place of the Metacomco assembler. In the process the design was refined to optimise the speed and size of the generated code. "

"Memory was tight - it had to run on a 128K computer with only microdrives, and fit the compiler, its source and intermediate code in RAM (buffered in screen memory for want of anywhere else) so the third and fourth passes only loaded, over the top of the parser, if the code was guaranteed correct. It compiled to an intermediate language which the code-generator could optimise and convert to either 16 bit threaded code (like Forth) or pure 68K code selectable on a per-line basis, and then generated a dynamically-built library to run the threading so the overhead of despatching between templates (16 bit code pointers) was only two instructions:"

 move.w (a5)+,d0
 jmp    0(a6,d0.w)

"Most of the machine-code from the macros could be encoded into a single 16 bit word, followed by any parameters (fetched with move (a5)+ from the threaded code stream) yet raw machine code could be inserted into the instruction stream at any point the maximum speed was essential, prefixed with jmp (a5) to switch out of threaded code, followed by reloading a5 and restarting the threaded code above when space was more important than speed. "

"Once Supercharge had compiled itself the overnight runs were reduced to about 20 minutes at first, then trimmed to nine minutes for the compiler to re-compile itself after optimisation of the code. The code itself shrank from about 80K of tokens to just 46.5K of compiled code, including the template library, threads and initialised data - leaving room for 30K of source and 9K of compile-time data on the unexpanded QL - the other 40K being taken up by the screen (32K, mostly used to buffer intermediate code during passes three and four) and the Qdos multi-tasking operating system structures and device linkage. "

"Supercharge was unveiled in an article in the October 1985 issue of QL User magazine and went on to earn a 'Sinclair User Classic' award and sold thousands of copies over the following couple of years. Some of these sales were gained - and doubtless some lost - by the revolutionary system of copy-protection built into the product - the infamous Lenslok. "

LensLok

"Lenslok, from ASAP Developments, consisted of a plastic holder for a transparent slatted lens which scrambled the image on screen over which it was placed, making nonsense of a normal bit-mapped display but shuffling a correctly pre-scrambled pattern into readable text. The user was required to read two characters through the lens and type them in at the start of each compiler run, to prove that they had a genuine copy of the compiler - or at least a copy of the lens, which was much harder to copy than the unprotected 100K microdrive tape on which Supercharge was shipped. "

"Lenslok became infamous that year when the programmers who bolted it onto the Spectrum version of 80s classic game Elite misread the instructions and generated a pattern which could not be read reliably, with or without the lens. The QL's floating point scaled graphics and high resolution meant that the Supercharge patterns were readable and readily compatible with various sizes of TV and monitor, though after a few days many users learned to shuffle the rows by eye and live without the lens. "

"Lenslok was very successful in dissuading commercial pirates from selling Supercharge, until some ingenious thieves in Belgium found a way to make the compiler defeat its own copy protection. The rip-off copies of Supercharge sold by Persoft Software in early 1986 came with a small program - itself compiled with Supercharge and hence able to multi-task alongside the compiler itself - which read the screen memory where the Lenslok pattern was displayed, re-ordered the data and displayed it alongside 'in clear'. "

"This was defeated by randomising the position and initial scale of the pattern in later versions of Supercharge. Eventually a version without the Lenslok code was produced, for a bundled deal with US QL distributors A+ Computer Response, but by that time Turbo, the inevitable follow-up product, was on its way…. "


Title: Supercharge SuperBASIC Compiler
Language: Self-Compiled from BASIC and 68000 Machine Code
Author: Simon Goodwin and Gerry Jackson
Publisher: Digital Precision Ltd
Year of Publication: 1985
Platforms Suitable for: All Sinclair QLs and emulators
Commercial Status: Unknown
Price in October 1985: £60
Reviewed: Sinclair User, March 1986
Sources Available from: n/a
Latest Version available from: n/a

  • qlwiki/supercharge.txt
  • Last modified: 2018/05/12 15:12
  • by normandunbar