(define program '( (loadI 10 R1) ;; here we load the desired values into registers (loadI 10 R2) (loadI 235 R3) (loadI 235 R4) (loadI 255 R5) (loadI 50 R6) (loadI 50 R7) (loadI 2 R8) ;; now we move the values to memory ;; which is the way a CPU communicates ;; with a graphics display device (store R1 M1) ; set x (store R2 M2) ; set y (store R3 M3) ; set w (store R4 M4) ; set h (store R5 M5) ; set r (store R6 M6) ; set g (store R7 M7) ; set b (store R8 M8) ; draw a filled rectangle of color (r,g,b), width w and height h, ; whose upper left corner is at position (x,y) ;; next we draw the top of the T ;; a rectangle starting at (20,20) ;; of width 40 and height 10 ;; we abbreviate this as follows ;; in our comments: (fillrect 20 20 40 10) (loadI 20 R1) ;; (fillrect 20 20 40 10) (store R1 M1) (store R1 M2) (loadI 40 R1) (store R1 M3) (loadI 10 R1) (store R1 M4) (loadI 255 R1) (store R1 M7) (loadI 2 R1) (store R1 M8) ;; here we draw the stem of the T ;; a rectangle starting at (35,20) ;; of width 10 and height 40 ;; we abbreviate this as follows: (loadI 35 R1) ;; (fillrect 35 20 10 40) (store R1 M1) (loadI 20 R1) (store R1 M2) (loadI 10 R1) (store R1 M3) (loadI 40 R1) (store R1 M4) (loadI 2 R1) (store R1 M8) (loadI 70 R1) ;; (fillrect 70 20 10 40) (store R1 M1) (loadI 20 R1) (store R1 M2) (loadI 10 R1) (store R1 M3) (loadI 40 R1) (store R1 M4) (loadI 2 R1) (store R1 M8) (loadI 100 R1) ;; (fillrect 100 20 10 40) (store R1 M1) (loadI 20 R1) (store R1 M2) (loadI 10 R1) (store R1 M3) (loadI 40 R1) (store R1 M4) (loadI 2 R1) (store R1 M8) (loadI 70 R1) ;; (fillrect 70 35 40 10) (store R1 M1) (loadI 35 R1) (store R1 M2) (loadI 40 R1) (store R1 M3) (loadI 10 R1) (store R1 M4) (loadI 2 R1) (store R1 M8) (loadI 4 R12) ;; R12 holds the current count of how many times the loop has gone (loadI 40 R10) ;; R10 is how much we add to the height (y=M2) and the green amt (M6) (loadI 1 R13) ;; R13 holds the constant 1, which we use when decrementing R12 loopstart ;; this starts the loop (load M2 R2) (add R2 R10 R2) (store R2 M2) ;; add 10 to M2 and store back in M2 (load M6 R6) (add R6 R10 R6) ;; add 10 to M6 (the green amount) (store R6 M6) ;; and store back in M6 (loadI 2 R8) (store R8 M8) ;; store 2 in M8, and so draw a box (sub R12 R13 R12) ;; subtract 1 from R12 (jumpLT R13 R12 loopstart) ;; jump back to the loop while 1 < R12 (halt) ) )