• No results found

Syntax of the Commands

In document Object code verification (Page 77-80)

3.2 Commands of L

3.2.1 Syntax of the Commands

The commands of L are defined as a set of commandsC

0 of which only a subset is needed to model processor instructions. This is to simplify the development of the language and its prop- erties. The setC

0 is inductively defined from labelling, conditional and assignment commands.

Definition 3.16 Syntax of the commands ofL There is an inductively defined setC

0and functions: if then else :(E C 0 C 0 )!C 0 :=

;

:(AlistEl)!C 0 : :(LabelsC 0 )!C 0

3.2 Commands ofL 60 The setC 0 is defined:

e

2E

c

1

;c

2 2C 0 (if

e

then

c

1else

c

2 )2C 0

al

2Alist

l

2El :=(

al;l

)2C 0

l

2Labels

c

2C 0 (

l

:

c

)2C 0 The assignment command ofLis:=(

al;l

), the conditional command is if

b

then

c

1else

c

2 and the labelling command is(

l

:

c

)where

al

2Alist

;l

2El

;b

2Eb and

c;c

1

;c

2

2C0. The label of a labelled command(

l

:

c

)is

l

, label(

l

:

c

)

def

=

l

. The successor expression of assignment command :=(

al;l

)is

l

(a label expression).

An assignment command made up of a simple list will be written using infix notation. e.g. The command:=((

x

1

;e

1

)(

x

n

;e

n)nil

;l

)will be written

x

1

;::: ;x

n :=

e

1

;::: ;e

n

;l

.

2 All commands ofC

0 contain at least one assignment command and every assignment com- mand assigns a value to the program counter, to select the next command for execution. An assignment command

c

is made up of an assignment list

al

and a label expression

l

. The com- mand assigns the label expression

l

to the program counter pc simultaneously with assignments of

al

. The full list of assignments made by the command

c

is therefore the list (pc

;l

)

al

. (In effect, the assignment command

x

:=

y;l

is short-hand for

x;

pc:=

y;l

.)

The commands ofL used to model the instructions of an object code program are labelled commands inC

0. The set containing these commands is denoted

C. Commands of the setC 0 can be labelled with two or more different labels. If a command has two distinct labels,

l

1

: (

l

2

:

c

) and

l

1

6=

l

2, then the command cannot be executed: A command is selected by the value of the name pc and the name pc cannot have two values. These commands are excluded from the setC.

Definition 3.17 Commands ofL A command

c

2C

0is regular if all labelled commands occurring in

c

have the same label.

regular?:C 0 !boolean regular?(

c

) def = 8(

l

1

;l

2 :Labels

;c

1

;c

2 :C 0 ): (

l

1 :

c

1 )

c

^(

l

2 :

c

2 )

c

)

l

1 =

l

2 The setC is the subset ofC

0containing only labelled, regular commands: C def = f(

l

:

c

)j (

l

:

c

)2C 0 ^regular?(

l

:

c

)g 2 A command

c

which is selected in a state

s

can fail if it attempts an impossible assignment or it is labelled with two distinct labels. The labels of a command can be distinguished by syntactic equality and commands with distinct labels are excluded from set C. This ensures that if a command inC fails, it does so because of an incorrect assignment.

3.2 Commands ofL 61

value ::= any element of the set Values name ::= any element of the set Names label ::= any element of the set Labels value function ::= any element of the setFv name function ::= any element of the setFn label function ::= any element of the setF

l

E ::= hvaluei j hvalue functioni(hEi

;::: ;

hEi) j hEni j hEli j hEi

/

hAlisti

En ::= hnamei j hname functioni(hEi

;::: ;

hEi) j hEni

/

hAlisti El ::= hlabeli j hlabel functioni(hEi

;::: ;

hEi) j hEli

/

hAlisti

Alist ::= nil j (hEni

;

hEi)hAlisti j hAlistihAlisti com ::= ifhEithenhcomielsehcomi j :=hAlisti

;

hEli

C 0

::= hcomijhlabeli:hcomi C ::= hlabeli:hcomi

Figure 3.4: Summary of Syntax for Expressions and Commands ofL

Example 3.15 Assume assignment lists

al;bl

2 Alist, distinct labels

l

1

;l

2

2 Labels, label ex- pression

l

2Eand Boolean expression

b

2Eb.

The commands ofC 0include: :=(

al;l

)

;

:=(

bl;l

1 )

;

:=((pc

;l

1 )

al;l

2 ) if

b

then

l

1 :(:=(

al;l

))else :=(

bl;l

1 )

l

2 :if

b

then

l

1 :(:=(

al;l

))else

l

2 :(:= (

bl;l

1 ))

l

1 :

l

2 :(:= (

al;l

))

l

1 :(:=(

al;l

))

;l

2 :(:= (

bl;l

1 )) Of these, the regular commands are:

:=(

al;l

)

;

:=(

bl;l

1 )

;

:=((pc

;l

1 )

al;l

2 ) if

b

then

l

1 :(:=(

al;l

))else :=(

bl;l

1 )

l

1 :(:=(

al;l

))

;l

2 :(:=(

bl;l

1 )) The commands which are also inC are

l

1 :(:=(

al;l

))and

l

2 :(:=(

bl;l

1 )). 2

3.2 Commands ofL 62

Basic Commands of

L

A summary of the syntax of the commands and expressions ofL is given in Figure (3.4). The syntactic category C describes the commands of the set C, which will be used to model the instructions of an object code program. These are the commands labelled with a single label. The syntactic category C

0 of Figure (3.4) describes the commands of the set

C0, which will be used when deriving and manipulating commands ofL.

In document Object code verification (Page 77-80)