I have a small piece of code That acts very unusual, I got from Bruce, I Believe. Anyway if you look at the label "ThisDoesnt" and compare it to the Label "ThisWorks" you may be able to spot the problem. However, I cant find any reason why this shouldnn't work. But it will not work for me.
I'm using PBP 2.46 and a lovely 18f2620.


DEFINE OSC 4
DEFINE HSER_BAUD 19200
DEFINE HSER_CLROERR 1 ' Automatically clear over-run errors
DEFINE HSER_RCSTA 90h ' Enable USART receive
DEFINE HSER_TXSTA 24h ' TXSTA=%00100100. TX enable, BRGH=1 for high-speed

GP VAR BYTE ' GP variable
BytesIn var byte[5] ' 0 thru 4 bytes
ByteCnt var byte ' Indicates number of bytes in buffer

OERR VAR RCSTA.1 ' Alias USART over-run bit
CREN VAR RCSTA.4 ' Alias USART continuous receive enable bit
RCIF VAR PIR1.5 ' Alias USART received character interrupt flag bit
INTCON = 0 ' Disable interrupts
ByteCnt = 0 ' Zero counter
ADCON1 = 7 ' A/D off, all digital
OSCCON=%01100000 ' Set internal osc to 4MHZ

Main:
IF oerr then
cren=0
cren=1
endif
IF RCIF THEN ' If RCIF=1 there's a new character in RCREG
BytesIn[ByteCnt]=RCREG ' Yes. Then store it in array
IF ByteCnt = 4 THEN ThisWorks ' IF BytesIn[ByteCnt]=EOM THEN OutMsg
ByteCnt=ByteCnt+1 ' Increment array index pointer
ENDIF
GOTO Main

ThisWorks:

if bytesin[0]= $80 then Weird
Weird:
HSEROUT ["up",str BytesIn\ByteCnt ,13,10]
FOR GP=0 TO ByteCnt ' Clear array bytes 0 to ByteCnt
BytesIn[GP]=0 '
NEXT gp '
ByteCnt=0 ' Reset index pointer back to first element
WHILE RCIF ' Keep reading until RCIF is clear to flush buffer
GP=RCREG ' after EOM is received
WEND
GOTO Main

ThisDoesnt:

if bytesin[0]= $80 then

HSEROUT ["up",str BytesIn\ByteCnt ,13,10]
endif

FOR GP=0 TO ByteCnt ' Clear array bytes 0 to ByteCnt
BytesIn[GP]=0 '
NEXT gp '
ByteCnt=0 ' Reset index pointer back to first element
WHILE RCIF ' Keep reading until RCIF is clear to flush buffer
GP=RCREG ' after EOM is received
WEND
GOTO Main

Also I have replaced this line (if bytesin[0]= $80 then) with a "> 7F and <81" and it works fine. But as soon as I use the "=" to i get nothing.
Could some someone please explain this to me?

thanks ash