We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS
SBC (SPC700): Difference between revisions
From SnesLab
(moved tables up) |
(mentioned BCD) |
||
(21 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| class="wikitable" style="float:right;clear:right;width: | {| class="wikitable" style="float:right;clear:right;width:45%" | ||
!colspan="8"|Basic Info | !colspan="8"|Basic Info | ||
|+ | |+ | ||
Line 7: | Line 7: | ||
|'''Speed''' | |'''Speed''' | ||
|+ | |+ | ||
| | |[[Immediate]] | ||
|A8 | |A8 | ||
|2 bytes | |2 bytes | ||
|2 cycles | |2 cycles | ||
|+ | |+ | ||
| | |[[Implied Indirect]] (type 1) | ||
|A6 | |A6 | ||
|1 byte | |1 byte | ||
|3 cycles | |3 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Addressing | Direct Page]] | ||
|A4 | |A4 | ||
|2 bytes | |2 bytes | ||
|3 cycles | |3 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Indexed by X]] | ||
|B4 | |B4 | ||
|2 bytes | |2 bytes | ||
|4 cycles | |4 cycles | ||
|+ | |+ | ||
| | |[[Absolute Addressing | Absolute]] | ||
|A5 | |A5 | ||
|3 bytes | |3 bytes | ||
|4 cycles | |4 cycles | ||
|+ | |+ | ||
| | |[[Absolute Indexed by X]] | ||
|B5 | |B5 | ||
|3 bytes | |3 bytes | ||
|5 cycles | |5 cycles | ||
|+ | |+ | ||
| | |[[Absolute Indexed by Y]] | ||
|B6 | |B6 | ||
|3 bytes | |3 bytes | ||
|5 cycles | |5 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Indexed by X]] | ||
|A7 | |A7 | ||
|2 bytes | |2 bytes | ||
|6 cycles | |6 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Indirect Indexed by Y]] | ||
|B7 | |B7 | ||
|2 bytes | |2 bytes | ||
|6 cycles | |6 cycles | ||
|+ | |+ | ||
| | |[[Implied Indirect]] (type 1) | ||
|B9 | |B9 | ||
|1 byte | |1 byte | ||
|5 cycles | |5 cycles | ||
|+ | |+ | ||
| | |[[Direct Page]] | ||
|A9 | |A9 | ||
|3 bytes | |3 bytes | ||
|6 cycles | |6 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Immediate]] | ||
|B8 | |B8 | ||
|3 bytes | |3 bytes | ||
Line 70: | Line 70: | ||
{| class="wikitable" style="float:right;clear:right;width:30%" | {| class="wikitable" style="float:right;clear:right;width:30%" | ||
!colspan="8"|Flags Affected | !colspan="8"|Flags Affected | ||
|+ | |||
|[[Negative Flag|N]] | |||
|[[Overflow Flag|V]] | |||
|[[Direct Page Flag|P]] | |||
|[[Break Flag|B]] | |||
|[[Half-Carry Flag|H]] | |||
|[[Interrupt Enable Flag|I]] | |||
|[[Zero Flag|Z]] | |||
|[[Carry Flag|C]] | |||
|+ | |+ | ||
|N | |N | ||
|V | |V | ||
| | |. | ||
| | |. | ||
|H | |H | ||
| | |. | ||
|Z | |Z | ||
|C | |C | ||
|} | |} | ||
'''SBC''' is an [[SPC700]] instruction that subtracts. | '''SBC''' (Subtract) is an [[SPC700]] instruction that subtracts the right operand and the inverse of the [[carry flag]] from the left operand. Often, the left operand is the [[accumulator]]. | ||
The operands are stored in the instruction stream in the opposite order they appear in the assembler source. In the assembler source, the operand on the right is the source and the operand on the left is the destination. | |||
==== Syntax ==== | |||
<pre> | |||
SBC A, #imm | |||
SBC A, (X) | |||
SBC A, dp | |||
SBC A, dp+X | |||
SBC A, !abs | |||
SBC A, !abs+X | |||
SBC A, !abs+Y | |||
SBC A, [dp+X] | |||
SBC A, [dp]+Y | |||
SBC (X), (Y) | |||
SBC dp<d>, dp<s> | |||
SBC dp, #imm | |||
</pre> | |||
Unlike the [[65c816]], the SPC700 has no [[decimal mode]], so the subtraction is always done in binary/hexadecimal. Use [[DAS]] after subtracting [[BCD]]-encoded data to repair it back to BCD. | |||
=== See Also === | === See Also === | ||
* [[ADC (SPC700)]] | * [[ADC (SPC700)]] | ||
* [[SBC]] | * [[SBC]] | ||
* [[SUBW]] | |||
=== External Links === | === External Links === | ||
* Official Super Nintendo development manual on SBC: [https://archive.org/details/SNESDevManual/book1/page/n230 Appendix C-5 of Book I] | * Official Super Nintendo development manual on SBC: Table C-7 in [https://archive.org/details/SNESDevManual/book1/page/n230 Appendix C-5 of Book I] | ||
* anomie: https://github.com/yupferris/TasmShiz/blob/master/spc700.txt#L559 | |||
[[Category:ASM]] | [[Category:ASM]] | ||
[[Category:SPC700]] | [[Category:SPC700]] | ||
[[Category:8-bit Arithmetic Operation Commands]] |
Latest revision as of 08:56, 19 September 2024
Basic Info | |||||||
---|---|---|---|---|---|---|---|
Addressing Mode | Opcode | Length | Speed | ||||
Immediate | A8 | 2 bytes | 2 cycles | ||||
Implied Indirect (type 1) | A6 | 1 byte | 3 cycles | ||||
Direct Page | A4 | 2 bytes | 3 cycles | ||||
Direct Page Indexed by X | B4 | 2 bytes | 4 cycles | ||||
Absolute | A5 | 3 bytes | 4 cycles | ||||
Absolute Indexed by X | B5 | 3 bytes | 5 cycles | ||||
Absolute Indexed by Y | B6 | 3 bytes | 5 cycles | ||||
Direct Page Indexed by X | A7 | 2 bytes | 6 cycles | ||||
Direct Page Indirect Indexed by Y | B7 | 2 bytes | 6 cycles | ||||
Implied Indirect (type 1) | B9 | 1 byte | 5 cycles | ||||
Direct Page | A9 | 3 bytes | 6 cycles | ||||
Direct Page Immediate | B8 | 3 bytes | 5 cycles |
Flags Affected | |||||||
---|---|---|---|---|---|---|---|
N | V | P | B | H | I | Z | C |
N | V | . | . | H | . | Z | C |
SBC (Subtract) is an SPC700 instruction that subtracts the right operand and the inverse of the carry flag from the left operand. Often, the left operand is the accumulator.
The operands are stored in the instruction stream in the opposite order they appear in the assembler source. In the assembler source, the operand on the right is the source and the operand on the left is the destination.
Syntax
SBC A, #imm SBC A, (X) SBC A, dp SBC A, dp+X SBC A, !abs SBC A, !abs+X SBC A, !abs+Y SBC A, [dp+X] SBC A, [dp]+Y SBC (X), (Y) SBC dp<d>, dp<s> SBC dp, #imm
Unlike the 65c816, the SPC700 has no decimal mode, so the subtraction is always done in binary/hexadecimal. Use DAS after subtracting BCD-encoded data to repair it back to BCD.
See Also
External Links
- Official Super Nintendo development manual on SBC: Table C-7 in Appendix C-5 of Book I
- anomie: https://github.com/yupferris/TasmShiz/blob/master/spc700.txt#L559