Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

© Roland Angst, 2010Institute of Visual Computing Informatik I for D-MAVT Exercise Session 1.

Ähnliche Präsentationen


Präsentation zum Thema: "© Roland Angst, 2010Institute of Visual Computing Informatik I for D-MAVT Exercise Session 1."—  Präsentation transkript:

1 © Roland Angst, 2010Institute of Visual Computing Informatik I for D-MAVT Exercise Session 1

2 © Roland Angst, 2010Institute of Visual Computing Organisatorisches Teaching Assistant Roland Angst (rangst@inf.ethz.ch) http://www.cvg.ethz.ch/people/phdstudents/rangst/TeachingActivities/InformatikIFS10 Übungsabgabe Auf Papier, keine Emails Später, wenn Programme umfangreicher werden, ev. auch Abgabe per Email möglich Gruppenlösungen erlaubt (aber max. 2 Studenten pro Gruppe) Abgabetermin eine Woche nach Vorbesprechung Testatbedingungen 75% aller Übungen Voraussichtlich 12 Serien (d.h. 9 gelöste Serien)

3 © Roland Angst, 2010Institute of Visual Computing Übungsstundenablauf Wünsche? Repetition der Vorlesungsunterlagen? Lediglich Vor- und Nachbesprechung der Übungen? Interaktiv?

4 © Roland Angst, 2010Institute of Visual Computing Computer Crash-Kurs http://msdn.microsoft.com/en-us/beginner/bb308732.aspx

5 © Roland Angst, 2010Institute of Visual Computing Programmiersprachen Unterscheidung zwischen Interpretierten Sprachen Bsp: Matlab, Python,... Kompilierten Sprachen Bsp: C, C++, Pascal,...

6 © Roland Angst, 2010Institute of Visual Computing Kompilierte Sprachen Source Code Geschrieben in einer Programmiersprache (C, C++, Oberon, Eiffel,...) Assembler Code Binary Code Machine Instruction (Einzelne Prozessorinstruktionen; immer noch lesbar für Menschen) Unabhängig vom Betriebssystem oder Prozessor Abhängig von Rechnerarchitektur (v.a. vom Prozessor) Für Computer verständliche Übersetzung des Assembly Codes (Binär Code, nicht mehr lesbar für Menschen) *.h *.hpp *.cpp *.asm*.obj Executables, Libraries Vom Betriebssystem ausführbare Programme & Funktionen *.exe *.dll... AssemblerCompilerLinker

7 © Roland Angst, 2010Institute of Visual Computing Source Code (Bsp in C++) Source Code #include int main(int argc, char** argv) { std::cout << hello world; return 0; } Assembly Code (Auszug) pushebp movebp, esp subesp, 192 ; 000000c0H pushebx pushesi pushedi leaedi, DWORD PTR [ebp-192] movecx, 48; 00000030H moveax, -858993460 ; ccccccccH rep stosd pushOFFSET ??_C@_0M@LACCCNMM@hello?5world?$AA@ moveax, DWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A pusheax call$basic_ostream@DU addesp, 8

8 © Roland Angst, 2010Institute of Visual Computing Source Code (Bsp in C++) Binary Code vs. Assembly Code (Auszug) 0000055 push ebp 000018b ec mov ebp, esp 0000381 ec c0 00 00 00 sub esp, 192; 000000c0H 0000953 push ebx 0000a56 push esi 0000b57 push edi 0000c8d bd 40 ff ff ff lea edi, DWORD PTR [ebp-192] 00012b9 30 00 00 00 mov ecx, 48; 00000030H 00017b8 cc cc cc cc mov eax, -858993460; ccccccccH 0001cf3 ab rep stosd Binary CodeAssembly Code Beispiel in Visual Studio

9 © Roland Angst, 2010Institute of Visual Computing Source Code im Detail Source Code #include int main(int argc, char** argv) { std::cout << hello world; return 0; } Include-Direktive Compilerdirektive: wird vom Präprozessor abgearbeitet Sucht Header-Datei iostream Kopiert Inhalt der Header-Datei anstelle des #include Befehls Dies geschieht in einer temporären Datei, ursprünglicher Source Code wird nicht verändert Temporäre Datei wird an Compiler weiter gereicht Wieso Header-Dateien? Siehe später in der Vorlesung (oder in meiner Übungsstunde...)

10 © Roland Angst, 2010Institute of Visual Computing Source Code im Detail Source Code #include int main(int argc, char** argv) { std::cout << hello world; return 0; } main-Funktion: Einstiegspunkt des Programs Betriebssystem lädt Executable in Speicher CPU-Programpointer wird auf Anfang der main-Funktion gesetzt Prozessor startet, das Executable auszuführen Input Argumente: Kommandozeilenparameter Int argc Anzahl der Parameter Erster Parameter ist gleich dem Namen der Executable Char** argv Einzelne Parameter als Zeichenfolge (sogenanntes Array of Characters)

11 © Roland Angst, 2010Institute of Visual Computing Source Code im Detail Source Code #include int main(int argc, char** argv) { std::cout << hello world; return 0; } Rückgabetyp der Funktion ist ein Integer ( int ) Return 0 Gibt an, dass Programm ohne Fehler beendet wurde (Konvention, irgendein Wert könnte zurückgegeben werden...) Ausgabe des Texts mittels output-stream operator << des std::cout object Funktionen dieser Klasse werden in iostream zur Verfügung gestellt Darum muss diese Header-Datei eingebunden werden

12 © Roland Angst, 2010Institute of Visual Computing Fragen Zur Vorlesung?

13 © Roland Angst, 2010Institute of Visual Computing Übung 1 Herumspielen mit Hello-World-Program Challenge: Schafft es jemand, die Inputparameter ( int argc, char** argv ) zu verwenden?


Herunterladen ppt "© Roland Angst, 2010Institute of Visual Computing Informatik I for D-MAVT Exercise Session 1."

Ähnliche Präsentationen


Google-Anzeigen