Author Topic: QB64 <-> Cpcdos compatibilities (Message for main QB64 developper(s))  (Read 155 times)

cpcdos

  • Newbie
  • *
  • Posts: 2
Hello!

First, we would like to ask you, there are not problems if we using Win32PE executables generated by your qb64, on another platform? (licence?)


We want to introduce your QB64 Win32PE (geneated exe) compatibilities under our Cpcdos OSx kernel. http://cpcdososx.wixsite.com/cpcdos (French website)

We are some problem in your exe generated by your compiler, like your entrypoint is not called "main??? And our method is to search the symbol under name of "main". we not found this in your geneated asm code. We can extract EntryPoint address but we have temporary some problems..  ::)

We want to know, how is called the symbol of entrypoint generated by your QB64 compiler ?

Best regards
Sébastien FAVIER


Excuse me for my bad english level
« Last Edit: February 06, 2017, 10:29:50 am by cpcdos »

waltersmind

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 602
  • TheJoyfulProgrammer.com
    • The Joyful Programmer
Re: QB64 <-> Cpcdos compatibilities (Message for main QB64 developper(s))
« Reply #1 on: February 06, 2017, 11:40:27 am »
Sébastien,

First, welcome to the forum.

You can run all your apps created in QB64 on any platform that you can get them to run on without having any issues with a license.

I never heard of "Cpcdos OSx kernel" Is it a Linux OS?

QB64 does not compile straight to machine code. All QB64 code gets translated to C++ code, then the C++ compiler (GCC.exe) compiles the C++ to machine language. QB64 is like many modern day high-level languages where it is a translator, not a compiler.

There is no "main" entry point. There are three entry points defined in QB64. The one for Windows is called, "MAIN_LOOP_WINDOWS" and the one for Linux is called, "MAIN_LOOP_LINUX". Both of them call the third entry point called, "MAIN_LOOP".

For those who are curious, these main loops can be found in the "libqb.cpp" file located in the "\internal\c\" directory, starting on line 29479 in the current dirty build.

EDIT: I almost forgot. There are three entry points in "qbx.cpp" (same directory and starting on line 1992) as well. "QBMAIN_WINDOWS", "QBMAIN_LINUX", and "QBMAIN". For whatever reason, I can not remember which entry point sets are actually used. Look for all six that I mentioned above.

Let us know if you have any other questions.


Walter Whitman
The Joyful Programmer
www.TheJoyfulProgrammer.com/qb64/forum/
« Last Edit: February 06, 2017, 11:55:23 am by waltersmind »
Please visit my QB64 programming forum located at http://www.TheJoyfulProgrammer.com and my YouTube Channel: https://www.youtube.com/c/Thejoyfulprogrammer

cpcdos

  • Newbie
  • *
  • Posts: 2
Re: QB64 <-> Cpcdos compatibilities (Message for main QB64 developper(s))
« Reply #2 on: February 11, 2017, 02:59:26 am »
Hi Walter,
Thank you for your reply. And ecuse me for my late reply (I've exams..)

Quote
You can run all your apps created in QB64 on any platform that you can get them to run on without having any issues with a license.
Okay thank you ;)

Quote
I never heard of "Cpcdos OSx kernel" Is it a Linux OS?
It's not an Linux OS, Cpcdos in french is "Crée Pour Concevoir Des OS" in english "Created For Concept Your OS". It's a new kernel project for create easily your OS with his "CpcdosC+" language or in C++11, 14, 17, Win32 exe, Clang...

It's an French/English kernel project started there are 6 years ago. For the moment he boot with FreeDos bootloader, so Cpcdos it's an "co-kernel" for the moment. This 32 bits co-kernel support native Win32 PE console code executable, Clang/LLVM bytecode, Network TCP/UDP, ICMP, 32 bits GUI, UTF-8, BMP, JPG, PNG, 3D OpenGL mesa, 3D GZE Engine, multi-threading. He include his programing language called "CpcdosC+" for create your easily your OS. This is an OS example created there a 2 years ago, with Cpcdos OS2.0.5 Alpha 3.9, CraftyOS: http://cpcdososx.wixsite.com/craftyos (French web site sorry) The next Cpcdos update will be avaiable for the end of year 2017 with english/french CpcdosC+ syntax.


Quote
There is no "main" entry point. There are three entry points defined in QB64. The one for Windows is called, "MAIN_LOOP_WINDOWS" and the one for Linux is called, "MAIN_LOOP_LINUX". Both of them call the third entry point called, "MAIN_LOOP".
Quote
EDIT: I almost forgot. There are three entry points in "qbx.cpp" (same directory and starting on line 1992) as well. "QBMAIN_WINDOWS", "QBMAIN_LINUX", and "QBMAIN". For whatever reason, I can not remember which entry point sets are actually used. Look for all six that I mentioned above.
It's very strange, my PE exe loader can't found symbols while they are present... I will debug my code after my high school exams  ;D
Otherwise i will extract entry point in PE header, like Microsoft NT kernel..

I will keep you informed. Thank you for your for your attention.

Regards
Sébastien FAVIER
PS:Excuse me for my bad english level

Johny B.

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 1449
Re: QB64 <-> Cpcdos compatibilities (Message for main QB64 developper(s))
« Reply #3 on: February 11, 2017, 05:55:29 am »
I'm disappointed you could get this so wrong, Walter.

MAIN_LOOP() handles various services that a QB64 program expects, such as filling input buffers. The MAIN_LOOP_WINDOWS() and MAIN_LOOP_LINUX() are the platform specific versions that are called.
QBMAIN() is the function that executes your BASIC code. It runs in a different thread to MAIN_LOOP. Again, there are platform-specific versions.

However, execution begins at the main() function, like any C++ program. It does some initialisation then spawns threads for MAIN_LOOP and QBMAIN (and some others...).

main() itself is called by the CRT (C runtime library), which is added by the compiler.

The CRT is what is actually called by the Windows loader/runtime linker. Some inspection with objdump shows this function to be _WinMainCRTStartup. That is where execution begins, as far as I can tell.

However, the compiler is not required to include its name in the symbol table; I had to compile with debugging turned on to get it to show. The only reliable way to find the entry point is by looking at AddressOfEntryPoint in the PE header. I would focus on getting your PE loader to correctly lookup this value. Do note that some documentation mentions stuff related to TLS (Thread Local Storage) that could be important, so you might want to look that up.

One of the most important things in systems programming is to read, read, read!