IDE tool for viewing the ASM for your PB source.

Share your advanced PureBasic knowledge/code with the community.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

IDE tool for viewing the ASM for your PB source.

Post by srod »

Hi,

just a simple tool which you may or may not find of some use. All it does is take the current source you have open in the PB IDE and generates the corresponding assembly code and loads it into notepad etc.

Compile to "commentedASM.exe" :

Code: Select all

file$=ProgramParameter(0)
dir$ = GetPathPart(file$)
DeleteFile(dir$+"PureBasic.asm")

If file$ And FileSize(file$)>0
  Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /commented", dir$, #PB_Program_Hide|#PB_Program_Wait)
  dir$+"PureBasic.asm"
  If Compiler  And FileSize(dir$)>=0
    RunProgram("notepad.exe", dir$,"")
  Else
    MessageRequester("Error!", "There was an error creating the assembly code file.")
  EndIf
EndIf
Now add the commentedASM.exe tool to the IDE tools menu by selecting "Configure Tools".

(Make sure that you select the name of the commentedASM.exe (with full path) in the CommandLine option.
In the 'Arguments:' control enter "%TEMPFILE" with the quotes. Select the 'Run Hidden' checkbox.)

**EDIT : change the command RunProgram("notepad.exe", dir$,"") to simply RunProgram(dir$) if your system is set up to deal directly with .asm files etc.
Last edited by srod on Sun Jan 24, 2010 9:59 am, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

very easy now. :D
thank you.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I won't say that I already made this (oups there I said it), because I'm not using it any more. Instead I use a bat file:

Code: Select all

@echo off
cd "c:\programfiler\purebasic 4\compilers"
pbcompiler %1 /COMMENTED
if errorlevel 1 goto wait
start PureBasic.asm
exit
:wait
pause
The advantage is that it pauses to show you the compilation error if any.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes, up until a request was made I always used a batch file as well for those same reasons! Still no reason why you cannot adjust the above tool in order to pipe the compiler's output to the tool etc.

**EDIT : sorry Trond, must have missed your example. I did a search... oh well! :)
I may look like a mule, but I'm not a complete ass.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: IDE tool for viewing the ASM for your PB source.

Post by skywalk »

Hey Trond & srod,
Thanks, very helpful as usual... :)
Last edited by skywalk on Tue Jul 08, 2014 12:21 am, edited 1 time in total.
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: IDE tool for viewing the ASM for your PB source.

Post by Demivec »

I found that the code srod posted needs one line changed to work with v4.51 due to a change in the constant #PB_Compiler_Home, that now adds "\" at the end of the constants value, at least for me.

The change line 6 to:

Code: Select all

Compiler = RunProgram(#PB_Compiler_Home+"Compilers\pbcompiler", Chr(34)+File$+Chr(34)+" /commented", dir$, #PB_Program_Hide|#PB_Program_Wait)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: IDE tool for viewing the ASM for your PB source.

Post by ts-soft »

Or use: GetEnvironmentVariable("PB_TOOL_Compiler")
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Re: IDE tool for viewing the ASM for your PB source.

Post by Hysteria »

Hi Guys

I'm interested in this utility - would like to see the PB output but can't get srod's program to work (have done Demivec's PB4.51 mod).

Each time I try to invoke it from the IDE, I get the error 'There was an error creating the assembly code file'. I've double-checked the settings and can't see why. I'm assuming that one just ensures the relevant source tab is selected in the IDE (assuming more than one source is present) and then selects the newly-added tool in the tools menu.

I've tried running it from the IDE and it completes without errors, though doesn't appear to do anything (notepad isn't invoked, etc.) Having put a 'debug' in to display 'file$' and 'dir$' both return blank. I don't know if that's relevant though as I'm new to PB and haven't found my way around invoking the compiler in these ways.

I was going to try Trond's batchfile but I couldn't see where it gets the source name and how I would actually use it. Sorry for being a dunce, I'm sure I'll get all of this down in the fullness of time but could do with some help right now.

Cheers

Hysteria
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: IDE tool for viewing the ASM for your PB source.

Post by Demivec »

@Hysteria: Is the tool setup to take the argument "%TEMPFILE" ? If it isn't then it won't have the source file passed as a parameter to the compiler and will fail.
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Re: IDE tool for viewing the ASM for your PB source.

Post by Hysteria »

Demivec wrote:@Hysteria: Is the tool setup to take the argument "%TEMPFILE" ? If it isn't then it won't have the source file passed as a parameter to the compiler and will fail.
Hi Demivec

Yes, copied from the argument's field:
"%TEMPFILE"

If it's relevant, I'm trying it on Win 7 64bit (demo version because I'm at work), not yet tried in on full 32 bit PC/Mac versions at home.
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Re: IDE tool for viewing the ASM for your PB source.

Post by Hysteria »

Just tried it on my Win 7 32bit full version and it works a treat.

Don't know if it's the fact I was using the demo version on my (work) Win7 64 or whether it's something to do with the 64 bit version itself...but the most important thing is it works on my main platform. Nice one guys :D
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: IDE tool for viewing the ASM for your PB source.

Post by luis »

Am I dreaming or something fishy is happening ?

Code: Select all

file$=ProgramParameter(0)
dir$ = GetPathPart(file$)
DeleteFile(dir$+"PureBasic.asm")

If file$ And FileSize(file$)>0
  Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /commented", dir$, #PB_Program_Hide|#PB_Program_Wait)
  dir$+"PureBasic.asm"
  If Compiler  And FileSize(dir$)>=0
    RunProgram("notepad.exe", dir$,"")
  Else
    MessageRequester("Error!", "There was an error creating the assembly code file.")
  EndIf
Else
   MessageRequester("What?", "How come I'm visualized even when the test is successful ?")
EndIf

Same as the original code by srod, but with

Code: Select all

Else
   MessageRequester("What?", "How come I'm visualized even when the test is successful ?")
added.

The message is always shown.


Code: Select all

file$=ProgramParameter(0)
dir$ = GetPathPart(file$)
DeleteFile(dir$+"PureBasic.asm")

If file$ And FileSize(file$)>0
  Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /commented", dir$, #PB_Program_Hide|#PB_Program_Wait)
  dir$+"PureBasic.asm"
  If Compiler  And FileSize(dir$)>=0
    RunProgram("notepad.exe", dir$,"")
  Else
    MessageRequester("Error!", "There was an error creating the assembly code file.")
  EndIf
  
  End ; <--- even this doesn't stop it !
Else
   MessageRequester("What?", "How come I'm visualized even when the test is successful ?")
EndIf

I tested it launching the exe from the Tools menu as indicated in the first post.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: IDE tool for viewing the ASM for your PB source.

Post by Demivec »

luis wrote:Am I dreaming or something fishy is happening ?
See my previous post regarding the constant #PB_Compiler_Home.
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: IDE tool for viewing the ASM for your PB source.

Post by luis »

Demivec wrote: See my previous post regarding the constant #PB_Compiler_Home.
I saw it, sorry but I don't understand what has to do with what I'm saying. :?:

Removing the "\" gives the same result anyway. The message is displayed when it shouldn't. Did you try it ?

I tried to make it happen in debug, replacing the param with a string ponting to a pb source, it seem to happen only with the compiled exe.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: IDE tool for viewing the ASM for your PB source.

Post by Demivec »

luis wrote:
Demivec wrote: See my previous post regarding the constant #PB_Compiler_Home.
I saw it, sorry but I don't understand what has to do with what I'm saying. :?:

Removing the "\" gives the same result anyway. The message is displayed when it shouldn't. Did you try it ?

I tried to make it happen in debug, replacing the param with a string ponting to a pb source, it seem to happen only with the compiled exe.
Your previous post said "the message is always shown". You didn't indicate anything else happened so I assumed it was because the filename and path were incorrectly constructed. I had corrected this code for myself and referred you to my previous post.

You however have updated the details and said that notepad is opened and that the second message is displayed, which shouldn't happen. I tested your code and did not observe this; the second message was never displayed after the assembled code was loaded in notepad.
Post Reply