Page 1 of 1
Pointer/Structur Casting
Posted: Thu May 06, 2010 3:03 pm
by crackhead
Hi, would it be possible to easily implement the following?:
Code: Select all
var.l = $5566
*heh.Long = @var
Structure struc1
var1.l
EndStructure
Structure struc2
var2.b
EndStructure
varstruct.struc1\var1 = $6655
;for more comfort when messing with bytes
;Debug *heh.Byte\b ;shows $55
;Debug varstruct.struc2\var2 ;shows $66
Re: Pointer/Structur Casting
Posted: Thu May 06, 2010 3:25 pm
by Rescator
I'm not entirely sure what you want here but...
I've done a lot of similar things using structureunions which is a brilliant time saver.
Code: Select all
Define var.l
var = $5566
Structure struc1
StructureUnion
value.l
valuebytes.b[4]
EndStructureUnion
EndStructure
Define *heh.struc1
*heh=@var
Debug Hex(*heh\value)
Debug Hex(*heh\valuebytes[0])
Debug Hex(*heh\valuebytes[1])
Debug Hex(*heh\valuebytes[2])
Debug Hex(*heh\valuebytes[3])
Re: Pointer/Structur Casting
Posted: Thu May 06, 2010 3:28 pm
by srod
Could use something like the following :
Code: Select all
Structure cast
StructureUnion
b.b
w.w
l.l
i.i
q.q
EndStructureUnion
EndStructure
var.l = $55667788
*heh.cast = @var
Debug Hex(*heh\b, #PB_Byte)
Debug Hex(*heh\w, #PB_Word)
Debug Hex(*heh\l, #pb_long)
Re: Pointer/Structur Casting
Posted: Thu May 06, 2010 4:03 pm
by crackhead
yeah, something like this, but couldn't such a temorary cast like '*var.Integer : *var.Byte\b' be native?