;; Homework 6 answers
;; Problem 1
LD R2,a ;; There seems to be an assumption
JSR PUSH ;; that R2 is used to pass value to POP
LD R2,b ;; STACK has [[ A B
JSR OpAdd ;; [[ (A+B)
LD R2,c
JSR PUSH ;; [[ (A+B) C
LD R2,d
JSR PUSH ;; [[ (A+B) C D
JSR OpAdd ;; [[ (A+B) (C+D)
JSR OpMult ;; [[ (A+B)*(C+D)
LD R2,e
JSR PUSH ;; [[ (A+B)*(C+D) E
JSR OpAdd ;; [[ (A+B)*(C+D)+E
JSR POP ;; [[
ST R2,r ;; Assume R2 receives the POPed value]
;; Problem 2
LDR R0,R5,#4 ;; R0 <- x
LDR R1,R5,#-3 ;; R1 <- y
ADD R0,R0,R1 ;; R0 <- x+y
STR R0,R5,#0 ;; z <- R0 or z <- x+y