On Friday, September 23, 2022 at 11:33:30 AM UTC-7, Spiros Bousbouras wrote:
> > and for the next colour: cur_col = (cur_col + 1) mod 3
> >
> > Sources available @ <
https://prino.neocities.org/zOS/zOS-Tools.html>
> If it were nothing more than that , the book would not have called it
> ingenious. Obviously it will have to fit with the rest of the algorithm
> without breaking the invariants which guarantee correctness. It also
> says "a single instruction". I don't think that
> cur_col = (cur_col + 1) mod 3
> can be implemented in a single instruction in common hardware.
(snip)
> [Hm, you're right, x+1 mod 3 is not a likely instruction. -John]
Maybe not common hardware today, but 50 years ago?
It would seem more likely on a machine with a word size a
multiple of 3, with 36 bit words not so rare 50 years ago.
The PDP-10 byte addressing instructions allow bytes
between 1 and 36 bits. I never learned all the tricks with them,
but if you use 12 bit bytes, the bit offset will cycle 0, 12, 24.
That is, you can sequentially address thirds of
the 36 bit words.
I did do PDP-10 assembly programming, but not quite enough
to learn all the tricks.
[I did a lot of PDP-8 and PDP-10 programming and I am pretty sure
there was no way to do x+1 mod 3 in a single instruction, not even
with tricky IDIVI with an indexed immediate operand. -John]