Add COMPILE-IR method for IR-MINUS
This commit is contained in:
parent
f814f9fbb9
commit
76cd607bab
1 changed files with 12 additions and 0 deletions
|
@ -92,6 +92,7 @@
|
||||||
(define-normal-emitter emit-lda #xa9 #xa5 #xad)
|
(define-normal-emitter emit-lda #xa9 #xa5 #xad)
|
||||||
(define-normal-emitter emit-sta (error "STA has no immediate mode.") #x85 #x8d)
|
(define-normal-emitter emit-sta (error "STA has no immediate mode.") #x85 #x8d)
|
||||||
(define-normal-emitter emit-adc #x69 #x65 #x6d)
|
(define-normal-emitter emit-adc #x69 #x65 #x6d)
|
||||||
|
(define-normal-emitter emit-sbc #xe9 #xe5 #xed)
|
||||||
(define-normal-emitter emit-cmp #xc9 #xc5 #xcd)
|
(define-normal-emitter emit-cmp #xc9 #xc5 #xcd)
|
||||||
|
|
||||||
(defun emit-store-data (data)
|
(defun emit-store-data (data)
|
||||||
|
@ -163,6 +164,17 @@
|
||||||
(emit-adc :address (data-reference (second (inputs inst)))))
|
(emit-adc :address (data-reference (second (inputs inst)))))
|
||||||
(emit-store-data (output inst)))
|
(emit-store-data (output inst)))
|
||||||
|
|
||||||
|
(defmethod compile-ir ((inst ir-minus))
|
||||||
|
(unless (= (length (inputs inst)) 2)
|
||||||
|
(error "During the final code generation step, IR-MINUS must have exactly 2 operands."))
|
||||||
|
(emit-load-data (first (inputs inst)))
|
||||||
|
(emit-asm-instruction :opcode #x38 :byte-length 1) ; Set Carry
|
||||||
|
(if (eql (strategy (allocation-details (second (inputs inst))))
|
||||||
|
:constant)
|
||||||
|
(emit-sbc :immediate (ir-constant-value (second (inputs inst))))
|
||||||
|
(emit-sbc :address (data-reference (second (inputs inst)))))
|
||||||
|
(emit-store-data (output inst)))
|
||||||
|
|
||||||
(defmethod compile-ir ((inst ir-assign))
|
(defmethod compile-ir ((inst ir-assign))
|
||||||
(emit-load-data (input inst))
|
(emit-load-data (input inst))
|
||||||
(emit-store-data (output inst)))
|
(emit-store-data (output inst)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue