http://sundry.wikispaces.com/octal-zero-prefix
I wonder if it's possible to add the reasons *why* B used a leading
zero.
Similarly, it looks like Thompson was first to use a leading zero in
this way but there may be other languages that predated B that did the
same. Perhaps those languages influenced B.
Anyone know more?
James
DEC PDP assembly language? It would make sense.
--
Chris Burrows
CFB Software
Armaide v2.1: ARM Oberon-07 Development System
http://www.armaide.com
> From a bit of checking I found that BCPL used a leading # for octal.
In the (original) BCPL manual we had at the time,
http://cm.bell-labs.com/cm/cs/who/dmr/bcpl.html
octal constants
were indicated in the typescript by an initial underlined 8. As we rendered
this in our in our compiler, octal numbers began with a #.
When Thompson did B, he chose to use a leading 0
instead, for reasons of his own.
Dennis
/BAH
OK thanks for the info.
James
> "James Harris" <james.h...@googlemail.com> wrote in message
> news:89a1b482-f0fd-4928...@s15g2000yqs.googlegroups.com...
>> Similarly, it looks like Thompson was first to use a leading zero in
>> this way but there may be other languages that predated B that did the
>> same. Perhaps those languages influenced B.
> DEC PDP assembly language? It would make sense.
No, those simply assume octal unless you specify decimal, so no marker for
either is necessary. You simply can't mix different radices on the same line
of code.
Now, in Macro-10/20, there *is* a marker for decimal numbers on a line, an
upparrow (later caret) followed by the letter "D" and the number. Thus, the
two lines of code following produce the same result:
movei 10,1750 ;RIP JSB
movei ^D8,^D1000 ;not nearly as entertaining a comment
though anyone who uses decimal accumulator numbers in Macro-20 code should be
horsewhipped in the public square.
Sometimes using decimal constants makes code much more readable.
--
Rich Alderson "You get what anybody gets. You get a lifetime."
ne...@alderson.users.panix.com --Death, of the Endless
>...
> Now, in Macro-10/20, there *is* a marker for decimal numbers on a line, an
> upparrow (later caret) followed by the letter "D" and the number. Thus, the
> two lines of code following produce the same result:
>
> movei 10,1750 ;RIP JSB
> movei ^D8,^D1000 ;not nearly as entertaining a comment
What! In the first line, you have to read the 1750 as *decimal* to make
sense of the comment!!
Cheers, Mike.
---------------------------------------------------------------
Mike Hore mike_h...@OVE.invalid.aapt.net.au
---------------------------------------------------------------
Huh? I wouldn't have thought of doing that in a gazillion years.
Don't tell me somebody actually did that.
>
> Sometimes using decimal constants makes code much more readable.
It also is a definitive method to show intent.
/BAH
It's a "numeric pun"...
--
+----------------------------------------+
| Charles and Francis Richmond |
| |
| plano dot net at aquaporin4 dot com |
+----------------------------------------+
...
> > > I wonder if it's possible to add the reasons *why* B used a leading
> > > zero.
>
> > > Similarly, it looks like Thompson was first to use a leading zero in
> > > this way but there may be other languages that predated B that did the
> > > same. Perhaps those languages influenced B.
>
> > In the (original) BCPL manual we had at the time,
> > http://cm.bell-labs.com/cm/cs/who/dmr/bcpl.html
> > octal constants
> > were indicated in the typescript by an initial underlined 8. As we rendered
> > this in our in our compiler, octal numbers began with a #.
>
> > When Thompson did B, he chose to use a leading 0
> > instead, for reasons of his own.
>
> OK thanks for the info.
If anyone's interested or is looking at this later, I've finally got
round to updating the page with the extra information.
http://sundry.wikispaces.com/octal-zero-prefix
James
I can push it back a little farther--Ken's assembler for the PDP-7 (before
B)
used the convention. The very original Unix was written in the
GE-635 macro-assembler using macros and cross-assembled;
as soon as possible he wrote his own assembler which did say
010 for 8. It doesn't look like GMAP (previously known as
GEMAP, previously known as GEM) did, though but I could
be wrong--I can't get the whole document about it.
Dennis
I don't suppose we can hope that this original source survived?
Ah - once we get to assembler level previous assumptions are void! I
remember the PDP-11 assembler assuming all numbers were octal by
default. At the time it didn't seem odd - except that, being an 8- and
16-bit machine I would have preferred hex. Base ten numbers were not
so important then. Funny how times have changed.
I found a manual for the GE machine
http://ed-thelen.org/comp-hist/GE-635.html
As shown in the manual the assembler uses a leading zero for octal.
(Interestingly there's no provision for hex literals.)
I'm not sure what GMAP, GEMAP, GEM are but if I understand correctly
Ken Thompson may have been influenced principally by the GE assembler
to adopt a leading zero - first for his PDP-7 assembler and later for
B.
Did it go something like this?
1964 - GE assembler used leading zero for octal
1969 or before - Ken's PDP-7 assembler uses leading zero
1969 - Unix uses leading zero (at least in some contexts, perhaps)
1971 - B uses leading zero
James
On the PDP-11, having the words chunk three bits per digit makes things
easier to read, since the arguments for most of the instructions are 3 bits
for mode, then 3 bits for register used, present in most of the instruction
formats, encode by three bits. So, for example, ADD -(R3),R0, if I see the
octal form, 064300, I immediately know it's arguments are source, mode 4 R3,
destination mode 0, R0. In hex, 68C0, takes a little more thinking to see
the mode & reg used of both args.
--
Lee K. Gleason N5ZMR
Control-G Consultants
lee.g...@comcast.net
> A zero would be easier to type than a #; no shifting involved.
My guess would have been that since 0 is a digit, this saved having to
use up an extra character to indicate that a number is octal, and it
could conceivably have saved a machine instruction or two in the code
to process integer constants.
John Savard