lehrstuhl für informatik 3 - d. fey vorlesung gra - ss 2015 4.5.-18.5.2015, folie 1 beispiel...
TRANSCRIPT
Lehrstuhl für Informatik 3 - D. FeyVorlesung GRa - SS 20154.5.-18.5.2015, Folie 1
Beispiel Stack-Architektur
Lehrstuhl für Informatik 3 - D. FeyVorlesung GRa - SS 20154.5.-18.5.2015, Folie 2
314 ba+
÷×
14 a b 3
14 a × b 3 ÷ +
Traversierter Baum (post-order)
Lehrstuhl für Informatik 3 - D. FeyVorlesung GRa - SS 20154.5.-18.5.2015, Folie 3
14 a × b 3 ÷ +
• Ausgangslage für Abarbeitung in stack-basierter Architektur• Erzeugte Textbeschreibung
• Keine explizite Adressierung über load, store Instruktionen• Sondern Verwenden von push, pop Instruktionen
14 a × b 3 ÷ +push 14
// Konstante 14 auf Stack legen
a × b 3 ÷ +
ab
14
ToS: Top of stackZeigt auf ersten freien Platz
ToS
Push 14 → Stack(ToS)ToS = ToS+1
Memory Stack
12-3
Lehrstuhl für Informatik 3 - D. FeyVorlesung GRa - SS 20154.5.-18.5.2015, Folie 4
a × b 3 ÷ + push a // Inhalt im Speicher unter Adresse a
auf Stack legen
× b 3 ÷ +
ab
ToS
Push Mem(a) → Stack(ToS)ToS = ToS+1
Memory Stack
12-3
14
12
× b 3 ÷ + x // Multiplizieren
b 3 ÷ +
ab
ToS Stack(ToS-2) x Stack(ToS-1)→ Stack(ToS-2)
ToS = ToS-1
Memory Stack
12-312
1412
168
Lehrstuhl für Informatik 3 - D. FeyVorlesung GRa - SS 20154.5.-18.5.2015, Folie 5
b 3 ÷ + push b // Inhalt im Speicher unter Adresse b
auf Stack legen
3 ÷ +
ab
ToS Push Mem(b) → Stack(ToS)ToS = ToS+1
Memory Stack
12-3
168
12
3 ÷ + push 3 ÷ +
ab ToS
Push 3 → Stack(ToS-1) ToS = ToS+1
Memory Stack
12-312 3
-3
-3168
Lehrstuhl für Informatik 3 - D. FeyVorlesung GRa - SS 20154.5.-18.5.2015, Folie 6
÷ + divide +
ab
ToS Stack(ToS-2) ÷ Stack(ToS-1)→ Stack(ToS-2)
ToS = ToS-1
Memory Stack
12-3
168
12-1
+ add
ab
ToS
Memory Stack
12-312
167
Stack(ToS-2) + Stack(ToS-1)→ Stack(ToS-2)
ToS = ToS-1