Difference between revisions of "LDX"

From NES Hacker Wiki
Jump to: navigation, search
(Created page with "{{Infobox Opcode | Title = Load X Index With Memory | Opcode = LDX | Operation = M → X | StatusN = Change | StatusZ = Change | StatusC = Ignore | StatusI = Ig...")
 
Line 11: Line 11:
 
}}
 
}}
  
'''''LDX (Load X Index With Memory)''''' loads the [[X Index Register]] with the specified memory. It is similar in function to [[LDA]] and [[LDY]] [[Opcode|opcodes]].
+
'''''LDX (Load X Index With Memory)''''' loads the [[X Index Register]] with the specified memory. It is similar in function to [[LDA]] and [[LDY]] [[Opcode|opcodes]]. Unlike [[LDA]], there aren't as many addressing modes available for LDX.
  
 
==Operation==
 
==Operation==
This pseudo C code shows how the LDA opcode functions when it is executed.
+
This pseudo C code shows how the LDX opcode functions when it is executed.
  
 
  SET_NEGATIVE(Operand);        // Clears the [[Negative Flag]] if the Operand is $#00-7F, otherwise sets it.
 
  SET_NEGATIVE(Operand);        // Clears the [[Negative Flag]] if the Operand is $#00-7F, otherwise sets it.
Line 22: Line 22:
 
==Addressing Modes==
 
==Addressing Modes==
 
{{OpcodeHeader}}
 
{{OpcodeHeader}}
{{OpcodeLine|Immediate|LDA ''#Operand''|A1|2|2}}
+
{{OpcodeLine|Immediate|LDX ''#Operand''|A1|2|2}}
{{OpcodeLine|Zero Page|LDA ''Operand''|A6|2|3}}
+
{{OpcodeLine|Zero Page|LDX ''Operand''|A6|2|3}}
{{OpcodeLine|Zero Page, X|LDA ''Operand, X''|B6|2|4}}
+
{{OpcodeLine|Zero Page, X|LDX ''Operand, X''|B6|2|4}}
{{OpcodeLine|Absolute|LDA ''Operand''|AE|3|4}}
+
{{OpcodeLine|Absolute|LDX ''Operand''|AE|3|4}}
{{OpcodeLine|Absolute, X|LDA ''Operand, X''|BE|3|4*}}
+
{{OpcodeLine|Absolute, X|LDX ''Operand, X''|BE|3|4*}}
 
{{OpcodeFooter|* Add 1 if page boundary is crossed.}}
 
{{OpcodeFooter|* Add 1 if page boundary is crossed.}}
  
 
==Examples==
 
==Examples==

Revision as of 14:38, 24 May 2013

Load X Index With Memory
Opcode: LDX
Operation: M → X
Status Register: Status-List.png
Status-Change.pngStatus-Space.pngStatus-Change.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.png

LDX (Load X Index With Memory) loads the X Index Register with the specified memory. It is similar in function to LDA and LDY opcodes. Unlike LDA, there aren't as many addressing modes available for LDX.

Operation

This pseudo C code shows how the LDX opcode functions when it is executed.

SET_NEGATIVE(Operand);        // Clears the Negative Flag if the Operand is $#00-7F, otherwise sets it.
SET_ZERO(Operand);            // Sets the Zero Flag if the Operand is $#00, otherwise clears it.
X_INDEX = Operand;            // Stores the Operand in the X Index Register.

Addressing Modes

Addressing Mode Assembly Language Form Opcode # Bytes # Cycles
Immediate LDX #Operand A1 2 2
Zero Page LDX Operand A6 2 3
Zero Page, X LDX Operand, X B6 2 4
Absolute LDX Operand AE 3 4
Absolute, X LDX Operand, X BE 3 4*
* Add 1 if page boundary is crossed.

Examples