Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Komischer ASM Code (https://www.delphipraxis.net/10033-komischer-asm-code.html)

Luckie 10. Okt 2003 06:22


Komischer ASM Code
 
Ich beschäftige mich jetzt etwas mit ASM und dabei bin ich über folgenden Code gestolpert:
Code:
    .WHILE TRUE                                                        ; Enter message loop
                invoke GetMessage, ADDR msg,NULL,0,0 
                .BREAK .IF (!eax)
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
   .ENDW
Offensichtlich eine Schleife. Nur in meinem ASM Buch werden Schleife so nicht realisiert, sondern mit Labels und Sprüngen. Es ist Code für MASM aus den Iczelion's Win32ASM Tutorials.

Könnte mir das mal bitte jemand erklären?

Robert Marquardt 10. Okt 2003 06:28

Re: Komischer ASM Code
 
Der Assembler kann offensichtlich ein paar einfache Hochsprachenkonstrukte.

Delphi-Quellcode:
  while True do
  begin
    if GetMessage(Msg, 0, 0, 0) = 0 then
      Break;
    // Anmerkung: hier fehlt ein IF
    TranslateMessage(Msg);
    DispatchMessage(Msg);
  end;

Luckie 10. Okt 2003 13:06

Re: Komischer ASM Code
 
Ja, soweit war ich auch schon. Inzwischen habe ich rausgefunden, dass das wohl Makros sind, die mit einem Punkt anfangen. Aus der Hilfe zu MASM:
Zitat:

MASM High Level Syntax

In conjunction with the "invoke" syntax, MASM has a set of built in pseudo high level macros for value comparison and loop construction. While many have passed comments about the lack of low level code by using such built in macros, generally they cannot construct normal windows message handling procedures with anything like the same complexity and reliability without them.

The .IF syntax can be nested in the normal manner which makes the "switch block" style of WndProc message handling procedures possible. The alternative using "cmp reg, var", "jne label" produces nightmares in terms of tracking the number of jumps and labels needed and it does not perform any better or asemble any smaller.

The choice where complex conditional testing is required is between reliable fast code and unreadable and unfixable code, most eventually take the choice of doing this type of testing in a reliable and fast manner so that the difficult work in terms of speed and capacity can be done in a reasonably timescale.

.IF
.REPEAT
.WHILE
.BREAK
.CONTINUE


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:09 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz