RAM allocation lazarus / 34-Windows ---------------------------------------------------------------------- StephanB · 2020-11-30 06:36 Just for curiosity: When a program coded for Win32 is run on Win64, hoch much RAM does a DOUBLE variable (8 bytes) use? 8 or 16 bytes? ---------------------------------------------------------------------- Handoko · 2020-11-30 06:46 Hello StephanB, Welcome to the forum. According to the documentation, double variables are always 8-bytes. (On that page, you need to scroll down to see the table). https://wiki.freepascal.org/Variables_and_Data_Types ---------------------------------------------------------------------- circular · 2020-11-30 08:15 Most types do not change their size. There are some exceptions though like IntPtr which represents an offset of a pointer and thus changes depending on the processor. What can change is the endianness, so if you write/read values from a stream, you need to make sure it is the same endianness or swap the byte order otherwise. ---------------------------------------------------------------------- howardpc · 2020-11-30 08:36 Two particular types Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SizeInt, SizeUIntare designed to change size according to platform bitness, as their names clearly indicate. ---------------------------------------------------------------------- lucamar · 2020-11-30 11:38 Quote from: circular on November 30, 2020, 09:15:48 amThere are some exceptions though like IntPtr which represents an offset of a pointer and thus changes depending on the processor. Quote from: howardpc on November 30, 2020, 09:36:57 amTwo particular types Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SizeInt, SizeUIntare designed to change size according to platform bitness, as their names clearly indicate. Correct me if I'm wrong but those size differences are set at compile time, aren't they? So a 32bit binary won't magically use 64bit SizeInt if run in, say, Windows 64bit, will it? ---------------------------------------------------------------------- PascalDragon · 2020-11-30 12:08 Quote from: lucamar on November 30, 2020, 12:38:56 pmCorrect me if I'm wrong but those size differences are set at compile time, aren't they? So a 32bit binary won't magically use 64bit SizeInt if run in, say, Windows 64bit, will it? These types only differ at compile time. ---------------------------------------------------------------------- Seenkao · 2020-11-30 16:02 Если я правильно понял вопрос, то уже скомпилированная программа под Win32, должна использовать отведённую ей область памяти как для Win32, а не для Win64. А регистры будут использоваться 64-х битные (я могу ошибаться). это не IDE решает, это решает сама системаWin32/Win64. google translate: If I understood the question correctly, then a program already compiled for Win32 should use the memory area allocated to it as for Win32, and not for Win64. And the registers will be 64-bit (I could be wrong). The IDE does not solve this, this is decided by the Win32/Win64 system itself. ---------------------------------------------------------------------- circular · 2020-11-30 17:57 Well the question isn't clear about whether or not the program is compiled for the target system. With a cross platform approach, I imagine that the program would be recompiled for each specific system but it is true that on Windows you can still run 32-bit programs. The 32-bit environment is emulated and in theory the programs runs the same as if the machine were 32-bit. Though that might not be true forever. ---------------------------------------------------------------------- Thaddy · 2020-11-30 18:34 Quote from: circular on November 30, 2020, 06:57:08 pmWell the question isn't clear about whether or not the program is compiled for the target system. With a cross platform approach, I imagine that the program would be recompiled for each specific system but it is true that on Windows you can still run 32-bit programs. The 32-bit environment is emulated and in theory the programs runs the same as if the machine were 32-bit. Though that might not be true forever. Most - if not all -  of that is also true for Linux: multiarch: https://wiki.debian.org/Multiarch On both Windows and Linux it is NOT emulated but a real native sub system.. ---------------------------------------------------------------------- circular · 2020-12-01 00:37 I do not disagree ---------------------------------------------------------------------- PascalDragon · 2020-12-01 08:15 Quote from: Seenkao on November 30, 2020, 05:02:18 pmIf I understood the question correctly, then a program already compiled for Win32 should use the memory area allocated to it as for Win32, and not for Win64. And the registers will be 64-bit (I could be wrong). If you run a 32-bit application on a 64-bit OS then the registers will be as if the application is running on a 32-bit variant of the CPU. So in case of x86 the general purpose registers (EAX, etc.) will be 32-bit not 64-bit. ---------------------------------------------------------------------- circular · 2020-12-01 09:45 Well the program is made to believe the OS is 32-bit and that the registers are 32-bit. Though at some level, the registers are in fact 64-bits even if the upper bits are ignored by 32-bit instructions. At the assembler level, you can in fact access the 64-bit registers by adding the operand-size override prefix (0x48 for 64-bit). That's a byte you would add in the machine code just before the instruction you want to modify. You could do the same when running 16-bit programs on a 32-bit processor. The prefix to use 32-bit operands was 0x66. ---------------------------------------------------------------------- Seenkao · 2020-12-01 10:04 Quote from: circular on December 01, 2020, 10:45:23 amAt the assembler level, you can in fact access the 64-bit registers by adding the operand-size override prefix (0x48 for 64-bit). That's a byte you would add in the machine code just before the instruction you want to modify. You could do the same when running 16-bit programs on a 32-bit processor. The prefix to use 32-bit operands was 0x66. I will lose it ... ---------------------------------------------------------------------- circular · 2020-12-02 11:19 You mean you will miss it? ---------------------------------------------------------------------- Seenkao · 2020-12-03 22:17 Quote from: circular on December 02, 2020, 12:19:01 pmYou mean you will miss it? когда мне это может понадобится, я не смогу это найти. Google translate: when I may need it, I cannot find it. ---------------------------------------------------------------------- circular · 2020-12-03 23:08 Gotcha