We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS
ADC (SPC700): Difference between revisions
From SnesLab
(see also) |
(flow DAA into body) |
||
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| class="wikitable" style="float:right;clear:right;width:45%" | |||
{| class="wikitable" style="float:right;clear:right;width: | |||
!colspan="8"|Basic Info | !colspan="8"|Basic Info | ||
|+ | |+ | ||
Line 9: | Line 7: | ||
|'''Speed''' | |'''Speed''' | ||
|+ | |+ | ||
| | |[[Immediate]] | ||
|88 | |88 | ||
|2 bytes | |2 bytes | ||
|2 cycles | |2 cycles | ||
|+ | |+ | ||
| | |[[Implied]] (type 1) | ||
|86 | |86 | ||
|1 byte | |1 byte | ||
|3 cycles | |3 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Addressing | Direct Page]] | ||
|84 | |84 | ||
|2 bytes | |2 bytes | ||
|3 cycles | |3 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Indexed by X]] | ||
|94 | |94 | ||
|2 bytes | |2 bytes | ||
|3 cycles | |3 cycles | ||
|+ | |+ | ||
| | |[[Absolute Addressing | Absolute]] | ||
|85 | |85 | ||
|3 bytes | |3 bytes | ||
|4 cycles | |4 cycles | ||
|+ | |+ | ||
| | |[[Absolute Indexed by X]] | ||
|95 | |95 | ||
|3 bytes | |3 bytes | ||
|5 cycles | |5 cycles | ||
|+ | |+ | ||
| | |[[Absolute Indexed by Y]] | ||
|96 | |96 | ||
|3 bytes | |3 bytes | ||
|5 cycles | |5 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Indexed by X]] | ||
|87 | |87 | ||
|2 bytes | |2 bytes | ||
|6 cycles | |6 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Indirect Indexed by Y]] | ||
|97 | |97 | ||
|2 bytes | |2 bytes | ||
|6 cycles | |6 cycles | ||
|+ | |+ | ||
| | |[[Implied]] (type 1) | ||
|99 | |99 | ||
|1 byte | |1 byte | ||
|5 cycles | |5 cycles | ||
|+ | |+ | ||
| | |[[Direct Page]] | ||
|89 | |89 | ||
|3 bytes | |3 bytes | ||
|6 cycles | |6 cycles | ||
|+ | |+ | ||
| | |[[Direct Page Immediate]] | ||
|98 | |98 | ||
|3 bytes | |3 bytes | ||
Line 71: | Line 69: | ||
{| class="wikitable" style="float:right;clear:right;width:30%" | {| class="wikitable" style="float:right;clear:right;width:30%" | ||
!colspan="8"|Flags | !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 | ||
|} | |} | ||
'''ADC''' (Add with Carry) is an [[SPC700]] instruction that adds the value of the two operands together (along with the [[carry flag]]) and stores the sum in 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> | |||
ADC A, #imm | |||
ADC A, (X) | |||
ADC A, dp | |||
ADC A, dp+X | |||
ADC A, !abs | |||
ADC A, !abs+X | |||
ADC A, !abs+Y | |||
ADC A, [dp+X] | |||
ADC A, [dp]+Y | |||
ADC (X), (Y) | |||
ADC dp<d>, dp<s> | |||
ADC dp, #imm | |||
</pre> | |||
Unlike the [[65c816]], the SPC700 has no [[decimal mode]], so the addition is always done in binary/hexadecimal. Use [[DAA]] after adding [[BCD]]-encoded data to repair it back to BCD. | |||
=== See Also === | === See Also === | ||
* [[SBC (SPC700)]] | * [[SBC (SPC700)]] | ||
* [[CLRC]] | |||
* [[ADDW]] | |||
* [[ADC]] | * [[ADC]] | ||
=== External Links === | === External Links === | ||
* Official Super Nintendo development manual on ADC: [https://archive.org/details/SNESDevManual/book1/page/n230 Appendix C-5 of Book I] | * Official Super Nintendo development manual on ADC: 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/8fabc9764c33a7ae2520a76d80ed7220bb939f12/spc700.txt#L304 | |||
[[Category:ASM]] | [[Category:ASM]] | ||
[[Category:SPC700]] | [[Category:SPC700]] | ||
[[Category:8-bit Arithmetic Operation Commands]] |
Latest revision as of 08:53, 19 September 2024
Basic Info | |||||||
---|---|---|---|---|---|---|---|
Addressing Mode | Opcode | Length | Speed | ||||
Immediate | 88 | 2 bytes | 2 cycles | ||||
Implied (type 1) | 86 | 1 byte | 3 cycles | ||||
Direct Page | 84 | 2 bytes | 3 cycles | ||||
Direct Page Indexed by X | 94 | 2 bytes | 3 cycles | ||||
Absolute | 85 | 3 bytes | 4 cycles | ||||
Absolute Indexed by X | 95 | 3 bytes | 5 cycles | ||||
Absolute Indexed by Y | 96 | 3 bytes | 5 cycles | ||||
Direct Page Indexed by X | 87 | 2 bytes | 6 cycles | ||||
Direct Page Indirect Indexed by Y | 97 | 2 bytes | 6 cycles | ||||
Implied (type 1) | 99 | 1 byte | 5 cycles | ||||
Direct Page | 89 | 3 bytes | 6 cycles | ||||
Direct Page Immediate | 98 | 3 bytes | 5 cycles |
Flags Affected | |||||||
---|---|---|---|---|---|---|---|
N | V | P | B | H | I | Z | C |
N | V | . | . | H | . | Z | C |
ADC (Add with Carry) is an SPC700 instruction that adds the value of the two operands together (along with the carry flag) and stores the sum in 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
ADC A, #imm ADC A, (X) ADC A, dp ADC A, dp+X ADC A, !abs ADC A, !abs+X ADC A, !abs+Y ADC A, [dp+X] ADC A, [dp]+Y ADC (X), (Y) ADC dp<d>, dp<s> ADC dp, #imm
Unlike the 65c816, the SPC700 has no decimal mode, so the addition is always done in binary/hexadecimal. Use DAA after adding BCD-encoded data to repair it back to BCD.
See Also
External Links
- Official Super Nintendo development manual on ADC: Table C-7 in Appendix C-5 of Book I
- anomie: https://github.com/yupferris/TasmShiz/blob/8fabc9764c33a7ae2520a76d80ed7220bb939f12/spc700.txt#L304