Basic Expression Algorithm
The basic algorithm for expressions is easy:
(defun genarith (x)
(if (atom x) ; if leaf,
(genload x (getreg)) ; load
(genop (op x) ; else op
(genarith (lhs x))
(genarith (rhs x))) ) )
>(genarith '(* (+ a b) 3)) LOAD A,R1 LOAD B,R2 ADD R1,R2 LOAD 3,R3 MUL R2,R3 R3