Asm/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Asm/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zu den [[Reserved words/de|reservierten Wörtern]]. | |
| 2 | + | ||
| 3 | + | Das reservierte Wort **Asm** gehört zum Inline Assembler. Es leitet im Pascalcode einen Abschnitt mit Assemblercode ein. | |
| 4 | + | ||
| 5 | + | Beispiel, wie der Assemblercode im Programm aufgerufen wird: | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | asm | |
| 9 | + | // Hier steht der Assemblercode | |
| 10 | + | end; | |
| 11 | + | ``` | |
| 12 | + | ||
| 13 | + | Beispiel für die Verwendung von Inline Assembler: | |
| 14 | + | ||
| 15 | + | ``` pascal | |
| 16 | + | var | |
| 17 | + | intWert: Integer; | |
| 18 | + | intErgebnis : Integer; | |
| 19 | + | ||
| 20 | + | begin | |
| 21 | + | intWert := ...; | |
| 22 | + | // Wird von Lazarus / Free Pascal bei Intel x86 Prozessoren benötigt: | |
| 23 | + | {$ASMMODE intel} | |
| 24 | + | asm | |
| 25 | + | MOV EAX, intWert // weist dem Register EAX den Wert der Variablen intWert zu | |
| 26 | + | ADD EAX, 110B // addiere den Binärwert 110 (der entsprechende Dezimalwert ist 6) | |
| 27 | + | SUB EAX, 2 // subtrahiere den Dezimalwert 2 | |
| 28 | + | MOV intErgebnis, EAX // weist der Variablen intErgebnis den Inhalt des Registers EAX zu | |
| 29 | + | end; | |
| 30 | + | ... := IntToStr(intErgebnis); | |
| 31 | + | end; | |
| 32 | + | ``` | |
| 33 | + | ||
| 34 | + | Beispiel für reine Assembler-Procedure/Function: | |
| 35 | + | ||
| 36 | + | ``` pascal | |
| 37 | + | {$ASMMODE intel} | |
| 38 | + | procedure nop; assembler; | |
| 39 | + | asm | |
| 40 | + | nop | |
| 41 | + | end; | |
| 42 | + | ``` | |
| 43 | + | ||
| 44 | + | --- | |
| 45 | + | *From the Free Pascal wiki, page "Asm/de", as it stood on 2020-02-09 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
