-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.lisp
52 lines (43 loc) · 1.18 KB
/
debug.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(in-package :z80)
(defun spy (term)
(when logging-enabled
(format t "~A~%" term))
term)
(defun int-to-hex (&rest ints)
(format t "~{~X~^ ~}~%" ints))
(defun int-to-bin (&rest ints)
(format t "~{~B~^ ~}~%" ints))
(defmethod debug-cpu ((cpu cpu))
(dump-flags cpu))
(defun dump-registers-to-values (cpu)
(values (reg-a cpu)
(reg-b cpu)
(reg-c cpu)
(reg-d cpu)
(reg-e cpu)
(reg-h cpu)
(reg-l cpu)
(reg-f cpu)))
(defun dump-registers-to-list (cpu)
(list (reg-a cpu)
(reg-b cpu)
(reg-c cpu)
(reg-d cpu)
(reg-e cpu)
(reg-h cpu)
(reg-l cpu)
(reg-f cpu)
(mem-hl cpu)))
(defun dump-registers (cpu)
(format t "~{~{~2a ~^| ~}~%~}~%"
(list '("a" "b" "c" "d" "e" "h" "l" "f" "(hl)")
(dump-registers-to-list cpu))))
(defun dump-flags (cpu)
(format t "~{~{~3a ~^| ~}~%~}~%"
(list '("C" "Z" "P" "S" "N" "H")
(list (flag-c cpu)
(flag-z cpu)
(flag-p cpu)
(flag-s cpu)
(flag-n cpu)
(flag-h cpu)))))