C
Chris Dollin
(Increasingly off-topic, so this is the last post I'll
make in this thread about PDP-11s.)
That's not how I remembered it, so I checked, and neither of us is
completely wrong ...
Not /all/ the two-operand instructions had byte forms; in particular,
ADD and SUB and MUL and DIV didn't. (I learned PDP-11 assembler on
a machine with no MUL and DIV, in fact, and no XOR either I think.)
So arithmetic on bytes had to be done by putting them into words
(typically, but I suppose not necessarily, registers - there was of
course the stack to hand), and if you used MOVB, it sign-extended.
Except - INC and DEC had -B forms, so adding/subtracting 1 to a char
variable /could/ be done with INCB and DECB. But if that was part of
a conditional -- eg `if (++byte == 128)` -- then the code would have
to go the long way round anyway.
It's an interesting compromise behaviour, since if you do a (non-MOV)
byte operation on a register with bits set in the top byte it (apparently;
I didn't remember this, but bits of the web apparently do) leaves those
bits alone.
Yeah. BHI not BGT, etc ...
.... which I wasn't thinking of as "something special", but clearly it
is.
So you're "unsigned arithmetic" is my "unsigned comparison", and I
think we can be reconciled.
make in this thread about PDP-11s.)
Ancient_Hacker said:IIRC ALL the two-operand instructions had a bit that controlled whether
the instruction worked on words or bytes. So you had not only MOVB,
but ADDB, SUBB, XORB, CLRB, BISB, BICB, ROLB, etc.... all of which
operated on bytes, in memory or in the lower byte of a register.
That's not how I remembered it, so I checked, and neither of us is
completely wrong ...
Not /all/ the two-operand instructions had byte forms; in particular,
ADD and SUB and MUL and DIV didn't. (I learned PDP-11 assembler on
a machine with no MUL and DIV, in fact, and no XOR either I think.)
So arithmetic on bytes had to be done by putting them into words
(typically, but I suppose not necessarily, registers - there was of
course the stack to hand), and if you used MOVB, it sign-extended.
Except - INC and DEC had -B forms, so adding/subtracting 1 to a char
variable /could/ be done with INCB and DECB. But if that was part of
a conditional -- eg `if (++byte == 128)` -- then the code would have
to go the long way round anyway.
I
guess the reason I misspoke about "byte registers" is that the handy
little pocket-guide to PDP-11 instructions has the registers
partitioned in half. And they certainly behave as 8-bit registers if
you set that bit.
It's an interesting compromise behaviour, since if you do a (non-MOV)
byte operation on a register with bits set in the top byte it (apparently;
I didn't remember this, but bits of the web apparently do) leaves those
bits alone.
You're also correct in that there was no separate "unsigned arithmetic"
mode per se, you just had to interpret the sign and overflow states
differently when using unsigned numbers. This became a really big
deal once folks could afford more than 32K of memory-- I remember a lot
of address comparisons broke once addresses could go "negative".
Yeah. BHI not BGT, etc ...
.... which I wasn't thinking of as "something special", but clearly it
is.
So you're "unsigned arithmetic" is my "unsigned comparison", and I
think we can be reconciled.