DEV Community

Beey
Beey

Posted on

Assembly 6502: LDA

Explanation

LDA in assembly(Assembly 6502) loads an 8-bit value into the A register.

How to use LDA to send non-hex values

The value must start with a # example:


LDA #12

; That is how to write 12 to the CPU in the A 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 LDA to send hex values

Hex values are also allowed: LDA #$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)