PB 5.61 - DataSection Label Address Raises Assembler Error

Post bugreports for the Windows version here
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

PB 5.61 - DataSection Label Address Raises Assembler Error

Post by Tristano »

PureBasic 5.61 x64

The code:

Code: Select all

DeclareModule MyMod
  MyLabel:
EndDeclareModule
Module MyMod
EndModule

DataSection
  Data.i MyMod::?MyLabel
EndDataSection
The error:

Code: Select all

PureBasic - Assembler error

PureBasic.asm [622]:
dq l_mylabel
error: undefined symbol 'l_mylabel'.
Yet, it's perfectly legal to reference a module's label:

Code: Select all

*mypoint = MyMod::?MyLabel
... doesn't raise any error, and works! The problem seems to occur only in DataSections.

On the other hand, module procedure address work fine in DataSections:

Code: Select all

DeclareModule MyMod
  Declare MyProc()
EndDeclareModule
Module MyMod
  Procedure MyProc()
    Debug "test"
  EndProcedure
EndModule

Read *procpoint

CallCFunctionFast(*procpoint)

DataSection
  Data.i MyMod::@MyProc()
EndDataSection
... works as expected.
The PureBASIC Archives: FOSS Resources:
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB 5.61 - DataSection Label Address Raises Assembler Err

Post by skywalk »

Code: Select all

DeclareModule MyMod
EndDeclareModule
Module MyMod
  DataSection
    MyLabel:
    Data.s "blah"
    MyLabel2:
    Data.s "blah2"
  EndDataSection
EndModule

DataSection
  MyLabel:
  Data.s "global blah"
  MyLabel2:
  Data.s "global blah2"
EndDataSection

UseModule MyMod
Restore MyMod::MyLabel2
Read.s s$
Debug s$
Restore MyLabel2
Read.s s$
Debug s$
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: PB 5.61 - DataSection Label Address Raises Assembler Err

Post by Tristano »

Hi @skywalk,

I know that you can use Restore with labels inside modules; what I was trying to achive is to Read.i from Data.i containing a label address from a module --- in other words, getting a pointer that points at a specific label, which then I'd use for operations other than Read (eg: access contents from binary included files).

It seems inconsistent that you can use:

Code: Select all

Data.i MyMod::@MyProc()
... but not:

Code: Select all

Data.i MyMod::?MyLabel
... even though both "MyMod::@MyProc()" and "MyMod::?MyLabel" are legal outside a Data context (even without UseModule! if they are in the Module Declaration section).
The PureBASIC Archives: FOSS Resources:
Post Reply