Author Topic: (forgotten) How to get C and Assembly listing of programs  (Read 3654 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
(forgotten) How to get C and Assembly listing of programs
« 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).

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #1 on: November 18, 2020, 11:16:22 pm »
What kind of listing exactly?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #2 on: November 18, 2020, 11:18:48 pm »
I'm not quite sure what it is exactly you are searching for.
Shuwatch!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #3 on: November 18, 2020, 11:46:27 pm »
Are you searching for some type listing from a compiler etc?

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #4 on: November 18, 2020, 11:58:30 pm »
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?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #5 on: November 19, 2020, 12:07:32 am »
internal\temp# holds the majority of your translated c-code, with # corresponding to the number of instances of the IDE you have open.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #6 on: November 19, 2020, 12:29:29 am »
@ 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???

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #7 on: November 19, 2020, 12:34:23 am »
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?


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #8 on: November 19, 2020, 12:44:41 am »
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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #9 on: November 19, 2020, 12:50:47 am »
@ Steve

Thank you very much.

You have made it very clear to me.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #10 on: November 19, 2020, 01:28:29 am »
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?
« Last Edit: November 19, 2020, 02:40:23 am by NOVARSEG »

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: (forgotten) How to get C and Assembly listing of programs
« Reply #11 on: November 19, 2020, 06:49:47 pm »
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?
« Last Edit: November 19, 2020, 07:15:54 pm by NOVARSEG »