list p=16f88 ; list directive to define processor
#include <p16F88.inc> ; processor specific variable definitions
errorlevel -302 , -207 ; suppress messages 302 [Bank] and 207 [label in column 1]
inA equ 0x24 ;reception of first number
inB equ 0x25 ; reception of second number
sumAB equ 0x26 ; reception the sum of the two numbers
;================= Start of Code =================
org 0
goto Start
org 4
Start
banksel TXSTA
movlw B'00100100'
movwf TXSTA
movlw D'25' ;sets band to 9600 b/s
movwf SPBRG
movlw 00
movwf TRISB ;set port B as Output
banksel RCSTA
movlw B'10010000'
movwf RCSTA
loop
banksel PIR1
firstReadingLoop
btfss PIR1,RCIF ;RCIF is set when reception is complete
goto firstReadingLoop
movf RCREG,W ; aquired data is stored in RCREG
movwf inA
secondReadingLoop
btfss PIR1,RCIF
goto secondReadingLoop
movf RCREG,W
movwf inB
addwf inA,W ;w holds the sum of 2 inputs A,B.
dw 1
banksel PIR1
transmit
btfss PIR1, TXIF
goto transmit
movwf TXREG ;w holds the sum of 2 inputs A,B.
goto loop
end