[Simh] Writeup of PDP-11 bootstrap loader analysis

Johnny Billquist bqt at softjar.se
Thu Dec 24 08:04:58 EST 2015



On 2015-12-24 02:02, Will Senn wrote:
>
>
> On 12/23/15 5:09 PM, Johnny Billquist wrote:
>>
>> As for your analysis:
>> Your explanation of branches seems somewhat over complicated. The
>> instruction is indeed in just 8 bits, while 8 bits are the offset.
>> However, there is no need to mess things up with one-complement, or
>> tricks like that. The offset is an 8-bit value. Sign extend to 16
>> bits. Multiply by 2, and add to the updated PC. Simple as that.
>> (Note that I said "updated PC". The PC will contain the address of the
>> instruction after the branch before you start doing the calculation
>> for the branch destination.)
>>
> Johnny,
>
> Given Line 7 037760  100376               BPL WAIT
>
> 100376 is a BPL instruction and the offset (376) is to be multiplied by
> two and added to the updated PC. That is, 376 * 2 is going to be added
> to 037762. 376 represents a negative offset in two's complement notation
> - it has a one in it's most significant bit, the left hand bit in 11 111
> 110. As a human, I kind of need the number in some form that makes sense
> to me, so I convert it to a positive quantity by first taking the one's
> complement and adding one. This gives me the positive magnitude of the
> negative number -1. Multiplying this by two is easy, it's -2, which when
> added to 037762 yields 037760 , which is the correct location. This is
> how I did the math. If I understand you correctly, the machine doesn't
> do it this way. I tried multiplying 376, 11 111 110 by shifting left
> one, 11 111 100, and adding that to 037762's binary representation, but
> that doesn't seem to make sense. Would you please elaborate?


Sure.
376 in twos complement is -2. (Sign extended it will still be -2, but 
that will then be 177776)
Multiply that by 2 gives -4.

The branch is at address 37760. The updated PC will be 37762 after the 
branch instruction have been fetched by the CPU. So the branch will be 
to 37762 - 4, which is 37756.

	Johnny

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt at softjar.se             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


More information about the Simh mailing list