4

I've been digging into the history of BCPL due to a question I was asked about the reasoning behind using the prefix "0x" for the representation hexadecimal numbers.

In my search I stumbled upon a really good explanation of the history behind this token. (Why are hexadecimal numbers prefixed with 0x?)

From this post, however, another questions sparked:

For octal constants, did BCPL use 8 <digit> (As per specs: http://cm.bell-labs.com/cm/cs/who/dmr/bcpl.pdf) or did it use #<digit> (As per http://rabbit.eng.miami.edu/info/bcpl_reference_manual.pdf) or were both of these syntaxes valid in different implementations of the language?

I've also been able to find a second answer here that used the # syntax which further intrigued me in the subject. (Why are leading zeroes used to represent octal numbers?)

Any historical insights are greatly appreciated.

4

1 回答 1

4

BCPL 中的语法有许多细微的变化。

例如,虽然我们使用的单元有 16 位单元(这样就可以从字地址(字地址是字节地址的一半)中x!y获得 16 位x + y,但我们还需要从字节地址中提取和字节值(因为我们主要在 6809 字节可寻址 CPU 上创建操作系统和控制软件)。

因此,除了:

x!y - get word from byte address (x + y) * 2

我们也有

x!%y - get byte from byte address (x * 2) + y
x%!y - get word from byte address x + (y * 2)
x%%y - get byte from byte address x + y

我很确定它们是特定于实现的,因为我从未在其他任何地方看到它们。早在语言标准像今天这样重要之前,BCPL 就已经存在了。

规范语言规范将是 Richards 编写该语言以来的早期规范(您的第二份文档是针对大约十年后的 Essex BCPL 实施)。但请记住,Project MAC 是最早的迭代 - 之后也有很多进步。

例如,2013 年修订的 BCPL 用户指南(参见Martin 的主页)指定#b,#o#x作为各种非十进制基数的前缀。

于 2013-11-19T05:02:01.237 回答