4.11.3.2 Accessing Registers From Assembly Code

In assembly code, SFR definitions are not automatically accessible. The header file <xc.h> can be included to gain access to these register definitions.

The symbols for registers in this header file are the same as those used in the C domain; however, you should use the appropriate I/O macros to ensure the correct address is encoded into instructions which accesses memory in the I/O space, for example, the following writes to the TCNT0 register:

out _SFR_IO_ADDR(TCNT0), r19

Bits within registers have macros associated with them and can be used directly with instructions that expect a bit number (0 thru 7), or with the _BV() macro if you need a bit mask based on that bit’s position in the SFR, for example:

sbic _SFR_IO_ADDR(PORTD), PD4
ldi r16, _BV(TOIE0)