Loading...
 

Fetch

Fetch

Fetch, Fetch(n)

Stack
Stack Position Description
Stack(In) Top n
Top 1 any
. . . . . .
Top-n Value x
Top-n+1 any
Stack(Out) Top Value x
Top 1 . . .

Replaces the number n lying on the stack top with the nth element on the stack (calculated from the stack top). If the current stack depth is less than n+2, INVALID is written to the stack as return value. The position (n) can also be passed directly to the fetch command, in this case the result is the same although there is one argument less on the stack.

" 2 Fetch" is the same as " Fetch(2)" and delivers the on the Stack-Top)

Example 1

Stack Position Description
Stack(In) Top 0
Top 1 1
Stack(Out) Top 1
Top 1 1

"0 Fetch" is equivalent to "Dup".

Example 2

Stack Position Description
Stack(In) Top 1
Top 1 am
top 2 me
Stack(Out) Top me
Top 1 am
top 2 me

Example 3

Stack Position Description
Stack(In) Top 3
Top 1 me
top 2 am
top 3 me
Stack(Out) Top INVALID
Top 1 me
top 2 am
top 3 me