This code will allow you to read the current data pointer easily...
Code: Select all
Procedure RestorePointer()
!MOV eax,dword [PB_DataPointer]
ProcedureReturn
EndProcedure
Debug("Uninitialised restore pointer: "+Hex(RestorePointer()))
Restore MyData
Debug("MyData address: "+Hex(?MyData))
Debug("Current restore pointer: "+Hex(RestorePointer()))
Read var
Debug("Restore pointer after read: "+Hex(RestorePointer()))
DataSection
MyData:
Data.l 123
EndDataSection
I tried to extend this with:
Code: Select all
Procedure RestorePointer(position=0)
!MOV eax,dword [PB_DataPointer]
!MOV edx,dword [p.v_position]
!CMP edx,0
!JE @f
!MOV dword [PB_DataPointer],edx
!@@
ProcedureReturn
EndProcedure
Debug("Uninitialised restore pointer: "+Hex(RestorePointer()))
Restore MyData
Debug("MyData address: "+Hex(?MyData))
Debug("Current restore pointer: "+Hex(RestorePointer()))
Read var
Debug("Restore pointer after read: "+Hex(RestorePointer(?MyData)))
Debug("Restore pointer after optional setting: "+Hex(RestorePointer()))
DataSection
MyData:
Data.l 123
EndDataSection
But I get an error on compilation with the
!@@ line, purebasic insists that it is an illegal instruction, but it's actually a way of doing anonymous labels in fasm.
Fasm documentation wrote:The @@ name means anonymous label, you can have defined many of them in the source. Symbol @b (or equivalent @r) references the nearest preceding anonymous label, symbol @f references the nearest following anonymous label. These special symbol are case-insensitive.
Is this a bug in the PureBasic compiler? I thought that
! would pass anything following (on the same line) direct to fasm without checks or interference.