Search code examples
bcpl

In BCPL what does "of" do?


I am trying to understand some ancient code from a DEC PDP10 written in BCPL. A sample of the code is as follows:

                test scanner()=S.DOTNAME then
            $(  word1:=checklook.up(scan.info,S.SFUNC,"unknown Special function [:s]")
                D7 of temp:=P1 of word1
                scanner()
            $) or D7 of temp:=SF.ACTION

What do the "D7 of temp" and "P1 of word1" constructs do in this case?


Solution

  • The unstoppable Martin Richards is continuing to add features to the BCPL language(a), despite the fact that so few people are aware of it(b). Only seven or so questions are tagged bcpl on Stack Overflow but don't get me wrong: I liked this language and I have fond memories of using it back in the '80s.

    Some of the things added since the last time I used it are the sub-field operators SLCT and OF. As per the manual on Martin's own site:

    An expression of the form K OF E accesses a field of consecutive bits in memory. K must be a manifest constant equal to SLCT length:shift:offset and E must yield a pointer, p say.

    The field is contained entirely in the word at position p + offset. It has a bit length of length and is shift bits from the right hand end of the word. A length of zero is interpreted as the longest length possible consistent with shift and the word length of the implementation.

    Hence it's a more fine-grained way of accessing parts of memory than just the ! "dereference entire word" operator in that it allows you to get at specific bits within a word.


    (a) Including, apparently, a version for the Raspberry PI, which may finally give me an excuse to break out all those spare PIs I have lying around, and educate the kids about the "good old days".


    (b) It was used for at least one MC6809 embedded system I worked on, and formed a non-trivial part of AmigaDOS many moons ago.