diff --git a/wip-duuqnd/user-side-compiler/backend/code-generator.lisp b/wip-duuqnd/user-side-compiler/backend/code-generator.lisp index c6881f7..89b1cd3 100644 --- a/wip-duuqnd/user-side-compiler/backend/code-generator.lisp +++ b/wip-duuqnd/user-side-compiler/backend/code-generator.lisp @@ -92,6 +92,7 @@ (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-adc #x69 #x65 #x6d) +(define-normal-emitter emit-cmp #xc9 #xc5 #xcd) (defun emit-store-data (data) (if (or (null (allocation-details data)) @@ -182,6 +183,14 @@ (emit-asm-instruction :opcode #x20 :operand (callee inst) :byte-length 3) (emit-store-result (output inst))) +(defmethod compile-ir ((inst ir-test-equal)) + (emit-load-data (first (inputs inst))) + (if (eql (strategy (allocation-details (second (inputs inst)))) + :constant) + (emit-cmp :immediate (ir-constant-value (second (inputs inst)))) + (emit-cmp :address (data-reference (second (inputs inst))))) + (emit-store-bool (output inst))) + (defun link-compute-addresses (start-instruction origin-address) "First linking pass, computes the addresses of all labels." (let ((address origin-address))