TITLE "MP3, Douglas Jones" ; recursively plots a fractal figure on the screen USE "hawk.macs" USE "monitor.h" S START EXT UNUSED SUBTITLE "PLOT routine" ; activation record of plot ;RETAD = 0 XLOW = 4 ; low x coordinate parameter XMID = 8 ; middle x coordinate XHIGH = 12 ; high x coordinate parameter YLOW = 16 ; low y coordinate parameter YMID = 20 ; middle y coordinate YHIGH = 24 ; high y coordinate parameter ARSIZE = 28 PLOT: ; plot a recursively defined gasket on the screen ; expects R3 - xlow, low x coordinate ; expects R4 - xhigh, high x coordinate ; expects R5 - ylow, low y coordinate ; expects R4 - yhigh, high y coordinate ; conforms to usual calling conventions STORES R1,R2 ADDI R2,R2,ARSIZE ; -- push ar STORE R3,R2,XLOW-ARSIZE ; -- save xlow STORE R4,R2,XHIGH-ARSIZE ; -- save xhigh ADD R3,R4,R3 SR R3,1 ; xmid = (xhigh + xlow)/2 STORE R3,R2,XMID-ARSIZE ; -- save xmid STORE R5,R2,YLOW-ARSIZE ; -- save ylow STORE R6,R2,YHIGH-ARSIZE ; -- save yhigh ADD R4,R6,R5 SR R4,1 ; ymid = (yhigh + ylow)/2 STORE R4,R2,YMID-ARSIZE ; -- save ymid LOAD R3,R2,XMID-ARSIZE ; -- restore xmid *** LOAD R4,R2,YMID-ARSIZE ; -- restore ymid *** LIL R1,DSPAT JSRS R1,R1 ; dspat( xmid, ymid ) LIS R3,"x" LIL R1,DSPCH JSRS R1,R1 ; dspch( 'x' ) LOAD R3,R2,XLOW-ARSIZE ; -- get xlow LOAD R4,R2,XMID-ARSIZE ; -- get xmid LOAD R5,R2,XHIGH-ARSIZE ; -- get xhigh CMP R3,R4 ; -- compare BGE PLOTQT ; if ((xlow < xmid) CMP R4,R5 ; -- compare BGE PLOTQT ; && (xmid < xhigh) LOAD R3,R2,YLOW-ARSIZE ; -- get ylow LOAD R4,R2,YMID-ARSIZE ; -- get ymid LOAD R5,R2,YHIGH-ARSIZE ; -- get yhigh CMP R3,R4 ; -- compare BGE PLOTQT ; && (ylow < ymid) CMP R4,R5 ; -- compare BGE PLOTQT ; && (ymid < yhigh)) { LOAD R3,R2,XLOW-ARSIZE ; -- get xlow LOAD R4,R2,XMID-ARSIZE ; -- get xmid ADDSI R4,-1 LOAD R5,R2,YLOW-ARSIZE ; -- get ylow LOAD R6,R2,YMID-ARSIZE ; -- get ymid ADDSI R6,-1 JSR R1,PLOT ; plot(xlow,xmid-1,ylow,ymid-1) LOAD R3,R2,XMID-ARSIZE ; -- get xmid ADDSI R3,1 LOAD R4,R2,XHIGH-ARSIZE ; -- get xhigh LOAD R5,R2,YLOW-ARSIZE ; -- get ylow LOAD R6,R2,YMID-ARSIZE ; -- get ymid ADDSI R6,-1 JSR R1,PLOT ; plot(xmid+1,xhigh,ylow,ymid-1) LOAD R3,R2,XLOW-ARSIZE ; -- get xlow LOAD R4,R2,XMID-ARSIZE ; -- get xmid ADDSI R4,-1 LOAD R5,R2,YMID-ARSIZE ; -- get ymid ADDSI R5,1 LOAD R6,R2,YHIGH-ARSIZE ; -- get yhigh JSR R1,PLOT ; plot(xlow,xmid-1,ymid+1,yhigh) LOAD R3,R2,XMID-ARSIZE ; -- get xmid ADDSI R3,1 LOAD R4,R2,XHIGH-ARSIZE ; -- get xhigh LOAD R5,R2,YMID-ARSIZE ; -- get ymid ADDSI R5,1 LOAD R6,R2,YHIGH-ARSIZE ; -- get yhigh JSR R1,PLOT ; plot(xmid+1,xhigh,ymid+1,yhigh) PLOTQT: ; } ADDI R2,R2,-ARSIZE ; -- pop ar LOADS R1,R2 JUMPS R1 ; return SUBTITLE "Main Program to call PLOT" START: LIL R2,UNUSED LIL R1,DSPINI JSRS R1,R1 ; returns R3=width, R4=height ADDI R6,R4,-1 ADDI R4,R3,-1 LIS R3,0 LIS R5,0 JSR R1,PLOT ; plot(0,width-1,0,height-1) LIL R1,EXIT JSRS R1,R1 END