Author Topic: First 64 bit Windows compilation  (Read 8699 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
First 64 bit Windows compilation
« on: November 13, 2011, 03:00:02 AM »
I'm starting to get a grip on this 64bit stuff. The calling convention is good for low-level coding due to its use of the extra registers instead the stack, but not so good for high level programming where expressions and functions may be passed as arguments, and inevitably the stack must be used to hold the values before they are passed.

The stack frame for the parameters has to be kept aligned to 16 bytes whenever an OS call is made, and floats have to be passed in the SIMD (xmm0..3) registers, which is a considerable pain when many functions require the services of the Floating point processor (FPU) .

More to be done but 2 independent executables are included below, and the source code which works on the latest Oxygen-in-progress (just posted). You will see that the 64 bit binary is significantly larger due to the 64bit opcode prefixes and stack assignment encodings.

Code: OxygenBasic
  1.  
  2.   'Charles Pegge
  3.  '13 Nov 2011
  4.  
  5.   '===========
  6.  'COMPILATION
  7.  '===========
  8.  
  9.   $ filename "t.exe"
  10.   '
  11.  '$ CompileDependent
  12.  '$ Compile32BitIndependent
  13.  '$ Compile64BitIndependent
  14.  '
  15.  '
  16.  #ifdef CompileDependent
  17.     #file filename
  18.     const string title="OXYGEN BASIC Compiled"
  19.   #else
  20.     const string title="OXYGEN BASIC"
  21.   #endif
  22.   '
  23.  '
  24.  #ifdef Compile64BitIndependent
  25.     #include   "../../inc/RTL64.inc"
  26.     const string title="OXYGEN BASIC 64-bit"
  27.   #endif
  28.   '
  29.  '
  30.  #ifdef Compile32BitIndependent
  31.     #include   "../../inc/RTL32.inc"
  32.     const string title="OXYGEN BASIC 32-bit"
  33.   #endif
  34. ....
  35.  

Charles
« Last Edit: November 13, 2011, 01:11:29 PM by Charles Pegge »

efgee

  • Guest
Re: First 64 bit Windows compilation
« Reply #1 on: November 13, 2011, 01:37:15 PM »
Good job, works great  8)

If you need a 64bit debugger:
I use the free Visual DuxDebugger

Take care

Charles Pegge

  • Guest
Re: First 64 bit Windows compilation
« Reply #2 on: November 13, 2011, 02:01:41 PM »

Thank you Frank. I've made a note of the link.

It should be plain sailing from now on. The first hurdle was to get the PE headers correct. The next was to display a message box. After that the biggest step was to get the float_to_ascii and hex functions working. With these working, the diagnostics became much easier.

Charles

efgee

  • Guest
Re: First 64 bit Windows compilation
« Reply #3 on: November 13, 2011, 05:12:30 PM »
Tested the ClassLibrary examples  :'(

It seems there is still some work to do...

Charles Pegge

  • Guest
Re: First 64 bit Windows compilation
« Reply #4 on: November 13, 2011, 10:39:43 PM »

Yes of course Frank. My task for the next few weeks is to get the more complex programs working.


Charles

efgee

  • Guest
Re: First 64 bit Windows compilation
« Reply #5 on: November 13, 2011, 11:31:03 PM »
Understood.
Happy hunting  ;D

Charles Pegge

  • Guest
Re: First 64 bit Windows compilation
« Reply #6 on: November 22, 2011, 01:22:28 AM »
I've now got 64 bit binaries working with the hard stuff: Windows-GUI, OpenGL, GDIplus images, COM (SAPI5 Speech engine IspVoice) and the ClassLibrary demo.

Latest Oxygen-in-Progress  21 Nov 2011

Quote

Programs Successfully Compiling to 64 bit executables

examples/GUI/

  ChildWin.o2bas
  HelloWin.o2bas
  FileFuncs.o2bas
  GraphWin.o2bas
  KeyboardCodesCmpl.o2bas
  OpenglChildWins.o2bas
  OpenglWin1.o2bas
  OpenglWin2.o2bas
  OpenglWin3.o2bas
  OpenglWinTex.o2bas
  PortViewer1.o2bas

examples/COM/

  Sapi4Cmpl.o2bas

examples/OOP/ClassLibrary64/

  ClassLibrary64.o2bas
  ClassLibraryTest64.o2bas
  

Charles
« Last Edit: November 22, 2011, 01:24:08 AM by Charles Pegge »

kryton9

  • Guest
Re: First 64 bit Windows compilation
« Reply #7 on: November 22, 2011, 11:07:50 AM »
Thanks Charles, will grab the latest and test them out.

JRS

  • Guest
Re: First 64 bit Windows compilation
« Reply #8 on: November 22, 2011, 11:22:53 AM »
Charles,

Is your plan to maintain both a 32 and 64 bit version of OxygenBasic or is it 64 bit moving forward?

John

Charles Pegge

  • Guest
Re: First 64 bit Windows compilation
« Reply #9 on: November 22, 2011, 11:48:48 AM »

Hi John,

My current plan is to keep the Oxygen compiler itself 32 bit, producing 32 and 64 bit binaries on demand.

Charles

JRS

  • Guest
Re: First 64 bit Windows compilation
« Reply #10 on: November 22, 2011, 02:04:20 PM »
Sounds like a wise and safe direction to take at this juncture in the development cycle.


Petr Schreiber

  • Guest
Re: First 64 bit Windows compilation
« Reply #11 on: November 23, 2011, 12:17:58 AM »
Go 64bit, go :)

I am very happy you are working on this Charles...


Petr

JRS

  • Guest
Re: First 64 bit Windows compilation
« Reply #12 on: November 23, 2011, 04:59:17 PM »
Quote
My current plan is to keep the Oxygen compiler itself 32 bit, producing 32 and 64 bit binaries on demand.

OxygenBasic might become a popular tool to build 64 bit DLLs. What is your stand on .NET support?


Charles Pegge

  • Guest
Re: First 64 bit Windows compilation
« Reply #13 on: November 23, 2011, 07:57:53 PM »

I have never knowingly used NET but perhaps Petr is familiar with this area. Externally produced DLLs fall into the category of "unmanaged code".

Charles

Petr Schreiber

  • Guest
Re: First 64 bit Windows compilation
« Reply #14 on: November 23, 2011, 11:46:13 PM »
Hi,

you can call "normal" and COM DLLs from .NET application, so for this purpose no specific effort from Charles side should be necessary.

Adding support for .NET DLLs would be loss of time at the moment - even express editions of VisualStudio already do them very well.
What interests me are high performance classic DLLs, which is what Charles can do.

Is there any Oxygen example on 64bit "normal" DLL? I could test it for interfacing with C# during weekend.


Petr