Tony Duell wrote: [Context: MOV -(PC),-(PC) ] > Does that work on all models of PDP11?
No idea, I just know that it worked on Soviet 1801VM1, which is where I learned it. Meanwhile, I am still struggling with the second part of Paul's original challenge: > 2. Show a one-word PDP-11 program that clears all of memory, > in forward order, halting on completion. The problem statement says that the trick must *clear* all of memory, which I read as making it all zeros, rather than some other clobber pattern. The "halting on completion" part makes sense: 000000 is the opcode for HALT, hence if there is a magic instruction running in a loop at the end of memory that writes zeros moving forward, once this write of zeros hits the executing code, halt will occur. But I am still not able to come up with a single-word PDP-11 instruction that does these two functions simultaneously: (1) decrements PC so that the instruction keeps re-executing, and (2) writes zeros moving forward. Paul gave this hint: > Hint: you get to pick the initial values of the registers. I can easily think of something like this: MOV -(PC),(R0)+ But this one won't satisfy the requirement of writing zeros: it does a forward clobber, but writes 014720 (the opcode for this instruction) instead of zeros. I thought of refining it like this: BIC -(PC),(R0)+ This one gets a bit closer in that it will clear _some_ bits to zero in every memory word, but still, it is not a write of all zeros. Then I thought about the XOR instruction that appears in later PDP-11 models; something like: XOR R0,-(PC) If R0 is preset to 074047 (the opcode), the instruction will overwrite itself with 0 word (HALT), and then the halt will happen. But that's only one word, not clearing all of memory, and of course it would be even simpler with: CLR -(PC) Why is there a -(PC) operand in each of my attempts above? Because I don't see another way to make the instruction keep re-executing. If it weren't for this re-execution requirement, the solution would be as simple as CLR (R0)+ but of course that one will result in the CPU executing garbage following this instruction after clearing just one memory word - not interesting... If PDP-11 had 3-operand instructions like VAXen do, we could do an instruction that has -(PC) as one operand, a preset register as the second operand to the addition or XOR or whatever, and something like (R0)+ as the destination operand - but we are talking about PDP-11 here, not VAX, and the requirement is for a single-word instruction. Thus I do not see how a single PDP-11 instruction can accomplish what is asked here - unless I am misinterpreting the problem statement... M~
