![]() |
AW: asm für meine VeryLongInteger-Unit
Delphi-Quellcode:
Ich bin mir grad nicht so sicher, ob das richtigrum ist.
mov [edx], eax
mov edx.IsNegative, 0 EAX = Self (der Record selber) EDX = 1. Parameter, also a Bei dir sieht es so aus, als wenn du es andersrum machst. :gruebl: |
AW: asm für meine VeryLongInteger-Unit
Hallo himitsu,
ja, darüber habe ich mich auch gewundert, aber so funktioniert es wirklich. Im Internet habe ich hierzu 2 Infos gefunden: 1. Bei Methoden: EAX = Self, EDX, ECX 2. Liefert eine Funktion einen array als Ergebnis, wird er behandelt wie eine zusätzliche Var. Keine Ahnung, warum hier 2. gilt. Ich habe nochmal an meiner Deklaration rumgefummelt, würde doch lieber einen dyn array verwenden, um für alle Fälle gerüstet zu sein:
Delphi-Quellcode:
type
TVLInt = record strict private Digits: array of Cardinal; IsNegative: Boolean; Length: Integer; ... public class operator Implicit(const a: Cardinal): TVLInt; ... end; implementation class operator TVLInt.Implicit(const a: Cardinal): TVLInt; begin SetLength(Result.Digits,1); Result.Digits[0] := a; Result.Length := Integer(a > 0); end; Dann habe ich mir mit Strg-Alt-c angeguckt, was Delphi beim Anlegen so treibt und folgendes geguttenbergt:
Delphi-Quellcode:
class operator TVLInt.Implicit(const a: Cardinal): TVLInt;
// eax <= a asm // MyVLInt.pas.41: begin push ebx push esi mov ebx,edx mov esi,eax // MyVLInt.pas.42: SetLength(Result.Digits,1); push $01 mov eax,ebx mov ecx,$00000001 mov edx,[$00455c9c] // ??? typeInfo?? call System.@DynArraySetLength add esp,$04 // MyVLInt.pas.43: Result.Digits[0] := a; mov eax,[ebx] mov [eax],esi // MyVLInt.pas.44: Result.Length := Integer(a > 0); test esi,esi setnbe al and eax,$7f mov [ebx+$05],eax // MyVLInt.pas.71: end; pop esi pop ebx ret end; Es gibt hier Schwierigkeiten mit DynArraySetLength (Zugriffsverletzung). Emba schreibt: DynArraySetLength(var a: Pointer; typeInfo: Pointer; dimCnt: Longint; lengthVec: PLongint); aber wie man edx richtig bestückt ist mir nicht klar. Ich habe einiges ausprobiert, produziere aber immer Murks. Gruß Talia |
AW: asm für meine VeryLongInteger-Unit
Hallo,
als Notlösung habe ich jetzt eine globale Variable eingeführt und unter initialization TypeInfo zugewiesen. Nicht besonders OOP, funktioniert aber. Gruß Talia |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:06 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz