anchor.diff: -;;Setting up stuff with all the registers and shit
  -(defparameter *number-registers* 12)
  -
   ;;contains name of the register, consed with a number if subscript goes from 0 - n-1
   (defparameter *mnemonics*
     '((zero)
  
positive.code: 
  (defprocedure '/
    (format s "div ~{~a~^,  ~} ~%"  params )
       (format s "mflo ~a~%" output))
  
  (defprocedure '%
    (format s "div ~{~a~^,  ~} ~%"  params )
    (format s "mfhi ~a~%") output)
  
  
  (defun operator (expr)
    (first expr))
  
  (defun operands (expr)
    (rest expr))
  
  
  (defun primitive-procedure? (sym)
    (member sym *primitive-procedures*))
  
  
  
  (defun evaluate (expr env)
    (cond ((numberp expr) (temp-register-allot expr) )
  	((register-p expr) expr)
  	((listp expr)
  	 (apply! (operator expr) (list-of-values (operands expr) env)))))
  
  
  (defun apply! (funct params)
    "Takes a fuction and its parameters and converts to asm"
    (funcall (gethash funct *procedures*) params)
   )
  
  (defun list-of-values (operands env)
    (if (not operands)
        '()
        (cons
         (evaluate (first operands) env)
         (list-of-values (rest operands) env))))
  
  ;(format t "Given arguments are ~&~S~&" *args*)
  (defparameter *output* (make-array 0 
                  :element-type 'character 
                  :adjustable t 
                  :fill-pointer 0))
  	
  
  ;;Parser
  ;;parses into a list, PERFECT!
  
negative.code: ;;Can be rewritten using find
  
  (defun find-empty-t-register ()
    "find an empty register of type t"
    (dolist (reg *register-list*)
      (when (and (equal (register-type reg) '$t)
  	       (register-free? reg))
        (return reg))))
  
  (defun temp-register-allot (constant)
    "Temporarily allot a t register"
    (let ((a  (find-empty-t-register)))
      (with-output-to-string (stream *text*)
        (format stream "li ~a , ~a ~%" a constant))
      (setf (register-value a) constant
  	  (register-temp? a) t
  	  (register-free? a) nil)
      a))
  
  
  
  (defun var-register-allot (constant)
    "Allot a t register to a variable"
    (let ((a  (find-empty-t-register)))
      (with-output-to-string (stream *text*)
        (format stream "li ~a , ~a ~%" a constant))
      (setf (register-value a) constant
  	  (register-temp? a) nil
  	  (register-free? a) nil)
      a))
  
  
  ;;Convert into a macro for freeing register
  
  (defun free-temp-register (params)
    "Takes a list of registers and frees those which are temporary"
    (dolist (param params)
      (when (and param (register-temp? param))
        (setf (register-free? param) t))))
  
  
  (defun free-register-list (params)
    "Takes a list of registers and frees those which are temporary"
    (dolist (param params)
      (setf (register-free? param) t)))
  
  (defparameter *env* '())
  
  
  
  (defun make-frame (var-val-list)
    "var-val list is ((var value) (var value)). Value defaults to 0"
    (let ((frame '()))
      (dolist (var-val var-val-list)
        (if (listp var-val)
  	  (setf frame (acons (first var-val) (var-register-allot (second var-val))  frame))
  	  (setf frame (acons (first var-val) (var-register-allot 0)  frame ))))
      (format t "Frame to be added ~a ~%" frame)
      frame))
  
  (defun add-frame (var-val-list)
    (format t "Adding frame with vars ~a ~%" var-val-list)
    (push (make-frame var-val-list) *env*))
  
  (defun pop-frame ()
    (let ((register-list '()))
      (dolist ( var (first *env*))
        (push (cdr var) register-list))
      (free-register-list register-list)))
  
  (defparameter *procedures* (make-hash-table))
  
  
  
  
  
  
  (defmacro defprocedure (func &body body)
    "make primitive procedures"
    `(setf (gethash ,func *procedures*) (lambda (params)
  					(let ((output ( find-empty-t-register)))
  					  (with-output-to-string (s *text*)
  					    ,@body)
  					  (free-temp-register params)
  					  output)))
    )
  
  (defprocedure '+
  