Ports and other Registers
Positron8 · Revision 4.0.6.5 · PDF pages 39–40
All of the PICmicro™ SFRs (Special Function Registers), including the ports, can be accessed just like any other byte-sized variable. This means that they can be read from, written to or used in expressions directly.
PORTA = 0b01010101 ' Write value to PORTA
MyWord = MyWord * PORTA ' Multiply variable MyWord with the contents of PORTA
The compiler can also combine16-bit SFRs such as TMR1 into a Word type variable. Which makes loading and reading these registers simple: -
' Combine TMR1L and TMR1H into unsigned Word variable wTimer1
Dim wTimer1 as TMR1L.Word
wTimer1 = 12345 ' Load TMR1L and TMR1H with the value 12345
or
MyWord = wTimer1 ' Load MyWord with the 16-bit contents of TMR1
The .Word extension links registers TMR1L and TMR1H, (which are assigned in the .ppi file associated with the relevant device used).
Any hardware register that can hold a 16-bit result can be assigned as a Word type variable: -
' Combine ADRESL and ADRESH into unsigned Word variable wADC_Result
'
Dim wADC_Result as ADRESL.Word
'
' Combine PRODL and PRODH into unsigned Word variable wMul_PROD
'
Dim wMul_PROD as PRODL.Word

