Ex6502.CPU.Executor.SBC (ex6502 v0.1.0) View Source

Subtract the value of memory and borrow (carry) from accumulator storing result in accumulator

A set carry flag means that a "borrow" was not required during the subtraction operation

Operation

A - M - ~C -> A

Table

SBC | Subtract Memory From Accumulator with Borrow
==================================================

A - M - ~C -> A                  N V - B D I Z C
                                 + + - - - - + +

addressing       assembler    opc  bytes  cycles
--------------------------------------------------
immediate        SBC #$nn      E9    2     2 d
absolute         SBC $nnnn     ED    3     4 d
absolute,X       SBC $nnnn,X   FD    3     4 dp
absolute,Y       SBC $nnnn,Y   F9    3     4 dp
zeropage         SBC $nn       E5    2     3 d
zeropage,X       SBC $nn,X     F5    2     4 d
(zp indirect)    SBC ($nn)     F2    2     5 d
(zp indirect,X)  SBC ($nn,X)   E1    2     6 d
(zp indirect),Y  SBC ($nn),Y   F1    2     5 dp

p: +1 if page is crossed
d: +1 if in decimal mode

Flags

  • Negative: 1 if bit 7 of result is 1; 0 otherwise
  • oVerflow: 1 when the sign of bit 7 is changed due to exceeding +127 or -128; else 0
  • Carry: 1 if result is >= 0; 0 otherwise
  • Zero: 1 if result is zero; 0 otherwise

Further reference

Link to this section Summary

Link to this section Functions