strange word varable array results


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: strange word varable array results

    its not corruption its just an unexpected way of array referencing the bytes are not!!! reversed at all look more closely at post #3

    it appears that single byte extraction of word arrays causes the array indexing to become as byte sized therefore
    to extract a byte from a word array element using .highbyte/.lowbyte (.byte0/.byte1) you need to multiply the element index x 2

    i think its best avoided but it does work
    eg
    var[0] = var[0].byte0/var[0].byte1
    var[1] = var[2].byte0/var[2].byte1
    var[2] = var[4].byte0/var[4].byte1

    x= Gate_Firm_Rev[0]
    Gate_Firm_Rev[1] = x +1
    Gate_Firm_Rev[2] = x +2
    Gate_Firm_Rev[3] = x +3
    Gate_Firm_Rev[4] = x +4
    Gate_Firm_Rev[5] = x +5
    Serout2 PORTb.7,84, [" 0. GateID_word[0] = ",dec GateID_word[0] ," Gate_Firm_Rev[0] = ",DEC Gate_Firm_Rev[0]," Gate_Firm_Rev.highbyte[0] = ",DEC Gate_Firm_Rev.BYTE1[0] ," Gate_Firm_Rev.lowbyte{0} = ",DEC Gate_Firm_Rev.BYTE0[0] ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" 1. GateID_word[1] = ",dec GateID_word[1] ," Gate_Firm_Rev[1] = ",DEC Gate_Firm_Rev[1]," Gate_Firm_Rev.highbyte[1] = ",DEC Gate_Firm_Rev.BYTE1[2] ," Gate_Firm_Rev.lowbyte{1} = ",DEC Gate_Firm_Rev.BYTE0[2] ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" 2. GateID_word[2] = ",dec GateID_word[2] ," Gate_Firm_Rev[2] = ",DEC Gate_Firm_Rev[2]," Gate_Firm_Rev.highbyte[2] = ",DEC Gate_Firm_Rev.BYTE1[4] ," Gate_Firm_Rev.lowbyte{2} = ",DEC Gate_Firm_Rev.BYTE0[4] ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" 3. GateID_word[3] = ",dec GateID_word[3] ," Gate_Firm_Rev[3] = ",DEC Gate_Firm_Rev[3]," Gate_Firm_Rev.highbyte[3] = ",DEC Gate_Firm_Rev.BYTE1[6] ," Gate_Firm_Rev.lowbyte{3} = ",DEC Gate_Firm_Rev.BYTE0[6] ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" 4. GateID_word[4] = ",dec GateID_word[4] ," Gate_Firm_Rev[4] = ",DEC Gate_Firm_Rev[4]," Gate_Firm_Rev.highbyte[4] = ",DEC Gate_Firm_Rev.BYTE1[8] ," Gate_Firm_Rev.lowbyte{4} = ",DEC Gate_Firm_Rev.BYTE0[8] ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" 5. GateID_word[5] = ",dec GateID_word[5] ," Gate_Firm_Rev[5] = ",DEC Gate_Firm_Rev[5]," Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev.BYTE1[10] ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev.BYTE0[10] ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev[0]/256 ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev[0]//256 ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev[1]/256 ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev[1]//256 ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev[2]/256 ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev[2]//256 ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev[3]/256 ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev[3]//256 ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev[4]/256 ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev[4]//256 ,13,10,10,10 ] 'debug
    Serout2 PORTb.7,84, [" Gate_Firm_Rev.highbyte[5] = ",DEC Gate_Firm_Rev[5]/256 ," Gate_Firm_Rev.lowbyte{5} = ",DEC Gate_Firm_Rev[5]//256 ,13,10,10,10 ] 'debug

    output

    ready
    z = 0 GateID_word[z] = 10 Gate_Firm_Rev[z] = 84


    0. GateID_word[0] = 10 Gate_Firm_Rev[0] = 84 Gate_Firm_Rev.highbyte[0] = 0 Gate_Firm_Rev.lowbyte{0} = 84


    1. GateID_word[1] = 8511 Gate_Firm_Rev[1] = 85 Gate_Firm_Rev.highbyte[1] = 0 Gate_Firm_Rev.lowbyte{1} = 85


    2. GateID_word[2] = 16367 Gate_Firm_Rev[2] = 86 Gate_Firm_Rev.highbyte[2] = 0 Gate_Firm_Rev.lowbyte{2} = 86


    3. GateID_word[3] = 65281 Gate_Firm_Rev[3] = 87 Gate_Firm_Rev.highbyte[3] = 0 Gate_Firm_Rev.lowbyte{3} = 87


    4. GateID_word[4] = 63752 Gate_Firm_Rev[4] = 88 Gate_Firm_Rev.highbyte[4] = 0 Gate_Firm_Rev.lowbyte{4} = 88


    5. GateID_word[5] = 49026 Gate_Firm_Rev[5] = 89 Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 89


    Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 84


    Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 85


    Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 86


    Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 87


    Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 88


    Gate_Firm_Rev.highbyte[5] = 0 Gate_Firm_Rev.lowbyte{5} = 89
    Last edited by richard; - 14th April 2015 at 11:59. Reason: POST 3

Similar Threads

  1. Need help - 16f876 - strange results
    By neverenouph in forum mel PIC BASIC
    Replies: 2
    Last Post: - 26th October 2013, 13:24
  2. RC - connection using RCTime produces strange results
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th February 2007, 16:16
  3. Strange Results in Math
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 31st August 2005, 07:09
  4. Help! - Very strange results with ShiftIn/ShiftOut
    By khufumen in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd February 2005, 22:21
  5. First test program, but strange results
    By bartman in forum General
    Replies: 12
    Last Post: - 19th November 2004, 03:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts