We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Y Index Register: Difference between revisions

From SnesLab
Jump to: navigation, search
(stack pointer)
(flowed LDY/STY into body)
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
The [[Y Index Register]] exists on 65x processors and often holds the current index when iterating over things.
The [[Y Index Register]] on 65x processors often holds the current index when iterating over things.  It can be incremented or decremented by one with [[INY]] or [[DEY]], but there is no instruction to add or subtract more than one.  Although INY and DEY can affect the [[negative flag]], the indexed [[addressing mode]]s always interpret the bit pattern in the Y index register as a non-negative integer.


On the [[S-SMP]] it is always 8 bits wide.  On the [[65c816]], it may be 8 or 16 bits wide.
It can be loaded with [[LDY]] and stored to memory with [[STY]].
 
On the [[S-SMP]] it is always 8 bits wide.  On the [[65c816]], it may be 8 or 16 bits wide:
* When the [[index register select]] flag is clear, Y is 16 bit
* When the index register select flag is set, Y is 8 bit
In [[emulation mode]] it is always 8 bits wide.


Unlike the [[X index register]], there are no instructions to transfer value of the [[stack pointer]] to/from Y.
Unlike the [[X index register]], there are no instructions to transfer value of the [[stack pointer]] to/from Y.


=== See Also ===
It is not specified to have any particular value after reset.
* [[INY]]
 
* [[DEY]]
It can be pushed to the [[stack]] with [[PHY]] and pulled with [[PLY]].  It can be copied to the [[accumulator]] with [[TYA]] and made to reflect the accumulator with [[TAY]].  It can be copied to X with [[TYX]] and made to reflect x with [[TXY]].
* [[LDY]]
 
* [[STY]]
[[CPY]] can compare it to something.
* [[CPY]]
 
* [[TAY]]
=== Reference ===
* [[TYA]]
* 8.1.3 of [https://archive.org/details/SNESDevManual/book1/page/n182 page 3-8-4 of Book I] of the official Super Nintendo development manual
* [[PHY]]
* [[PLY]]
* [[Accumulator]]


[[Category:SNES Hardware]]
[[Category:SNES Hardware]]

Latest revision as of 23:28, 16 August 2024

The Y Index Register on 65x processors often holds the current index when iterating over things. It can be incremented or decremented by one with INY or DEY, but there is no instruction to add or subtract more than one. Although INY and DEY can affect the negative flag, the indexed addressing modes always interpret the bit pattern in the Y index register as a non-negative integer.

It can be loaded with LDY and stored to memory with STY.

On the S-SMP it is always 8 bits wide. On the 65c816, it may be 8 or 16 bits wide:

  • When the index register select flag is clear, Y is 16 bit
  • When the index register select flag is set, Y is 8 bit

In emulation mode it is always 8 bits wide.

Unlike the X index register, there are no instructions to transfer value of the stack pointer to/from Y.

It is not specified to have any particular value after reset.

It can be pushed to the stack with PHY and pulled with PLY. It can be copied to the accumulator with TYA and made to reflect the accumulator with TAY. It can be copied to X with TYX and made to reflect x with TXY.

CPY can compare it to something.

Reference