Small step semantics help needed

12 views
Skip to first unread message

MorF

unread,
Mar 12, 2011, 6:59:28 PM3/12/11
to proglang-course-2011
Hello,
due to my sickness I was absent on the lecture 9 - Code Generation and
now I feel really confused about the "small step semantics".

I simply don't understand the syntax and what does it mean?
for e.g goto instruction is explained with this sentence

<goto LABEL, i-C-V-S> --> <C(LABEL), LABEL-C-V-S>

but then (solutions to exam 2008-2
http://www.cse.chalmers.se/edu/course/TIN321/exams/solutions-plt-2008-2.html
)
there is something:
<goto L, C-P-V-S> ---> < C(L), C-L-V-S>

What does C-L-V-S or C-P-V-S stand for?

I'd be very thankful for any help!

Aarne Ranta

unread,
Mar 13, 2011, 8:09:39 AM3/13/11
to proglang-c...@googlegroups.com
Hello MorF,

The explanation is in lecture 8, interpreters. To summarize, your example means:

  execution of instruction goto LABEL, in the state consisting of
  - current instruction pointer i
  - code C (i.e. all instructions)
  - variable storage V
  - stack S
  leads to the state with
  - next instruction C(LABEL) (i.e. the instruction in C pointed by LABEL)
  - current instruction pointer LABEL
  - code C (not changed)
  - variable storage V (not changed)
  - stack S (not changed)

Thus the rules of the form <...>--> <...> tell how the state is changing. They can be seen as compact formulations of the textual explanations in the JVM specification, see


(also referenced from exercise 1). Now you can go through all small-step rules in lectures 8 and 9 and verify that this is the case; alternatively, you can take it as an exercise to formulate some JVM specs as semantic rules and compare with the lectures. (However, for goto this looks a little different, because the JVM spec is closer to the bytecode than the Jasmin assembler, which we use ; start with iadd for a more exact correspondence.)

Regards

  Aarne.

MorF

unread,
Mar 13, 2011, 10:54:56 AM3/13/11
to proglang-course-2011
Thank you very much for the explanation!
I think now I understand it :-) Seemed much more complicated than it
actually is.


On Mar 13, 1:09 pm, Aarne Ranta <aa...@chalmers.se> wrote:
> Hello MorF,
>
> The explanation is in lecture 8, interpreters. To summarize, your example
> means:
>
>   execution of instruction goto LABEL, in the state consisting of
>   - current instruction pointer i
>   - code C (i.e. all instructions)
>   - variable storage V
>   - stack S
>   leads to the state with
>   - next instruction C(LABEL) (i.e. the instruction in C pointed by LABEL)
>   - current instruction pointer LABEL
>   - code C (not changed)
>   - variable storage V (not changed)
>   - stack S (not changed)
>
> Thus the rules of the form <...>--> <...> tell how the state is changing.
> They can be seen as compact formulations of the textual explanations in the
> JVM specification, see
>
> http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2...
>
> (also referenced from exercise 1). Now you can go through all small-step
> rules in lectures 8 and 9 and verify that this is the case; alternatively,
> you can take it as an exercise to formulate some JVM specs as semantic rules
> and compare with the lectures. (However, for goto this looks a little
> different, because the JVM spec is closer to the bytecode than the Jasmin
> assembler, which we use ; start with iadd for a more exact correspondence.)
>
> Regards
>
>   Aarne.
>
> On Sun, Mar 13, 2011 at 12:59 AM, MorF <nuzz...@gmail.com> wrote:
> > Hello,
> > due to my sickness I was absent on the lecture 9 - Code Generation and
> > now I feel really confused about the "small step semantics".
>
> > I simply don't understand the syntax and what does it mean?
> > for e.g goto instruction is explained with this sentence
>
> >    <goto LABEL, i-C-V-S>  -->  <C(LABEL), LABEL-C-V-S>
>
> > but then (solutions to exam 2008-2
>
> >http://www.cse.chalmers.se/edu/course/TIN321/exams/solutions-plt-2008...
Reply all
Reply to author
Forward
0 new messages