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
|
||||
(defclass ,base-name (instruction)
|
||||
((%mnemonic :allocation :class :initform ',mnemonic)))
|
||||
(setf (slot-value (make-instance ',base-name) '%mnemonic) ',mnemonic)
|
||||
,@(loop :for (mode code) :in modes-and-codes
|
||||
:collect `(defclass ,(intern (format nil "INST-~A-~A"
|
||||
name mode))
|
||||
,(append
|
||||
`(,base-name
|
||||
,(addressing-mode-to-class-name mode)
|
||||
complete-mixin)
|
||||
(when branching-p
|
||||
'(branching-mixin)))
|
||||
((%opcode :allocation :class :initform ,code)))))))
|
||||
:for class-name := (intern (format nil "INST-~A-~A" name mode))
|
||||
:collect `(progn
|
||||
(defclass ,class-name
|
||||
,(append
|
||||
`(,base-name
|
||||
,(addressing-mode-to-class-name mode)
|
||||
complete-instruction-mixin)
|
||||
(when branching-p
|
||||
'(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)
|
||||
(loop :with address := origin
|
||||
|
@ -106,23 +109,22 @@
|
|||
|
||||
;;; Testing
|
||||
|
||||
(define-instruction "TXA" nil (:implied 0))
|
||||
(define-instruction "PHA" nil (:implied 0))
|
||||
(define-instruction "PLA" nil (:implied 0))
|
||||
(define-instruction "TAX" nil (:implied 0))
|
||||
(define-instruction "DEX" nil (:implied 0))
|
||||
(define-instruction "BNE" t (:relative 0))
|
||||
(define-instruction "TXA" nil (:implied #x8a))
|
||||
(define-instruction "PHA" nil (:implied #x48))
|
||||
(define-instruction "PLA" nil (:implied #x68))
|
||||
(define-instruction "TAX" nil (:implied #xaa))
|
||||
(define-instruction "DEX" nil (:implied #xca))
|
||||
(define-instruction "BNE" t (:relative #xd0))
|
||||
(define-instruction "LDA" nil
|
||||
(:absolute 0)
|
||||
(:zero-page 0)
|
||||
(:immediate 0)
|
||||
(:absolute-y 0))
|
||||
(:immediate #xa9)
|
||||
(:zero-page #xa5)
|
||||
(:absolute #xad)
|
||||
(:absolute-y #xb9))
|
||||
(define-instruction "LDY" nil
|
||||
(:absolute 0)
|
||||
(:immediate 0))
|
||||
(:immediate #xa0)
|
||||
(:absolute #xac))
|
||||
(define-instruction "STA" nil
|
||||
(:absolute 0)
|
||||
(:immediate 0)
|
||||
(:absolute-y 0))
|
||||
(:absolute #x8d)
|
||||
(:absolute-y #x99))
|
||||
(define-instruction "JSR" nil
|
||||
(:absolute 0))
|
||||
(:absolute #x20))
|
||||
|
|
Loading…
Add table
Reference in a new issue