It is currently Wed Jan 27, 2021 4:58 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Is that possible to disasemble a procedure (a bug?) ?
PostPosted: Fri Apr 29, 2016 10:17 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 24, 2012 10:19 am
Posts: 205
I try to disasemble a procedure, but i've got a problem (a bug ?)

Code:
DisableDebugger


  Procedure ranasm()
  aaaa:
   
  a = (Random(100) * 5) + 2000
  ProcedureReturn a
 
  zzzz:
EndProcedure

MessageRequester("Result", Str(ranasm()))

bbbb:
a = (Random(100) * 5) + 2000
cccc:

  Texte$ = "Code disasembled: " + Chr(13) 
  If ExamineAssembly(?l_ranasm_aaaa, ?l_ranasm_zzzz) ; doesn't work
  ;If ExamineAssembly(?bbbb, ?cccc) ; it works out a procedure
    While NextInstruction()
      Texte$ + RSet(Hex(InstructionAddress()), SizeOf(Integer)*2, "0")
      Texte$ + " " + InstructionString() + Chr(13)
    Wend
  EndIf
 
  MessageRequester("Result", Texte$)



M.


Top
 Profile  
Reply with quote  
 Post subject: Re: Is that possible to disasemble a procedure (a bug?) ?
PostPosted: Fri Apr 29, 2016 10:50 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1678
labels are local to a procedure so you can't access them globally, there's a current thread about it here.
Regarding the topic ("possible to disassemble a procedure?"), you can simply by getting the address of the procedure itself instead of a label:
Code:
Procedure Test()
EndProcedure

Debug "Address=0x" + Hex( @Test() )


Top
 Profile  
Reply with quote  
 Post subject: Re: Is that possible to disasemble a procedure (a bug?) ?
PostPosted: Fri Apr 29, 2016 12:18 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 04, 2013 5:28 pm
Posts: 334
How could referencing l_ranasm_aaaa work ?
Do you see a Basic label l_ranasm_aaaa somewhere ?
There may be a asm label in the generated code (actually with two "l'), but not something you can reference through PB commands.

This may give you an idea about how disassemble the whole procedure, if that's acceptable.

viewtopic.php?p=483177#p483177

That is supposing PB procs have a single exit point. I think they have (?)


Top
 Profile  
Reply with quote  
 Post subject: Re: Is that possible to disasemble a procedure (a bug?) ?
PostPosted: Mon May 02, 2016 2:37 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 24, 2012 10:19 am
Posts: 205
@DontTalkToMe :
Quote:
Do you see a Basic label l_ranasm_aaaa somewhere ?

In the doc, here: https://www.purebasic.com/documentation ... edasm.html

we can read:
Quote:
- When you reference a label, you must put the prefix 'll_' before the name. This is because PureBasic add a 'll_' before a BASIC label to avoid conflict with internal labels. The label need to be referenced in lowercase when using the in-line ASM. If the label is defined in a procedure, then its prefix is 'l_procedurename_', in lowercase.


Do you see the "l_ranasm_aaaa" now ? :P

I think the doc has to be more explicit about that.

M.


Top
 Profile  
Reply with quote  
 Post subject: Re: Is that possible to disasemble a procedure (a bug?) ?
PostPosted: Mon May 02, 2016 3:01 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 04, 2013 5:28 pm
Posts: 334
Mesa wrote:
Do you see the "l_ranasm_aaaa" now ? :P


No, I don't. :)

myself wrote:
Do you see a Basic label l_ranasm_aaaa somewhere ?
There may be a asm label in the generated code (actually with two "l'), but not something you can reference through PB commands.


There is no l_ranasm_aaaa: BASIC label, there is a aaaa: BASIC label, local to the procedure.

The section of the manual you are citing says the same thing I tried to explain above. It's talking about how BASIC labels are renamed when converted to ASM labels, accessible through inline ASM.
And it's already explicit about that.
In your code you are passing to a BASIC command labels (incidentally not existing anyway) meant to be accessed through inline ASM.
That's all.

The help on the other hand is wrong about the "l" and "ll" but it's irrelevant in this specific case, your code wouldn't work even using the right label ll_ranasm_aaaa:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye