No announcement yet.

Endians are attacking - Help

  • Filter
  • Time
  • Show
Clear All
new posts

  • Endians are attacking - Help

    I am wondering what the native format is in PBDLL.
    If I create a long variable and place a value it,
    then use the BIN$(LongVariable, 32),
    I see the value in Big Endian format.
    If I have a structure with several long fields,
    and I just grab all the bytes from the structure,
    will the bytes be in Big Endian or Little Endian.

    Type strTest
    One as Long
    Two as Long
    End Type

    Union uTest
    All as String * 8
    Indi as strTest
    End Union

    GLOBAL Struct as uTest

    Will Struct.All be the 2 longs in Big Endian order?
    Does PBDLL have an easy way of converting between the different
    Endian type?


    Ben Clark
    [email protected]
    If at first you don't succeed, destroy all evidence that you tried.

  • #2
    PB/DLL uses native format for x86 PCes - Little Endian.
    If x is long and x = &H01020304, at address VarPtr(x) is located &H04; VarPtr(x) + 1 - &H03...
    But, of course, Hex$(x, 8) will display 01020304.
      #Compile Exe
      #Register None
      Type strTest
        One As Long
        Two As Long
      End Type
      Function PbMain
         Dim x As strTest
         x.One = &H01020304
         x.Two = &H55667788
         MsgBox Hex$(x.One, 8)
         MsgBox Hex$(x.Two, 8)
         Dim b As Byte Ptr
         b = VarPtr(x)
         MsgBox Hex$(@b[0], 2) + Hex$(@b[1], 2) + Hex$(@b[2], 2) + Hex$(@b[3], 2)
         MsgBox Hex$(@b[4], 2) + Hex$(@b[5], 2) + Hex$(@b[6], 2) + Hex$(@b[7], 2)
      End Function
    [This message has been edited by Semen Matusovski (edited February 15, 2001).]