DEV Community

Cover image for Assembly 6502: LDX
Beey
Beey

Posted on

Assembly 6502: LDX

Explanation

LDX in NES assembly(Assembly 6502) loads an 8-bit value into the X register.

How to use LDX to send non-hex values

The value must start with a # example:


LDX #12

; That is how to write 12 to the CPU in the X register

Enter fullscreen mode Exit fullscreen mode

The registers

Now there are multiple registers some include:

  • X register(LDX)
  • A register(LDA)
  • Y register(LDY)

How to use LDX to send hex values

Hex values are also allowed: LDX #$12

They MUST start with #(Standard for LDX, LDA and LDY)

They also MUST start with $ after #(Special to hex values)

Max values for 8-bit integer

The maximum value for the 8-bit unsigned integer is: 255
The maximum value for the 8-bit signed integer is: 127

Your stats will always need to cap at 255 unless you are using the 16-bit integer limit

Notes

NOTE: The NES is different than the SNES in assembly.

Top comments (0)