Page 1 of 2
IDE tool for viewing the ASM for your PB source.
Posted: Thu Jan 31, 2008 11:57 am
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.
Posted: Thu Jan 31, 2008 12:10 pm
by #NULL
very easy now.
thank you.
Posted: Thu Jan 31, 2008 12:33 pm
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.
Posted: Thu Jan 31, 2008 12:40 pm
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!

Re: IDE tool for viewing the ASM for your PB source.
Posted: Thu Mar 25, 2010 4:50 pm
by skywalk
Hey Trond & srod,
Thanks, very helpful as usual...

Re: IDE tool for viewing the ASM for your PB source.
Posted: Tue Feb 22, 2011 5:18 pm
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)
Re: IDE tool for viewing the ASM for your PB source.
Posted: Tue Feb 22, 2011 5:33 pm
by ts-soft
Or use: GetEnvironmentVariable("PB_TOOL_Compiler")
Re: IDE tool for viewing the ASM for your PB source.
Posted: Thu Feb 24, 2011 12:26 pm
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
Re: IDE tool for viewing the ASM for your PB source.
Posted: Thu Feb 24, 2011 3:55 pm
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.
Re: IDE tool for viewing the ASM for your PB source.
Posted: Thu Feb 24, 2011 4:25 pm
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.
Re: IDE tool for viewing the ASM for your PB source.
Posted: Sat Feb 26, 2011 5:47 pm
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

Re: IDE tool for viewing the ASM for your PB source.
Posted: Sat Mar 19, 2011 10:17 pm
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.
Re: IDE tool for viewing the ASM for your PB source.
Posted: Sun Mar 20, 2011 2:42 am
by Demivec
luis wrote:Am I dreaming or something fishy is happening ?
See my previous post regarding the constant #PB_Compiler_Home.
Re: IDE tool for viewing the ASM for your PB source.
Posted: Sun Mar 20, 2011 1:45 pm
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.
Re: IDE tool for viewing the ASM for your PB source.
Posted: Sun Mar 20, 2011 2:46 pm
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.