![]() |
Delphi-Version: 2005
Is this correct and Safe
I would like to do 3 Loops and each loop gives a Message , but without using IF .. Then
i did it in this way * Is it correct and Safe ... ? * // in ASM
Delphi-Quellcode:
var
Str: string; begin Str := 'Just to popup a message without using IF Then'; try Asm PushAd Xor al,al @Loop:Cmp al,3//xLoop //---> 3 loops JE @ExitpRoc PushAd Push 0 Push 0 Push Str Push 0 Call MessageBoxA PopAd Inc al Jmp @Loop @ExitpRoc:PopAd End; except Exit; end; end; |
AW: Is this correct and Safe
Zitat:
Bernhard BTW: What do PushAd/PopAd do? - I just know "Push XXX"/"Pop XXX" (including space) |
AW: Is this correct and Safe
Should do fine imo, except for one thing: MessageBoxA is an API function, hence it uses PChar and not Delphi's internal string. You should pass a pointer to the first character instead of the string itself.
I'm not sure about the PushAd and PopAd stuff - I think it's for exception handling, isn't it? I can't tell if you're using those instructions correctly because I've never used them myself, but I think the easiest way to find that out is to just run the code and see if it works. |
AW: Is this correct and Safe
@NamenLozer: Intern enthält ein Delphi-String alles, was einem PChar gleicht.
Delphi-Quellcode:
aka
. except
Exit; end; end;
Delphi-Quellcode:
Sowas macht man nicht :!:!
. except
end; end; Ansonsten seh ich keinen Vorteil, weswegen man hier unbedingt ASM und nicht einfaches Pascal nutzt. |
AW: Is this correct and Safe
Zitat:
|
AW: Is this correct and Safe
Der interne Pointer eines Strings und der anderen dynamischen Arrays zeigt absichtlich auf das erste Array-Feld/Char.
Vor diesem Feld/Char liegen dann Referenzzählung, Längenangabe und Co. . Beim String liegt dann hinter dem String auch noch eine zusätzliche #0, obwohl es dieses für einen String mit Längenangabe nicht nötig währe. (Abgesehn vom ShortString) Durch die Position des Pointers und die #0 entspricht es "absichtlich" (ja, man hat sich dabei was gedacht) einem PChar, denn daruch kann eine Konverierung in einen PChar ohne Probleme und großen Aufwand vorgenommen werden, bzw. man kann es einfach ohne Konvertierung nutzen. Nur die andere Richtung, von PChar nach String geht natülich nicht. |
AW: Is this correct and Safe
Ah okay, wieder was gelernt. In dem Fall ist das natürlich dann kein Problem.
|
AW: Is this correct and Safe
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:59 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