How do I compile and link a 32-bit Windows executable using mingw-w64

That depends on which variant of toolchain you’re currently using. Both DWARF and SEH variants (which come starting from GCC 4.8.0) are only single-target. You can see it yourself by inspecting the directory structure of their distributions, i.e. they contain only the libraries with either 64- or 32-bit addressing, but not both. On the other … Read more

how much memory can be accessed by a 32 bit machine?

Yes, a 32-bit architecture is limited to addressing a maximum of 4 gigabytes of memory. Depending on the operating system, this number can be cut down even further due to reserved address space. This limitation can be removed on certain 32-bit architectures via the use of PAE (Physical Address Extension), but it must be supported … Read more

File/DLL installed to {sys} does not appear in C:\Windows\system32

By default the {sys} (system32) is redirected to {win}\SysWOW64 by the OS for 32-bit applications (like Inno Setup). If your DLL (or rather the application) is 32-bit, you actually want the redirection. The SysWOW64 is the System32 equivalent for Windows 32-bit emulation on Windows 64-bit. See also Inno Setup install to SysWOW64 in 32Bit mode. … Read more

Huge performance difference (26x faster) when compiling for 32 and 64 bits

I can reproduce this on 4.5.2. No RyuJIT here. Both x86 and x64 disassemblies look reasonable. Range checks and so on are the same. The same basic structure. No loop unrolling. x86 uses a different set of float instructions. The performance of these instructions seems to be comparable with the x64 instructions except for the … Read more

Using a 32bit or 64bit dll in C# DllImport

I’ve found the simplest way to do this is to import the two methods with different names, and calling the right one. The DLL won’t be loaded until the call is made so it’s fine: [DllImport(“MyDll32.dll”, EntryPoint = “Func1”, CallingConvention = CallingConvention.Cdecl)] private static extern int Func1_32(int var1, int var2); [DllImport(“MyDll64.dll”, EntryPoint = “Func1”, CallingConvention … Read more

What’s the size of a QWORD on a 64-bit machine?

In x86 terminology/documentation, a “word” is 16 bits because x86 evolved out of 16-bit 8086. Changing the meaning of the term as extensions were added would have just been confusing, because Intel still had to document 16-bit mode and everything, and instruction mnemonics like cwd (sign-extend word to dword) bake the terminology into the ISA. … Read more

tech