PDA

View Full Version : two bytes



l_gaminde
- 10th February 2013, 02:03
Below I have code where I get serin2 v3.byte1, I must echo back serout2 v3.byte1 to get serin2 v3.byte0, now when I lcdout v3.byte1 I get 8 and when I lcdout byte0 I get C both of these are correct and it works great now when I lcdout v3 I get 80C I have tried to shift this out, it changes the value I cannot shift out the upper or lower byte why am I getting the 0 in v3 output. this value is needed in another part of the program and I can lcdout hex1 v3.byte1,hex1 v3.byte0 and make it look correct but I need to compare this value somewhere else.




SERIN2 PORTB.1,16468,100,key,[HEX1 V3.byte1] 'GET BYTE 1 DATA
SEROUT2 PORTB.2,16468,[HEX1 V3.byte1] 'SEND BACK BYTE 1 ECHO
SERIN2 PORTB.1,16468,100,key,[HEX1 V3.byte0] 'GET BYTE 2 DATA

lcd: LCDOUT $FE,$94,hex V3.byte1
LCDOUT $FE,$D4,hex V3.byte0," ",hex V3

l_gaminde
- 11th February 2013, 02:07
I think its solved shifted lower byte left 4 then whole word right 4

LinkMTech
- 11th February 2013, 17:58
why am I getting the 0 in v3 output


You might have figured it out already, but 0C is the correct value when displayed as a WORD or 16 bit value.
8 by itself is 8 in a Byte
C by itself is C in a Byte
But as a Word, 8C is only 140 not 2060 like 80C.

The leading 0 is not displayed for 080C.

l_gaminde
- 11th February 2013, 18:43
Thanks LinkMtech
After messing with it for the weekend I kinda? thought that, its good to know now for sure.
anybody know of a better way of doing this or is what I have after shifting fine.