Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| lehrkraefte:blc:informatik:efi-2023:exam4 [2024/04/30 06:51] – [Freifächer] Ivo Blöchliger | lehrkraefte:blc:informatik:efi-2023:exam4 [2024/04/30 06:58] (current) – [Assembler] Ivo Blöchliger | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Assembler ====== | ||
| + | * Erklären Sie, was jeder einzelne der folgenden Befehle tut und was passieren würde, wenn man die Zeile '' | ||
| + | <code asm> | ||
| + | befehl1: | ||
| + | MOV A, [42] | ||
| + | befehl2: | ||
| + | MOV A, 42 | ||
| + | befehl3: | ||
| + | CALL blabla | ||
| + | befehl4: | ||
| + | JMP befehl1 | ||
| + | blabla: | ||
| + | PUSH A | ||
| + | befehl5: | ||
| + | INC A | ||
| + | befehl6: | ||
| + | POP A | ||
| + | befehl7: | ||
| + | RET | ||
| + | </ | ||
| + | * Folgende Information ist gegeben: | ||
| + | <WRAP info> | ||
| + | Die Ausgabe auf die drei 7-Segment Anzeigen erfolgt auf die Adressen 253 bis 255. | ||
| + | |||
| + | Die Bits auf der Anzeige sind wie folgt nummeriert: | ||
| + | <code txt> | ||
| + | +--0--+ | ||
| + | 5 1 | ||
| + | :--6--: | ||
| + | 4 2 | ||
| + | +--3--+ | ||
| + | </ | ||
| + | </ | ||
| + | * Schreiben Sie eine Zeile Code, die die Ziffer 4 auf die erste der drei 7-Segment Anzeigen erscheinen lässt. | ||
| + | * Erklären Sie, was folgendes Programm tut (0xe8 ist die Startadresse der Textausgabe). Insbesondere, | ||
| + | <code asm> | ||
| + | start: | ||
| + | MOV A, 0xe8 | ||
| + | MOV B, hello | ||
| + | loop: | ||
| + | MOV C, [B] | ||
| + | CMP C,0 | ||
| + | JZ ende ; JUMP if Zero | ||
| + | MOV [A], C | ||
| + | INC A | ||
| + | INC B | ||
| + | JMP loop | ||
| + | ende: | ||
| + | HLT | ||
| + | hello: | ||
| + | DB " | ||
| + | DB 0 | ||
| + | </ | ||
| + | |||
| + | |||
| + | * Erklären Sie Sinn und Zweck der folgenden Registern: | ||
| + | * IP (Instruction Pointer), wird oft auf PC (Programm Counter) genannt. | ||
| + | * SP (Stack Pointer) | ||
| + | * allgemeine Verwendung | ||
| + | * speziell im Zusammenhang mit den Instruktionen '' | ||
| + | * Bei jeder Berechnung werden die Flags Z (Zero) und C (Carry) gesetzt oder gelöscht, je nach Resultat der Berechnung. | ||
| + | * Welche «Befehlsfamilie» nutzt diese Flags und welchem Programmierbefehl entspricht das am ehesten in Python? | ||
| + | * Was genau macht der Befehl '' | ||
| + | |||
| + | ====== Unicode ====== | ||
| + | * Was ist Unicode? | ||
| + | * Was sind die konzeptuellen Unterschiede zwischen Unicode und UTF-8? | ||
| + | * Was ist der Vorteil von der Verwendung von Start- und Folgebytes? | ||
| + | |||
| + | ====== SQL ====== | ||
| + | ===== Highscores ===== | ||
| + | |||
| + | Gegeben ist eine sqlite-Datenbank mit folgenden Schema: | ||
| + | <code sql> | ||
| + | .schema | ||
| + | CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | name TEXT UNIQUE NOT NULL); | ||
| + | CREATE TABLE score (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | userid INT NOT NULL, | ||
| + | zeit TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| + | score INT, | ||
| + | FOREIGN KEY(userid) REFERENCES USER(id)); | ||
| + | </ | ||
| + | Die Tabellen sind mit folgendem Inhalt gefüllt: | ||
| + | <code txt> | ||
| + | sqlite> select * from user; | ||
| + | id name | ||
| + | -- ---------- | ||
| + | 1 | ||
| + | 2 | ||
| + | 3 | ||
| + | 4 | ||
| + | |||
| + | sqlite> select * from score; | ||
| + | id userid | ||
| + | -- ------ | ||
| + | 1 | ||
| + | 2 | ||
| + | 3 | ||
| + | 4 | ||
| + | 5 | ||
| + | 6 | ||
| + | |||
| + | </ | ||
| + | * Was liefert folgende Abfrage? Kommentieren Sie die einzelnen Teil der Abfrage. | ||
| + | <code sql> | ||
| + | SELECT score.score, | ||
| + | </ | ||
| + | |||
| + | * Geben Sie eine Anfrage an, die alle Scores mit Zeitstempel von '' | ||
| + | |||
| + | <hidden Dump der Datenbank> | ||
| + | Kann mit '' | ||
| + | <code sql highscore.dump> | ||
| + | PRAGMA foreign_keys=OFF; | ||
| + | BEGIN TRANSACTION; | ||
| + | CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | INSERT INTO user VALUES(1,' | ||
| + | INSERT INTO user VALUES(2,' | ||
| + | INSERT INTO user VALUES(3,' | ||
| + | INSERT INTO user VALUES(4,' | ||
| + | CREATE TABLE score (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | userid INT NOT NULL, | ||
| + | zeit TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| + | score INT, | ||
| + | FOREIGN KEY(userid) REFERENCES USER(id)); | ||
| + | INSERT INTO score VALUES(1, | ||
| + | INSERT INTO score VALUES(2, | ||
| + | INSERT INTO score VALUES(3, | ||
| + | INSERT INTO score VALUES(4, | ||
| + | INSERT INTO score VALUES(5, | ||
| + | INSERT INTO score VALUES(6, | ||
| + | DELETE FROM sqlite_sequence; | ||
| + | INSERT INTO sqlite_sequence VALUES(' | ||
| + | INSERT INTO sqlite_sequence VALUES(' | ||
| + | COMMIT; | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== Freifächer ===== | ||
| + | Folgendes Schema ist definiert: | ||
| + | <code sql> | ||
| + | CREATE TABLE student (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | name TEXT NOT NULL); | ||
| + | CREATE TABLE freifach (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | name TEXT UNIQUE NOT NULL); | ||
| + | CREATE TABLE wahl (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | Folgende Daten sind eingetragen: | ||
| + | <code txt> | ||
| + | sqlite> select * from student; | ||
| + | id name | ||
| + | -- ---------- | ||
| + | 1 | ||
| + | 2 | ||
| + | 3 | ||
| + | 4 | ||
| + | |||
| + | sqlite> select * from freifach; | ||
| + | id name | ||
| + | -- ---------- | ||
| + | 1 | ||
| + | 2 | ||
| + | 3 | ||
| + | |||
| + | sqlite> select * from wahl; | ||
| + | id freifachid | ||
| + | -- ---------- | ||
| + | 1 | ||
| + | 2 | ||
| + | 3 | ||
| + | 4 | ||
| + | 5 | ||
| + | 6 | ||
| + | </ | ||
| + | |||
| + | <hidden Dump der Datenbank> | ||
| + | Kann mit '' | ||
| + | <code sql freifach.dump> | ||
| + | PRAGMA foreign_keys=OFF; | ||
| + | BEGIN TRANSACTION; | ||
| + | CREATE TABLE student (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | name TEXT NOT NULL); | ||
| + | INSERT INTO student VALUES(1,' | ||
| + | INSERT INTO student VALUES(2,' | ||
| + | INSERT INTO student VALUES(3,' | ||
| + | INSERT INTO student VALUES(4,' | ||
| + | CREATE TABLE freifach (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | name TEXT UNIQUE NOT NULL); | ||
| + | INSERT INTO freifach VALUES(1,' | ||
| + | INSERT INTO freifach VALUES(2,' | ||
| + | INSERT INTO freifach VALUES(3,' | ||
| + | CREATE TABLE wahl (id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| + | freifachid INTEGER NOT NULL, | ||
| + | studentid INTEGER NOT NULL, | ||
| + | FOREIGN KEY(freifachid) REFERENCES freifach(id), | ||
| + | FOREIGN KEY(studentid) REFERENCES student(id)); | ||
| + | INSERT INTO wahl VALUES(1, | ||
| + | INSERT INTO wahl VALUES(2, | ||
| + | INSERT INTO wahl VALUES(3, | ||
| + | INSERT INTO wahl VALUES(4, | ||
| + | INSERT INTO wahl VALUES(5, | ||
| + | INSERT INTO wahl VALUES(6, | ||
| + | DELETE FROM sqlite_sequence; | ||
| + | INSERT INTO sqlite_sequence VALUES(' | ||
| + | INSERT INTO sqlite_sequence VALUES(' | ||
| + | INSERT INTO sqlite_sequence VALUES(' | ||
| + | COMMIT; | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | * Erklären Sie folgende Anfrage und deren Ausgabe: | ||
| + | <code txt> | ||
| + | sqlite> select freifach.name, | ||
| + | name count(freifachid) | ||
| + | ---------- | ||
| + | python | ||
| + | javascript | ||
| + | sql | ||
| + | </ | ||
| + | |||
| + | * Schreiben Sie eine Abfrage, die die Namen aller Freifächer auflistet, die von '' | ||
| + | * Erklären Sie, warum eine dritte Tabelle '' | ||
| + | |||