Information Technology Reference
In-Depth Information
registers of addresses i
j respectively. Three special registers are assumed: an input
register R in providing data to the machine, an output register R out providing results,
plus the register C , with the role of counter . Any machine is assumed to have, apart
the three special registers, all the registers necessary for executing the instructions
of its program.
,
Ta b l e 6 . 1 6 The instructions of a register machine (applicable when the counter C contains h
h , input i , k
the value of register R in is put into the register R in and k in C .
h , out put i , k
the value of register R i is put into the register R out and k in C .
h , inc i , k
the value put in the register R i is incremented of one unit and k in C .
h , dec i , k
the value put in the register R i is decremented of one unit and k in C .
h , zero i , k
the value 0 is put in the register R i and k in C .
h , test i , j , k , l
if the values of R i and R j are equal then k ,otherwise l , is put in C .
Ta b l e 6 . 1 7 A register machine computing the sum of two numbers
1 . input 1 2
2
input 2 3
3 . zero 3 4
4 . test 2 , 3 7 , 5
5 . dec 2 6
6 . inc 1 4
7 . out put 1 8
.
It can be shown that the same computational power of register machines defined
above continues to hold by substituting the two operations of test and decrement
with a unique operation of conditional decrement cdec i k
l such that if the content
of R i is not zero decrements this register and put k in C , otherwise only puts l in C .
Register machines have the same computational power of structured register
while-programs , which are realized by using only the operations of increment and
decrement, but by structuring operations in blocks of type while j . This means, all
the operations in a while j block are iterated while the content of register R j is not
zero. For example, the program of Table 6.17 could be expressed by the register
while-program given in Table 6.18. In this case, instructions do not need to have
order numbers and next instruction numbers, because operations are executed in
the order they are listed in the program, and the program execution ends when the
last instruction is executed. When a while-block is entered, the exit from it happens
when its condition does not continue to hold.
This notion of program is the basis of structured programming, which was a key
feature of high level programming languages developed in 1970s. In a structured
program, a correspondence holds between the order of instructions in the program
,
Search WWH ::




Custom Search