     # Addition / subtraction instructions
     ###########################################################
 
-    ADC: (address) =>
+    ADC: (address) ->
         @$addValueToAccumulator @$readByte address
 
-    SBC: (address) =>
+    SBC: (address) ->
         @$addValueToAccumulator (@$readByte address) ^ 0xFF # With internal carry incremment makes negative operand
 
     ###########################################################
     # Shifting / rotation instructions
     ###########################################################
 
-    ASL: (address) =>
+    ASL: (address) ->
         @$rotateAccumulatorOrMemory address, @rotateLeft, false
 
-    LSR: (address) =>
+    LSR: (address) ->
         @$rotateAccumulatorOrMemory address, @rotateRight, false
 
-    ROL: (address) =>
+    ROL: (address) ->
         @$rotateAccumulatorOrMemory address, @rotateLeft, true
 
-    ROR: (address) =>
+    ROR: (address) ->
         @$rotateAccumulatorOrMemory address, @rotateRight, true
 
     ###########################################################
     # Hybrid instructions
     ###########################################################
 
-    DCP: (address) =>
+    DCP: (address) ->
         @$compareRegisterAndOperand @accumulator, @DEC address
 
-    ISB: (address) =>
+    ISB: (address) ->
         @$addValueToAccumulator (@INC address) ^ 0xFF # With internal carry incremment makes negative operand
 
-    SLO: (address) =>
+    SLO: (address) ->
         @$storeValueIntoAccumulator @accumulator | @ASL address
 
-    SRE: (address) =>
+    SRE: (address) ->
         @$storeValueIntoAccumulator @accumulator ^ @LSR address
 
-    RLA: (address) =>
+    RLA: (address) ->
         @$storeValueIntoAccumulator @accumulator & @ROL address
 
-    XAA: (address) => # Also known as ANE
+    XAA: (address) -> # Also known as ANE
         @$storeValueIntoAccumulator @registerX & @AND address
 
-    RRA: (address) =>
+    RRA: (address) ->
         @$addValueToAccumulator @ROR address
 
-    AXS: (address) => # Also known as SBX
+    AXS: (address) -> # Also known as SBX
         @registerX = @compareRegisterAndMemory @accumulator & @registerX, address
 
-    ANC: (address) =>
+    ANC: (address) ->
         @$rotateLeft @AND(address), false # rotateLeft computes carry
 
-    ALR: (address) =>
+    ALR: (address) ->
         @AND address
         @LSR()
 
-    ARR: (address) =>
+    ARR: (address) ->
         @AND address
         @ROR()
         @carryFlag = (@accumulator >>> 6) & 1
         @overflowFlag = ((@accumulator >>> 5) & 1) ^ @carryFlag
 
-    TAS: (address) => # Also known as SHS
+    TAS: (address) -> # Also known as SHS
         @stackPointer = @accumulator & @registerX
         @SHA address
 

    # Increment instructions
    ###########################################################

    INC: (address) =>
        @$storeValueIntoMemory address, ((@$readByte address) + 1) & 0xFF

    INX: =>
        @$storeValueIntoRegisterX (@registerX + 1) & 0xFF

    INY: =>
        @$storeValueIntoRegisterY (@registerY + 1) & 0xFF

    ###########################################################
    # Decrement instructions
    ###########################################################

    DEC: (address) =>
        @$storeValueIntoMemory address, ((@$readByte address) - 1) & 0xFF

    DEX: =>
        @$storeValueIntoRegisterX (@registerX - 1) & 0xFF

    DEY: =>
        @$storeValueIntoRegisterY (@registerY - 1) & 0xFF

    ###########################################################
    # Comparison instructions
    ###########################################################

    CMP: (address) =>
        @$compareRegisterAndMemory @accumulator, address

    CPX: (address) =>
        @$compareRegisterAndMemory @registerX, address

    CPY: (address) =>
        @$compareRegisterAndMemory @registerY, address

    ###########################################################
    # Branching instructions
    ###########################################################

    BCC: (address) =>
        @$branchIf not @carryFlag, address

    BCS: (address) =>
        @$branchIf @carryFlag, address

    BNE: (address) =>
        @$branchIf not @zeroFlag, address

    BEQ: (address) =>
        @$branchIf @zeroFlag, address

    BVC: (address) =>
        @$branchIf not @overflowFlag, address

    BVS: (address) =>
        @$branchIf @overflowFlag,  address

    BPL: (address) =>
        @$branchIf not @negativeFlag, address

    BMI: (address) =>
        @$branchIf @negativeFlag, address

    ###########################################################
    # Jump / subroutine instructions
    ###########################################################

    JMP: (address) =>
        @programCounter = address

    JSR: (address) =>
        @$pushWord (@programCounter - 1) & 0xFFFF # The pushed address must be the end of the current instruction
        @programCounter = address

    RTS: =>
        @programCounter = (@$popWord() + 1) & 0xFFFF # We decremented the address when pushing it during JSR
        @tick()


    # No operation instruction
    ###########################################################

    NOP: ->

    ###########################################################
    # Clear flag instructions
    ###########################################################

    CLC: ->
        @carryFlag = 0

    CLI: ->
        @interruptDisable = 0

    CLD: ->
        @decimalMode = 0

    CLV: ->
        @overflowFlag = 0

    ###########################################################
    # Set flag instructions
    ###########################################################

    SEC: ->
        @carryFlag = 1

    SEI: ->
        @interruptDisable = 1

    SED: ->
        @decimalMode = 1

    ###########################################################
    # Memory write instructions
    ###########################################################

    STA: (address) ->
        @$writeByte address, @accumulator

    STX: (address) ->
        @$writeByte address, @registerX

    SAX: (address) ->
        @$writeByte address, @accumulator & @registerX

    STY: (address) ->
        @$writeByte address, @registerY

    SHA: (address) -> # Also known as AHX
        @$storeHighAddressIntoMemory address, @accumulator & @registerX

    SHX: (address) -> # Also known as SXA
        @$storeHighAddressIntoMemory address, @registerX

    SHY: (address) -> # Also known as SYA
        @$storeHighAddressIntoMemory address, @registerY

    ###########################################################
    # Memory read instructions
    ###########################################################

    LDA: (address) ->
        @$storeValueIntoAccumulator @$readByte address

    LDX: (address) ->
        @$storeValueIntoRegisterX @$readByte address

    LDY: (address) ->
        @$storeValueIntoRegisterY @$readByte address

    LAX: (address) ->
        value = @$readByte address
        @$storeValueIntoAccumulator value
        @$storeValueIntoRegisterX value

    LAS: (address) ->
        @stackPointer &= @$readByte address
        @$storeValueIntoAccumulator @stackPointer
        @$storeValueIntoRegisterX @stackPointer
