;;-*-mode:lisp;package:lambda;BASE:8.-*-
;;
;; (C) COPYRIGHT 1984 LISP MACHINE, INC
;;

;; some tests for spiffing up the sdu-translate-file capabilities.


(Eval-for-translation
  (defprop EXAMPLE\WRITE-DP-MODE "EWDPM" sdu-c-function)
  (defprop EXAMPLE\1 "E1" sdu-c-function)
  (defprop EXAMPLE\2 "E2" sdu-c-function)
  (defprop EXAMPLE\3 "E2" sdu-c-function)
  (defprop EXAMPLE\4 "E4" sdu-c-function)

  (defprop example\write-spy-reg-and-check "WspC" sdu-c-function)
  (defprop *bus-communication-instance* nil sdu-translate-time-value)
  (defprop read-spy-reg "rsp" sdu-c-function)
  (defprop spy-read "SPYR" sdu-c-function)
  (defprop spy-write "SPYW" sdu-c-function)

  (setq *output-main-prog? nil)
  )



(defun example\1 (a b c)
  (write-m-mem 1 a)		      
  (write-m-mem 2 b)
  (write-m-mem 3 c)
  (let ((z (read-m-mem 1)))
    (if (= z a)
	(format t "all ok~%")
	(format t "Got back ~O but expected ~O~%" z a))))

(defun example\2 (a b)
  (prog (j)
	(setq j 0)
     tag
	(write-m-mem j a)
	(write-m-mem (+ j j 4) b)
	(if (< j 10.) (go tag))))

(defun example\3 (a)
  (example\1 (example\2 a a) (if (= a 9) 7 3) a))

(DEFUN EXAMPLE\WRITE-DP-MODE (NUM)		
  (WRITE-SPY-REG-AND-CHECK (LOGAND 77 NUM))	;NOTE -- YOU CAN ONLY WRITE 6 BITS!!!
  (LAM-EXECUTE (WRITE)
	       LAM-IR-OP LAM-OP-ALU
	       LAM-IR-OB LAM-OB-ALU
	       LAM-IR-M-SRC LAM-M-SRC-SPY-REG
	       LAM-IR-ALUF LAM-ALU-SETM
	       LAM-IR-FUNC-DEST LAM-FUNC-DEST-DP-MODE))


(defun example\4 (x)
  (if (write-m-mem (read-m-mem 9) 10) (write-m-mem 1 2) (write-m-mem 3 4)))

(DEFUN EXAMPLE\WRITE-SPY-REG-AND-CHECK (DATA)
  (SPY-WRITE 17 DATA)
;  (FORMAT T "pausing to see if that helps")
  (LET ((TEM (READ-SPY-REG)))
    (COND ((NOT (= TEM (LOGAND 37777777777 DATA)))
	   (FERROR NIL "spy reg lost, wrote ~s read ~s" DATA TEM)))))




