CPS 1 (Ramm) Spring 1995 12 April 1995 Quiz #11 Name _______________________ Section _____ -------------------------------------------------------------------------------- Derivation Rules -------------------------------------------------------------------------------- (1) 1 R3: 1 -> 2:=3 code(1) = code(3) COPY AX,M(3) COPY M(2),AX (2) 2:=3 R1: 2 -> Q M(2) = Q (3) Q:=3 R4: 3 -> (4+5) M(3) = CN1 code(3) = code(4) code(5) COPY AX, M(4) ADD AX, M(5) COPY M(3),AX (4) Q:=(4 + 5) R2: 4 -> 6 M(4) = M(6) code(4) = //nothing// (5) Q:=(6 + 5) R1: 6 -> R M(6) = R (6) Q:=(R + 5) R2: 5 -> 7 M(5) = M(7) code(5) = //nothing// (7) Q:=(R + 7) R1: 7 -> A M(7) = A (8) Q:=(R + A) -------------------------------------------------------------------------------- Using the rule instantiations shown above to derive Q := (R + A), generate the code for 1 step-by-step as shown in the text. The first two substitutions have been done and the next one suggested below: code(1) = code (3) by R3 line (1) COPY AX,M(3) COPY M(2), AX = code (3) by R1 line (2) COPY AX,M(3) COPY Q, AX = by R4 line (3)