Improved debug info output.
[ez.git] / ez.el
diff --git a/ez.el b/ez.el
index 1fb0f65..3948f4c 100644 (file)
--- a/ez.el
+++ b/ez.el
         new-s
       (binformat d new-s))))
 
+(defun ez-list-to-string-hex (l)
+  (concat "("
+          (when l
+            (concat
+             (format "%x" (car l))
+             (apply 'concat (mapcar (lambda (n) (format " %x" n)) (cdr l)))))
+          ")"))
+
 ;; Memory
 
 (defvar ez-memory nil
 (defun ez-set-var (var val)
   (cond
    ((= var 0)
+    (message "Pushed %x to stack" val)
     (ez-routine-stack-push val))
    ((< var 16)
+    (message "Saved %x to local variable %x" val var)
     (ez-set-local-var var val))
    (t
+    (message "Saved %x to global variable %x" val (- var 16))
     (ez-set-global-var (- var 16) val))))
 
 (defun ez-read-pc-var-and-inc ()
     (let ((table-row (assoc (list optype opcode) ez-op-table)))
       (unless table-row
         (error "Unsupported op PC:%x Optype:%s Opcode:%x Operands:%s Operand-types:%s"
-               instr-pc optype opcode operands operand-types))
+               instr-pc optype opcode (ez-list-to-string-hex operands) operand-types))
       (let ((mnemonic (elt table-row 1)))
         (message "PC:%x Optype:%s Opcode:%x Mnemonic:%s Operands:%s Operand-types:%s"
-                 instr-pc optype opcode mnemonic operands operand-types))
+                 instr-pc optype opcode mnemonic
+                 (ez-list-to-string-hex operands) operand-types))
       (funcall (elt table-row 2) operands operand-types))))
 
 (defun ez-read-var-operands-and-inc ()