Assembler : Directives : RS

RS - Assign a value to a symbol.
A bit like EQU but here the value assigned is taken from an internal counter, and after the assignation this counter is increased by the amount specified in the RS directive. This is a very handy way of defining structure member offsets.

Example :
  

 ; C:
 ; --
 ; struct {
 ;    short p_x;
 ;    short p_y;
 ;    byte p_color;
 ; } pixel;
 ;
 ; ASM:
 ; ----
 
           .rsset $0  ; set the initial value
                      ; of the RS counter
 P_X       .rs 2
 P_Y       .rs 2
 P_COLOR   .rs 1
  
You can then use these symbols as offsets in a 'pixel' struct :

  

           ldy #P_COLOR
           lda [pixel_ptr],Y

See also RSSET.