QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Richard on November 18, 2020, 10:03:23 pm
-
A long time ago I was able to get a C listing of my programs - I have forgotten how to do this.
Also how to also get assembly listing - a cmd line version would be OK (and preferred).
-
What kind of listing exactly?
-
I'm not quite sure what it is exactly you are searching for.
-
Are you searching for some type listing from a compiler etc?
-
A long time ago - if I wrote a program (say X.BAS), as well as the X.EXE being generated from the compilation stage (pressing [F5]) - there was an option to also have the C code (I do not know what version of C) also. Possibly the C code ended up in some temp folder.
If I understand correctly, QB64 always goes through the process of generating C code (from X.BAS), and THEN generates from the C code an assembly file (I think) and finally from the assembly file the X.EXE is generated.
Hope above clarifies what I want?
-
internal\temp# holds the majority of your translated c-code, with # corresponding to the number of instances of the IDE you have open.
-
@ Steve
Thanks - it appears that a number of .TXT files are generated (stored in appropriate internal/temp#)
Main.TXT (the largest of all .txt files) appears to be the "C" file relating uniquely to my program. So the C file does not have a name corresponding to the program file (X.BAS or even TMP... or TEMP...) and ALWAYS has .txt extension?
Would the next stage in compilation also produce a assembly file somewhere???
-
Quick Basic source file translated to c++ source
C++ source file complied by QB64 to object file
object file linked by link to EXE file
is that correct?
-
Nope. Our c-compiler basically reads those txt files and compiles from them.
If you look in internal\c\qbx.cpp, you’ll find the “universal side” of your program. It’s what hold all the basic c-code which declares our libraries and such. Down inside it, you’ll find the list of include statements for main.txt and all, which basically work as $INCLUDE does in QB64.
What gets compiled is qbx.cpp, with all your code translated into internal\temp, and included into it. AFAIK, there’s no step between translate and compile, which assembles all that code into a single file. qbx.cpp simply #includes all those files, as they are, in itself.
-
@ Steve
Thank you very much.
You have made it very clear to me.
-
Ok thanks all
found this here
https://github.com/Galleondragon/qb64/pull/16
****
I think this overview will provide you with enough insight to get a general idea, though I'm still new to the codebase myself and this is based solely on my own exploration:
internal/c/qbx.cpp: The C++ source file compiled and linked to create a binary.
internal/c/libqb.cpp: The C++ source file compiled and linked to create libqb_XXXXXX.o. When using the setup script, XXXXXX is "setup". When using the QB64 compiler, it's a string based on the version of QB64 and a set of dependencies that should be loaded to make the program work, such as sockets, fonts, etc. For OS X, libqb.mm is used instead, which simply includes libqb.cpp.
internal/source: Contains all files that would be in internal/temp if compiling source/qb64.bas using an existing qb64 binary.
internal/temp: A work directory containing all files that get included in internal/c/qbx.cpp to make your program work.
source: Contains the QB64 source code for the qb64 compiler binary, qb64.bas being the "main" file.
****
Ok it looks like there must be a translation from Quick Basic source to C++ source
In the above quote, "C++ source" is mentioned twice but we are writing BAS files so where is the translator?
Is it easier to write a Quick Basic source to c++ source translator or a custom C++ complier?
-
Quick Basic source file translated to C++ source file by QB64 which produces qbx.cpp
qbx.cpp is (contains) C++ source code
qbx.cpp is complied by QB64 which produces object file
object file linked by link.exe to make EXE file
is that correct?