This preview shows pages 1–8. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Operational Semantics References: Kurtz (Ch. 8.4, 8.5, 8.6) Many ways to define o.s.: 1. Define an interpreter for the language. 2. Define a compiler for the language, plus an interpreter for the assembly language used. 3. Specify how the state changes as various commands are executed. We will discuss the third approach now. 71 We will define a relation h c, i to mean that the execution of c starting in terminates in . Example: h skip , i We also need to define h ae, i n if the value of ae in is n . And, h be, i bv if the value of be in is bv . Questions: 1. What if ae or be are not well defined? 2. What if ae or be have sideeffects? 72 Arithmetic expressions: First the syntax: a ::= n  X  a + a 1  a a 1  a a 1 h n, i n h X, i ( X ) h a , i n , h a 1 , i n 1 h a + a 1 , i n where n is the sum of n and n 1 . h a , i n , h a 1 , i n 1 h a a 1 , i n where n is the product of n and n 1 . h a , i n , h a 1 , i n 1 h a a 1 , i n where n is the difference between n and n 1 . Using these we can, for instance, derive, h X + Y, i 10 if ( X ) = 4 and ( Y ) = 6 73 Operational semantics of boolean expressions: First the syntax: b ::= true  false  a = a 1  a a 1  b  b b 1  b b 1 h true , i true h false , i false h a , i n , h a 1 , i n 1 if n , n 1 are equal h a = a 1 , i true h a , i n , h a 1 , i n 1 if n , n 1 not equal. h a = a 1 , i false h a , i n , h a 1 , i n 1 if n less/equal to n 1 . h a a 1 , i true h a , i n , h a 1 , i n 1 if n greater than n 1 h a a 1 , i false h b, i true h b, i false h b, i false h b, i true 74 h b , i t , h b 1 , i t 1 h b b 1 , i t where t is true if both t and t 1 are true, and false otherwise. Or better: h b , i false h b b 1 , i false h b , i true , h b 1 , i false h b b 1 , i false h b , i true , h b 1 , i true h b b 1 , i true b b 1 is similar. 75 Commands : Notation: the state [ m/X ] is the same as except the value of X in the former is m (rather than ( X ) ). In other words, [ m/X ]( Y ) = m if X Y and ( Y ) if X 6 Y [ m/X ] is also written [ X m ]. h skip , i h a, i m h X := a, i [ m/X ] h c , i , h c 1 , i 00 h c ; c 1 , i 00 ***Need to define read and write. 76 h b, i true , h c , i h if b then c else c 1 , i h b, i false , h c 1 , i h if b then c else c 1 , i h b, i false h while b do c, i h b, i true , h c, i , h while b do c, i 00 h while b do c, i 00 This semantics is coarse , i.e., the details of the in dividual steps are lost. It is also called natural semantics or bigstep semantics. (Slonnegarsemantics or bigstep semantics....
View
Full
Document
 Winter '05
 NeelamSoundarajan
 Assembly Language

Click to edit the document details