Search code examples
6502

What do < or > mean in LDA/STA command?


I understand the basics of the 6502 instruction set but have come across this code which is confusing me.

Can't find any reference to these in the 6502 manuals I have.

What do the < and > signify?

CLBASE  = $100
BPTR    = $25
ARM .BYT $1,$2  

LDA #<ARM
STA BPTR
LDA #>ARM
STA BPTR+1
LDA #>CLBASE

Solution

  • The prefix #< specifies the low byte of the operand, and #> specifies the high byte of the operand.

    E.g.

    LDA #>CLBASE ;This will be #$01
    LDA #<CLBASE ;This will be #$00
    

    There's an assembler convention across the range of 6502-derived devices supported by most assemblers, such as ACME for instance. Here's the relevant section from WDC's W65C816S 8/16–bit Microprocessor datasheet.

    | Operand     | One Byte Result | Two Byte Result |
    |-------------|-----------------|-----------------|
    | #$01020304  | 04              | 0403            |
    | #<$01020304 | 04              | 0403            |
    | #>$01020304 | 03              | 0302            |
    | #^$01020304 | 02              | 0201            |