🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #1700

Re: PDP-1 tricks (was DECSYSTEM 20)

#1700
From: Ric Werme
Date: Wed, 26 Jul 1989 02:53
64 lines
3088 bytes
In article <30191@ucbvax.BERKELEY.EDU> muir@postgres.Berkeley.EDU (David Muir Sharnoff) writes:
>In article <3893@phri.UUCP> roy@phri.UUCP (Roy Smith) writes:
>>	I always wanted to try (I don't know why I never did) using
>>auto-decrement mode on r7 (i.e. the pc).  I wonder what would happen?
>
>How about ...
>
>	mov	-(pc), -(pc)

Whenever I wanted to wipe out memory on a PDP-11, I'd deposit this instruction
at the high end and hit start. If you didn't blink, you could watch the PC
run backward.


How about:
	jsr	pc,@pc
foo:	<subroutine>

which was a handy way to call foo twice with only an additional word of code.


One thing I did just for the shear perversity of it was to add a number
to the PC.  I had a routine that did a table lookup sine function.  I needed
to run an 11/20 (meaning I had integer add/sub, but nothing higher).  The
table had one entry per degree, but I wanted to interpolate down to 1/8
degree.  The table was 14 bit, fixed point data, so I came up with something
like:  (I wrote the original over 15 years ago, and my memory is fading, so
no flames if there's a bug here!)

	mov	r0,r1		;Copy angle (in 1/8ths degree) (e.g. 32 3/8)
	and	#177770,r1	;Isolate degrees (e.g 32)
	asr	r1		;Shift to use as index
	asr	r1
	mov	sine(r1),r2	;Get sine (e.g. sin(32))
	mov	sine+2(r1),r1	;Get next sine (e.g. sin(33))
	sub	r1,r2		;Get negative the distance between them
	asr	r2		;Divide by 8 for distance of 1/8th
	asr	r2
	asr	r2
	and	#7,r0		;Isolate 1/8ths to interpolate (e.g. 3/8)
	asl	r0		;Shift to size of sub r2,r1 instructions
	add	r0,pc		;Jump to right interpolation point
	add	r2,r1		;Interpolate by backing up
	add	r2,r1
	add	r2,r1
	add	r2,r1		;(e.g. here for 3/8)
	add	r2,r1
	add	r2,r1
	add	r2,r1
	add	r2,r1
	rts	pc		;Return sine in r1

I also tried writing it without the add to the PC, and came up with something
an instruction or two shorter, a pity, because this was the only use I ever
came up with for math to the PC.  Of course, I kept this version in the final
program!

Also - no flames for the questionable precision of the interpolation.  The
output was for a 1024x1024 vector display and the above code would give at
least 11 bits of accuracy and I only needed 10.-- 

| A pride of lions              | Eric J Werme                |
| A gaggle of geese             | uucp: decvax!linus!alliant  |
| An odd lot of programmers     | Phone: 603-673-3993         |
Technical Details
Message-ID: <3291@alliant.Alliant.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!usc!elroy.jpl.nasa.gov!ucla-cs!uci-ics!zardoz!tgate!ka3ovk!drilex!axiom!linus!alliant!werme
References: <3256@wpi.wpi.edu> <EGDORF.89Jul21195924@zaphod.lanl.gov> <443@anasaz.UUCP> <BRUCE.89Jul23155646@heather.pooh.com> <3893@phri.U

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!usc!elroy.jpl.nasa.gov!ucla-cs!uci-ics!zardoz!tgate!ka3ovk!drilex!axiom!linus!alliant!werme
From: werme@Alliant.COM (Ric Werme)
Newsgroups: comp.arch
Subject: Re: PDP-1 tricks (was DECSYSTEM 20)
Message-ID: <3291@alliant.Alliant.COM>
Date: 26 Jul 89 02:53:53 GMT
References: <3256@wpi.wpi.edu> <EGDORF.89Jul21195924@zaphod.lanl.gov> <443@anasaz.UUCP> <BRUCE.89Jul23155646@heather.pooh.com> <3893@phri.U
Reply-To: werme@alliant.Alliant.COM (Ric Werme)
Organization: Alliant Computer Systems, Littleton, MA
Lines: 64