Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As I have explained in the comments, what really matters here is which operations you wish to support. The data type is simple enough. You represent it as two adjacent 32 bit integers. But the complexity lies in implementing the operations on that data type.</p> <p>On a 32 bit machine, you cannot operate directly on 64 bit integers, so you need to build 64 bit operations using the functionality of the 32 bit CPU.</p> <p>Here is an example of how to implement incrementing of an unsigned 64 bit integer by a signed 32 bit integer.</p> <pre><code>type UInt64 = record Lo: Cardinal; Hi: Cardinal; end; procedure Increment(var op1: UInt64; op2: Integer); // IN: eax = pointer to op1; edx = op2 asm mov ecx,eax mov eax,edx cdq add eax,[ecx] adc edx,[ecx+4] mov [ecx],eax mov [ecx+4],edx end; </code></pre> <p>The tricky part of this function is the <code>cdq</code> instruction. That sign extends the signed double word in <code>eax</code> to a signed quad word in <code>edx:eax</code>.</p> <p>Implementing other operations is broadly similar. Obviously addition is the simplest. Multiplication gets a little more difficult. </p> <hr> <p>In the comments you state:</p> <blockquote> <p>I am trying to port the latest BTMemoryModule.pas to make it work without <code>UInt64</code>. It uses <code>UInt64</code> so it supports x64 but I only need it for x86.</p> </blockquote> <p>Since you only need x86 support, because your compiler is 32 bit, then I don't think you actually need <code>UInt64</code> operations. You replace those variables with <code>Cardinal</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload