Benutzer-Werkzeuge

Webseiten-Werkzeuge


neuerlehrplan:klasse10:algorithmusbegriff

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
neuerlehrplan:klasse10:algorithmusbegriff [2025/05/15 10:20] – [Grundsätzliches Vorgehen beim Programmieren mit textorientierten Sprachen] lutzneuerlehrplan:klasse10:algorithmusbegriff [2025/05/15 10:46] (aktuell) – [Beispiel: "Hallo Welt!"-Programm in Python] lutz
Zeile 60: Zeile 60:
   * Bei Interpretersprachen wird das Programm direkt mit dem Interpreter aufgerufen und dadurch ausgeführt.   * Bei Interpretersprachen wird das Programm direkt mit dem Interpreter aufgerufen und dadurch ausgeführt.
  
-====Beispiel: "Hallo Welt!"-Programm mit Assembler=====+====Beispiel: "Hallo Welt!"-Programm in Assembler===== 
 + 
 +<code asm hallo.asm> 
 +section .text 
 + global _start       ;must be declared for using gcc 
 +_start:                     ;tell linker entry point 
 + mov edx, len    ;message length 
 + mov ecx, msg    ;message to write 
 + mov ebx, 1     ;file descriptor (stdout) 
 + mov eax, 4     ;system call number (sys_write) 
 + int 0x80        ;call kernel 
 + mov eax, 1     ;system call number (sys_exit) 
 + int 0x80        ;call kernel 
 + 
 +section .data 
 + 
 +msg db 'Hello, world!',0xa ;our dear string 
 +len equ $ - msg ;length of our dear string 
 +</code> 
 + 
 +Aufruf des Assemblers in der Kommandozeile: 
 + 
 +<code> 
 +nasm -f elf64 hallo.asm 
 +</code> 
 + 
 +Programm linken: 
 + 
 +<code> 
 +ld hallo.o -o hallo 
 +</code> 
 + 
 +Programm ausführen: 
 + 
 +<code> 
 +./hallo 
 +</code> 
 + 
 +Ausgabe: 
 +<code> 
 +Hello, world! 
 +</code> 
 + 
 +====Beispiel: "Hallo Welt!"-Programm in C===== 
 + 
 +<code c hallo.c> 
 +#include <stdio.h> 
 + 
 +int main() 
 +
 +    printf("Hello, World!\n"); 
 + 
 +    return 0; 
 +
 +</code> 
 + 
 +Programm compilieren: 
 + 
 +<code> 
 +gcc hallo.c -o hallo 
 +</code> 
 + 
 +Programm ausführen: 
 + 
 +<code> 
 +./hallo 
 +</code> 
 + 
 +Ausgabe: 
 +<code> 
 +Hello, world! 
 +</code> 
 + 
 +====Beispiel: "Hallo Welt!"-Programm in Python===== 
 + 
 +<code python hallo.py> 
 +print ("Hello, world!\n"
 +</code> 
 + 
 +Programm ausführen: 
 + 
 +<code> 
 +python hallo.py 
 +</code> 
 + 
 +Ausgabe: 
 +<code> 
 +Hello, world! 
 +</code> 
neuerlehrplan/klasse10/algorithmusbegriff.1747297233.txt.gz · Zuletzt geändert: von lutz