Positron Compiler Documentation

Add '+'

Positron16 · Revision 1.1.3.5 · PDF page 76

Assignment Variable = Variable + Variable

Adds variables and/or constants, returning an unsigned or signed 8, 16, 32-bit or floating point result.

Variables may be constants, variables or expressions. Assignment Variable can be any valid variable type.

Addition works exactly as you would expect with signed and unsigned integers as well as floating point.

  Device = 24FJ64GA002           ' Select the device to compile for
  Declare Xtal = 16      ' Tell the compiler the device will be operating at 16MHz

  Declare Hserial1_Baud = 9600
  Declare Hrsout1_Pin = PORTB.14

  Dim MyWord1 as Word
  Dim MyWord2 as Word

  PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX

  MyWord1 = 1575
  MyWord2 = 976
  MyWord1 = MyWord1 + MyWord2    ' Add the numbers.
  HrsoutLn Dec MyWord1            ' Display the result

' 32-bit addition
  Device = 24FJ64GA002           ' Select the device to compile for
  Declare Xtal = 16      ' Tell the compiler the device will be operating at 16MHz

  Declare Hserial1_Baud = 9600
  Declare Hrsout1_Pin = PORTB.14

  Dim MyWord as Word
  Dim MyDword as Dword

  PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX

  MyWord = 1575
  MyDword = 9763647
  MyDword = MyDword + MyWord    ' Add the numbers.
  HrsoutLn Dec MyDword            ' Display the result
View original PDF page 76Open page in PDFOriginal PDF page 76