Clear Core

cottrell at nbs-vms.ARPA cottrell at nbs-vms.ARPA
Tue Mar 5 11:03:37 AEST 1985


/*
>> Now, who remembers the one-instruction core clear?
>>
>>mov	-(pc),-(pc)	; .word	014747
>
>Ok, you got the easy one.  Now here's the harder version of the
>question.  Write a PDP-11 assembly language program that will set ALL
>of memory and all of the registers (except, possibly, for PC) to the
>value ZERO. I'll post an answer in a week or two if nobody gets it.

How about:

	clr	r0
	clr	r1
	...
	clr	sp
	mov	(pc)+, at sp	; copy next instruxion
	jsr	pc,-(pc)	; to loc 0
	jmp	@sp		; execute it

The one instruxion repeatedly executes itself, pushing the return
address (zero) onto the stack, first at 177776, all the way 
down to 000000. Core is cleared. Finally, the zero at location 000000
is executed, which is a halt. PC=2. That was fun!

	jim		cottrell at nbs
*/



More information about the Comp.unix.wizards mailing list