Fix instruction redefinition and add some opcodes
This commit is contained in:
parent
184d0324c0
commit
9d2d0dea6b
1 changed files with 27 additions and 25 deletions
|
@ -85,16 +85,19 @@
|
||||||
`(progn
|
`(progn
|
||||||
(defclass ,base-name (instruction)
|
(defclass ,base-name (instruction)
|
||||||
((%mnemonic :allocation :class :initform ',mnemonic)))
|
((%mnemonic :allocation :class :initform ',mnemonic)))
|
||||||
|
(setf (slot-value (make-instance ',base-name) '%mnemonic) ',mnemonic)
|
||||||
,@(loop :for (mode code) :in modes-and-codes
|
,@(loop :for (mode code) :in modes-and-codes
|
||||||
:collect `(defclass ,(intern (format nil "INST-~A-~A"
|
:for class-name := (intern (format nil "INST-~A-~A" name mode))
|
||||||
name mode))
|
:collect `(progn
|
||||||
,(append
|
(defclass ,class-name
|
||||||
`(,base-name
|
,(append
|
||||||
,(addressing-mode-to-class-name mode)
|
`(,base-name
|
||||||
complete-mixin)
|
,(addressing-mode-to-class-name mode)
|
||||||
(when branching-p
|
complete-instruction-mixin)
|
||||||
'(branching-mixin)))
|
(when branching-p
|
||||||
((%opcode :allocation :class :initform ,code)))))))
|
'(branching-mixin)))
|
||||||
|
((%opcode :allocation :class :initform ,code)))
|
||||||
|
(setf (slot-value (allocate-instance (find-class ',class-name)) '%opcode) ,code))))))
|
||||||
|
|
||||||
(defun fix-label-addresses-in-instruction-list (instruction-list origin)
|
(defun fix-label-addresses-in-instruction-list (instruction-list origin)
|
||||||
(loop :with address := origin
|
(loop :with address := origin
|
||||||
|
@ -106,23 +109,22 @@
|
||||||
|
|
||||||
;;; Testing
|
;;; Testing
|
||||||
|
|
||||||
(define-instruction "TXA" nil (:implied 0))
|
(define-instruction "TXA" nil (:implied #x8a))
|
||||||
(define-instruction "PHA" nil (:implied 0))
|
(define-instruction "PHA" nil (:implied #x48))
|
||||||
(define-instruction "PLA" nil (:implied 0))
|
(define-instruction "PLA" nil (:implied #x68))
|
||||||
(define-instruction "TAX" nil (:implied 0))
|
(define-instruction "TAX" nil (:implied #xaa))
|
||||||
(define-instruction "DEX" nil (:implied 0))
|
(define-instruction "DEX" nil (:implied #xca))
|
||||||
(define-instruction "BNE" t (:relative 0))
|
(define-instruction "BNE" t (:relative #xd0))
|
||||||
(define-instruction "LDA" nil
|
(define-instruction "LDA" nil
|
||||||
(:absolute 0)
|
(:immediate #xa9)
|
||||||
(:zero-page 0)
|
(:zero-page #xa5)
|
||||||
(:immediate 0)
|
(:absolute #xad)
|
||||||
(:absolute-y 0))
|
(:absolute-y #xb9))
|
||||||
(define-instruction "LDY" nil
|
(define-instruction "LDY" nil
|
||||||
(:absolute 0)
|
(:immediate #xa0)
|
||||||
(:immediate 0))
|
(:absolute #xac))
|
||||||
(define-instruction "STA" nil
|
(define-instruction "STA" nil
|
||||||
(:absolute 0)
|
(:absolute #x8d)
|
||||||
(:immediate 0)
|
(:absolute-y #x99))
|
||||||
(:absolute-y 0))
|
|
||||||
(define-instruction "JSR" nil
|
(define-instruction "JSR" nil
|
||||||
(:absolute 0))
|
(:absolute #x20))
|
||||||
|
|
Loading…
Add table
Reference in a new issue