;; i have a bunch of functions that work in a similar way to the below one
;; basically F is either bound to a single number F = 8L + R, or it is the
;; two numbers L and R.
;; further each operation has a default F that i would like to use if none has been provided
(defun ADD (M &rest F)
(multiple-value-bind (L R) (apply #'field F)
(let* ((m-word (memory-contents M))
(V (sub-instruction-as-in-load m-word L R))
(V-sign (WORD-SIGN V))
(rA *RA*)
(rA-sign (WORD-SIGN rA))
(result 0))
(if (equal POSITIVE V-sign)
(if (equal POSITIVE rA-sign)
(setf result (+ V rA))
(setf result (- V (negate rA))))
(if (equal POSITIVE rA-sign)
(setf result (- rA (negate V)))
(setf result (- (+ (negate V)
(negate rA))))))
(when (< result 0)
(setf result (- result))
(setf (WORD-SIGN result) NEGATIVE))
(when (= result 0)
(setf (WORD-SIGN result) rA-sign))
(setf *RA* result))))