The strange story of opcode "36" (Pascal S, CDC6600)

Pascal S is a weak subset of Pascal, good for learning how to write a compiler. The first implementation, by Wirth, was for the CDC6600 (it has since been ported) and includes the compiler and the bytecode interpreter. But it turns out that the implementation of one of the opcodes is simply broken on other architectures - it turns out there’s an assumption about the now-rather-unusual number formats of the CDC6600.

Here’s the full story, from Scott Moore:
http://www.standardpascaline.org/pascals.html

Unwilling to simply declare it to be a bug and fix it, I began to think about what I knew about the CDC 6000 series computer, and looking at some CDC 6600/6000 reference material. The CDC has a very unique floating point format. The CDC 6000 uses 60 bit words for both integer and floating point formats. In fact, a floating point number is essentially the mantissa, represented by a 60 bit signed integer, with the exponent stuck into the high order bits between bit 48 and bit 59. The exponent even is allowed to appear as the complement of itself so that it remains valid if the entire number is complemented (the CDC 6600 used 1’s complement numbers).

The result is that a negate instruction works equally well on both real and integer formats, on the CDC 6600 series computers.

Via Willard Goosey on mastodon:

Got an old Pascal S compiler to compile and run under RISC OS. Then I read about Pascal S on the web (the compiler helpfully includes no documentation) and discover that Pascal S is a toy subset of Pascal. No pointers, no file IO, or function parameters…

No wonder nobody bothered recompiling it for 32bit RISC OS…

But that’s OK because I learned a little about the history of Pascal. And about the … unique architecture of the CDC6600.

This is quite interesting, given how much Wirth was about portable code. Especially, provided the scope of this language, such a dependency must appear much like a bug. But then, there are those moments, when you just use such a feature. Maybe, a bit like a guilty pleasure. Or, maybe, you are totally convinced that everybody will notice and take note of this and maybe join the club of those admiring the inherent beauty of simplicity in those number formats. (See, no hoops to jump through, things may be that simple!) I guess, Wirth must have liked the CDC6600 quite a bit.

1 Like

The CDC 6600 (and its relatives in the 6000 and 7000 series) was a great processor. It was the first “supercomputer” and introduced a lot of the ideas used to speed processing in the new processors of the '70s through the '90s. (It was particularly influential on RISC architectures, and was itself a load-store rather than memory-data architecture, perhaps the first one in wide use.)

Ralph Grishman’s Assembly Language Programming for the Control Data 6000 and Cyber Series is great reading and very educational itself, and also provides essential background if you want to read J.E. Thornton’s Design of a Computer: The Control Data 6600, which will explain a lot about contemporary and modern computer architectures.

As for the Pascal S negation issue, that seems to me clearly a bug: even back then one should have known not to assume specifics of machine integer and floating point representations. (Perhaps even more so back then, when there were more representations in use.) I too am very surprised that Wirth would make that kind of mistake. Surprised enough that I, too, feel as if I must be missing something here.

1 Like

Thanks for the links!

1 Like