Page 21-56
@SST
↓
@
SL1 = 0., (start value of loop index)
@SST
↓
@
SL1 = 2.(n), SL2 = 0. (end value of loop
index)
@SST
↓
@
Empty stack (START – beginning of loop)
--- loop execution number 1 for k = 0
@SST
↓
@
SL1 = 0. (k)
@SST
↓
@
SL1 = 0. (SQ(k) = k
2
)
@SST
↓
@
SL1 = 0.(S), SL2 = 0. (k
2
)
@SST
↓
@
SL1 = 0. (S + k
2
)
@SST
↓
@
SL1 = 1., SL2 = 0. (S + k
2
)
@SST
↓
@
SL1 = 0.(k), SL2 = 1., SL3 = 0. (S + k
2
)
@SST
↓
@
SL1 = 1.(k+1), SL2 = 0. (S + k
2
)
@SST
↓
@
SL1 = ‘k’, SL2 = 1., SL3 = 0. (S + k
2
)
@SST
↓
@
SL1 = 0. (S + k
2
) [Stores value of SL2 = 1,
into SL1 = ‘k’]
@SST
↓
@
SL1 = ‘S’, SL2 = 0. (S + k
2
)
@SST
↓
@
Empty stack [Stores value of SL2 = 0, into
SL1 = ‘S’]
@SST
↓
@
Empty stack (NEXT – end of loop)
--- loop execution number 2 for k = 1
@SST
↓
@
SL1 = 1. (k)
@SST
↓
@
SL1 = 1. (SQ(k) = k
2
)
@SST
↓
@
SL1 = 0.(S), SL2 = 1. (k
2
)
@SST
↓
@
SL1 = 1. (S + k
2
)
@SST
↓
@
SL1 = 1., SL2 = 1. (S + k
2
)
@SST
↓
@
SL1 = 1.(k), SL2 = 1., SL3 = 1. (S + k
2
)
@SST
↓
@
SL1 = 2.(k+1), SL2 = 1. (S + k
2
)
@SST
↓
@
SL1 = ‘k’, SL2 = 2., SL3 = 1. (S + k
2
)
@SST
↓
@
SL1 = 1. (S + k
2
) [Stores value of SL2 = 2,
into SL1 = ‘k’]
@SST
↓
@
SL1 = ‘S’, SL2 = 1. (S + k
2
)
@SST
↓
@
Empty stack [Stores value of SL2 = 1, into
SL1 = ‘S’]