| Zeile 204: | Zeile 204: | ||
==Beispiel== | ==Beispiel== | ||
Das folgende Programm, bestehend aus einem Assembler- und einem C-Teil berechnet die Fakultät einer Zahl: | Das folgende Programm, bestehend aus einem Assembler- und einem C-Teil berechnet die Fakultät einer Zahl: | ||
| − | <asm>.section .text | + | <syntaxhighlight lang=asm>.section .text |
.global factorial | .global factorial | ||
factorial: | factorial: | ||
| Zeile 237: | Zeile 237: | ||
mov %ebp, %esp | mov %ebp, %esp | ||
pop %ebp | pop %ebp | ||
| − | ret</ | + | ret</syntaxhighlight> |
| − | <c>#include <stdio.h> | + | <syntaxhighlight lang=c>#include <stdio.h> |
extern int factorial(int n); | extern int factorial(int n); | ||
| Zeile 247: | Zeile 247: | ||
printf("Die Fakultät von %d ist %d\n", n, factorial(n)); | printf("Die Fakultät von %d ist %d\n", n, factorial(n)); | ||
return 0; | return 0; | ||
| − | }</ | + | }</syntaxhighlight> |
Kompiliert wird das ganze (abhängig von den Dateinamen natürlich) wie folgt (-m32 ist auf 64-Bit-Systemen wichtig - wir haben hier 32-Bit-Code geschrieben): | Kompiliert wird das ganze (abhängig von den Dateinamen natürlich) wie folgt (-m32 ist auf 64-Bit-Systemen wichtig - wir haben hier 32-Bit-Code geschrieben): | ||