;PROGRAM TO PERFORM 9 POINT SMOOTH WITH WEIGHTS 4,2,1 .TITLE SMOOTH .GLOBL SMOOTH SMOOTH: SAVREG TST (R5)+ ;skip argument count MOV (R5)+,R2 ;address of input array to R2 MOV (R5)+,R3 ;address of output array to R3 MOV #77,R1 ONE: MOV (R2)+,(R3)+ DEC R1 BEQ BLOCK1 ;branch when R1=0 JMP ONE BLOCK1: MOV #77,R1 BLOCK: DEC R1 BEQ END MOV (R2)+,(R3)+ ;copy pixels at edge of image MOV #76,R5 MOV (R2)+,(R3)+ NEXT: MOV (R2)+,R4 ;next array element to R4 CLC ROL R4 ;multiply by 2 CLC ROL R4 ;multiply by 2 MOV (R2),R0 ;move N+1 element to R0 ADD -4(R2),R0 ;add N-1 element to R0 ADD 176(R2),R0 ;add N+64 element ADD -202(R2),R0 ;add N-64 element ROL R0 ;multiply by 2 ADD R0,R4 ;add total to R4 ADD 200(R2),R4 ;add N+65 element ADD -204(R2),R4 ;N-65 element ADD 174(R2),R4 ;N+63 element ADD -200(R2),R4 ;N-63 element CLC ROR R4 ;divide by 16 CLC ROR R4 CLC ROR R4 CLC ROR R4 MOV R4,(R3)+ ;moves result to output array DEC R5 BEQ BLOCK ;branch to BLOCK when R5 is zero JMP NEXT ;read next array element END: MOV #101,R1 ;copy last 65 elements CONT: MOV (R2)+,(R3)+ DEC R1 BEQ RETURN ;branch when last pixel transferred JMP CONT RETURN: RSTREG RTS PC .END