TRIPOS PDP-11 Assembler version 1.4


                                      ; @(#)follow.11	1.1 (mg@ukc) 4/9/88
                                      ; Follow light pen around with a blob

                                      ; Constants about machine.

              020000                  COREND	= 8.*1024.	; First unusable word
              002000                  WIDTH	= 1024.		; Height of display
              001400                  HEIGHT	= 768.		; Width of display

                                      ; Address of registers.

              172000                  DPC     = 172000        ; VT40 Program counter
              172002                  DSR     = 172002        ; VT40 Status register
              172004                  XSR     = 172004        ; X status register
              172006                  YSR     = 172006        ; Y status register

                                      ; Addresses of interrupt vectors
              000320                  STOPVEC = 320
              000324                  LPVEC	= 324

                                      ; Recommended mnemomics for Display processor instructions

              100000                  CHAR    = 100000        ; Character mode
              104000                  SHORTV  = 104000        ; Short vector mode
              110000                  LONGV   = 110000        ; Long vector mode
              114000                  POINT   = 114000        ; Point mode
              120000                  GRAPHX  = 120000        ; Graphplot X mode
              124000                  GRAPHY  = 124000        ; Graphplot Y mode
              130000                  RELATV  = 130000        ; Relative point mode

              002000                  INT0    = 2000          ; Intensity modes
              002200                  INT1    = 2200
              002400                  INT2    = 2400
              002600                  INT3    = 2600
              003000                  INT4    = 3000
              003200                  INT5    = 3200
              003400                  INT6    = 3400
              003600                  INT7    = 3600

              000100                  LPOFF   = 100           ; Light pen off
              000140                  LPON    = 140           ; and on

              000020                  BLKOFF  = 20            ; Blink off
              000030                  BLKON   = 30            ; and on

              000004                  LINE0   = 4             ; Solid line
              000005                  LINE1   = 5             ; Long dash
              000006                  LINE2   = 6             ; Short dash
              000007                  LINE3   = 7             ; Dot dash

              160000                  DJMP    = 160000        ; Display jump
              164000                  DNOP    = 164000        ; Display NOP

              170000                  STATSA  = 170000        ; Load status A
              173400                  DSTOP   = 173400        ; Display stop and interrupt

              001400                  SINON   = 1400          ; Stop interrupt on
              001000                  SINOFF  = 1000          ; Stop interrupt off
              000200                  LPLITE  = 200           ; Light pen hit on
              000300                  LPDARK  = 300           ; and off

              000040                  ITAL0   = 40            ; Italics off
              000060                  ITAL1   = 60            ; and on

              000004                  SYNC    = 4             ; Halt and resume in Sync

              174000                  STATSB  = 174000        ; Load status B
              000100                  INCR    = 100           ; Graphplot increment

              040000                  INTX    = 40000         ; Intensify vector or point
              001777                  MAXX    = 1777          ; Max delta-x
              001377                  MAXY    = 1377          ; Max delta-y

              020000                  MINUSX  = 20000         ; -ve delta-x
              020000                  MINUSY  = 20000         ; -ve delta-y

              017600                  MAXSX   = 17600         ; Max delta-x in short mode
              000077                  MAXSY   = 77            ; Max delta-y

              020000                  MISVX   = 20000         ; -ve delta-x
              000100                  MISVY   = 100           ; -ve delta-y

              000000'                         .PSECT

                                      ;       Simple PDP-11 program

      000000' 012706  017776          	MOV	#COREND-2,SP	; Set up stack

                                      	; set up interrupt vectors
      000004' 012737  000100' 000324  	MOV	#LPINTR,@#LPVEC	; light pen hit
      000012' 012737  000200  000326  	MOV	#200,@#LPVEC+2	; new priority = BR4 (exclude further DPU interrupts)

      000020' 012737  000142' 000320  	MOV	#STOPINTR,@#STOPVEC	; display proram stop
      000026' 012737  000200  000322  	MOV	#200,@#STOPVEC+2	; new priority = BR4

      000034' 005067  000032          	CLR	XACC
      000040' 005067  000030          	CLR	YACC
      000044' 005067  000026          	CLR	NHIT

                                      	; start it off
      000050' 012705  000300'         	MOV	#DLOOP,R5	; restart address
      000054' 012704  172000          	MOV	#DPC,R4		; cache addr of DPC
      000060' 012737  000276' 172000  	MOV	#DPROG,@#DPC

      000066' 000001                  IDLE:	WAIT		; and hang around
      000070' 000776                  	BR	IDLE

                                      	; Strategy: draw eight lines from around the current centre to the
                                      	; current centre point.  If the pen is pointing at the centre, this
                                      	; will cause 8 light pen hits per display.Add them up, divide by N,
                                       	; and this gives you the centre of the light pen hit area.

                                      	; total of x- and y-coords of light pen hits (up to eight hits)
      000072' 000001                  XACC:	.WORD	1
      000074' 000001                  YACC:	.WORD	1
      000076' 000001                  NHIT:	.WORD	1	; number of LP hits thie display

      000100'                         LPINTR:
                                      	; Find position of hit
      000100' 013700  172004          	MOV	@#XSR,R0
      000104' 013701  172006          	MOV	@#YSR,R1
                                      	; and start display processor again ASAP
      000110' 012714  000001          	MOV	#1,@R4

      000114' 042700  176000          	BIC	#176000,R0	; mask out the X position from bits 0..9
      000120' 060037  000072'         	ADD	R0,@#XACC

      000124' 042701  176000          	BIC	#176000,R1	; mask out the Y position from bits 0..9
      000130' 060137  000074'         	ADD	R1,@#YACC

      000134' 005237  000076'         	INC	@#NHIT

      000140' 000002                  	RTI

                                      ; all done.  should have got up to 8 light pen hits during a single display
      000142'                         STOPINTR:
      000142' 016701  177730          	MOV	NHIT,R1
      000146' 001422                  	BEQ	ENDINTR

      000150' 016700  177716          	MOV	XACC,R0
      000154' 004767  000040          	JSR	PC,DIVIDE
      000160' 010037  000302'         	MOV	R0,@#CX

      000164' 013700  000074'         	MOV	@#YACC,R0
      000170' 004767  000024          	JSR	PC,DIVIDE
      000174' 010037  000304'         	MOV	R0,@#CY

      000200' 005067  177666          	CLR	XACC
      000204' 005067  177664          	CLR	YACC
      000210' 005067  177662          	CLR	NHIT

      000214'                         ENDINTR:
      000214' 010514                  	MOV	R5,@R4	; continue
      000216' 000002                  	RTI


                                      	; R0 := R0 / R1, remainder in R2, R1 is positivised
                                      	; R0 is top, shifted into R2 one bit at a time.
                                      	; R3 is the loop counter.
      000220'                         DIVIDE:
      000220' 010246                  	MOV	R2,-(SP)
      000222' 010346                  	MOV	R3,-(SP)
      000224' 005701                  	TST	R1	; Validate divisor
      000226' 001421                  	BEQ	DIV0	; divide by 0!
      000230' 100001                  	BPL	DIV1
      000232' 005401                  	NEG	R1
      000234'                         DIV1:
      000234' 005002                  	CLR	R2
      000236' 012703  000017          	MOV	#15.,R3		; 16 iterations
      000242'                         DIV2:
      000242' 006300                  	ASL	R0
      000244' 006102                  	ROL	R2
      000246' 020201                  	CMP	R2,R1		; can we subtract bottom from top?
      000250' 103403                  	BCS	DIV3		; no
      000252' 160102                  	SUB	R1,R2		; yes - do it.
      000254' 052700  000001          	BIS	#1,R0
      000260' 005303                  DIV3:	DEC	R3
      000262' 100367                  	BPL	DIV2

      000264' 012603                  DIVEND:	MOV	(SP)+,R3
      000266' 012602                  	MOV	(SP)+,R2
      000270' 000207                  	RTS	PC

      000272'                         DIV0:	; divide by 0.  return 0. (any other ideas?)
      000272' 005000                  	CLR	R0
      000274' 000773                  	BR	DIVEND
                                      ; end of DIVIDE


      000276' 170200                  DPROG:	STATSA+LPLITE

                                      ; Values to change the position by one gooby
              004000                  DX	= 4000
              000020                  DY	= 20


      000300' 114140                  DLOOP:	POINT+LPON
      000302' 001000                  CX:	WIDTH/2		; start in the middle
      000304' 000600                  CY:	HEIGHT/2

                                      	; draw 8 radial lines
      000306' 107600                  	SHORTV+INT7
      000310' 170004                  	STATSA+SYNC		; to avoid too-quick refresh

      000312' 024040                  	MISVX+DX+DY+DY		; top left (-1,+2) ...
      000314' 044140                  	INTX+DX+MISVY+DY+DY	; ... and draw to centre

      000316' 004040                  	DX+DY+DY		; top right(+1,+2)
      000320' 064140                  	INTX+MISVX+DX+MISVY+DY+DY

      000322' 010020                  	DX+DX+DY		; right top (+2,+1)
      000324' 070120                  	INTX+MISVX+DX+DX+MISVY+DY

      000326' 010120                  	DX+DX+MISVY+DY		; right bottom (+2,-1)
      000330' 070020                  	INTX+MISVX+DX+DX+DY

      000332' 004140                  	DX+MISVY+DY+DY		; bottom right (+1,-2)
      000334' 064040                  	INTX+MISVX+DX+DY+DY
                                      	
      000336' 024140                  	MISVX+DX+MISVY+DY+DY	; bottom left (-1,-2)
      000340' 044040                  	INTX+DX+DY+DY

      000342' 030120                  	MISVX+DX+DX+MISVY+DY	; left bottom (-2,-1)
      000344' 050020                  	INTX+DX+DX+DY

      000346' 030020                  	MISVX+DX+DX+DY		; left top (-2,+1)
      000350' 050120                  	INTX+DX+DX+MISVY+DY

      000352' 173400                  	DSTOP

      000354' 160000                  	DJMP
      000356' 000300'                 	DLOOP

                                      	.END

No errors detected

Assembly statistics (words):

           Absolute   Relocatable
Code            0         120
Reloc. info     0          11

Space used for symbol table: 1105 words
Total workspace used: 1337 words
Assembly complete
