1

Currently I am reading the book: Lions_Commentary_on_UNIX_6th_Edition, together I am trying to understand the source code of unix v6, and I found some code intriguing: e.g.

. = 40^.
...
. = 60^.

This is some PDP-11 assembly which I am not very good at, so could anyone explain to me what did these codes try to do here? Also, in PDP-11, there is another symbol : "..", can anyone explain what does this symbol do , as well?

wangshuaijie
  • 1,821
  • 3
  • 21
  • 37

2 Answers2

1

The ^ operator returns the value of the first operand and the type of the second.

Hence .=40^. sets the location counter to location 40 in the current segment, which I expect would have been data or bss. A plain .=40 would try to set the location counter to absolute location 40 which would have been an error, since as didn't emit absolute code.

The .. symbol was the relocation counter, approximately, the location in memory where the program is loaded. It was a kludge for programs on early PDP-11's without relocation hardware. As I recall, the only thing anyone ever did with it was to set ..=something at the beginning of programs that were intended to be loaded at specific locations in core.

You can read the UNIX Assembler Reference Manual by Dennis Ritchie here in PDF.

Andriy Makukha
  • 7,580
  • 1
  • 38
  • 49
0

. is the location counter so assembly language statement is adjusting the position of the location counter by the the expressions 40^. or 60^. so the intent is to move the assembler location counter around.

If the statement read

. = 40 + .

it would mean change the location counter to 40 (octal) + the current value of the location counter. What confuses me is that the ^ is an unary operator that according to the MACRO11 manual I have doesn't make sense in this usage.

rmtheis
  • 5,992
  • 12
  • 61
  • 78
sillygoose
  • 151
  • 1
  • 4
  • The Lions book is talking about UNIX, so it uses the early UNIX assembly language, which is slightly different from PAL-11 and MACRO-11. See the [UNIX Assembler Reference Manual](http://www.tom-yam.or.jp/2238/ref/as.pdf) by Dennis Ritchie. – Andriy Makukha Jul 02 '19 at 04:28