Hi all,
I made some progress on the Int128 unit. The goal is to provide 128 bit integer types which are as close as possible equal to a new ordinal type. As I am a complete newbie to operator overloading and exception handling I also did some reverse engineering (study of compiled code) to understand how the compiler works with existing ordinal types. Before I continue with the development I would like to clarify some questions that came up so far. To support my questions I have attached a reduced, but compilable extract of the unit.
1. it looks like I have to do all variants for the operator overloads if I want to achieve my goal and also be efficient in the generated code - or am I missing something here?
2. is the way I generate range and overflow exceptions reasonable, or is there a better way to do this?
3. so far I saw that assignments & comparisons are only range checked, arithmetics are range & overflow checked, range checks precede overflow checks which again precede the actual setting of a value. Am I correct with that understanding?
4. on the following Int128 := -QWORD it looks like I can not avoid the implicte, compiler generated range check for -QWORD without the use of an explicite type cast like Int128 := -tInt128( QWORD )?
5. do I need to take action wrt operand aliasing, or is this fully handled by the compiler? I.e. OWord1 := OWord1 * OWord1 needs a temporary buffer for the result, otherwise the computation steps would destroy the source. Looking at the generated code it seems FPC is handling this, but I would like confirmation.
6. so far I used the generic QWORD and INT64 ordinals, especially for the multiply overloads. I wonder how efficient this is on 32 bit platforms, or whether I need to do seperate implementations for these? Can somebody pls have a look at the generated code on a 32 bit platform.
Cheers,
MathMan