You do not need more operations. In fact, you do not need DUP and DROP, either. All you need are SWAP, PUSH and PULL.
The list of states of main stack below shows how the initial state 1 a 3 p q r 2 x y
is changed to 1 a 2 x y 3 p q r
. The auxiliary stack is at left hand side growing to the right from its bottom at the very left. The main stack is at right hand side growing to the left from it bottom at the very right. <-
means PUSHing to the auxiliary stack and ->
mean PULLing from the auxiliary stack.
<- 1 a 3 p q r 2 x y //initial state
1 <- a 3 p q r 2 x y
1 a <- 3 p q r 2 x y
1 a 3 <- p q r 2 x y
1 a 3 p <- q r 2 x y
1 a 3 p q r 2 x y //then SWAP
1 a 3 p q -> 2 r x y
1 a 3 p q 2 r x y //then SWAP
1 a 3 p -> 2 q r x y
1 a 3 p 2 q r x y //then SWAP
1 a 3 -> 2 p q r x y
1 a 3 2 p q r x y //then SWAP
1 a <- 2 3 p q r x y
1 a 2 <- 3 p q r x y
1 a 2 3 <- p q r x y
1 a 2 3 p <- q r x y
1 a 2 3 p q r x y //then SWAP
1 a 2 3 p q -> x r y
1 a 2 3 p q x r y //then SWAP
1 a 2 3 p -> x q r y
1 a 2 3 p x q r y //then SWAP
1 a 2 3 -> x p q r y
1 a 2 3 x p q r y //then SWAP
1 a 2 <- x 3 p q r y
1 a 2 x <- 3 p q r y
1 a 2 x 3 <- p q r y
1 a 2 x 3 p <- q r y
1 a 2 x 3 p q r y //then SWAP
1 a 2 x 3 p q -> y r
1 a 2 x 3 p q y r //then SWAP
1 a 2 x 3 p -> y q r
1 a 2 x 3 p y q r //then SWAP
1 a 2 x 3 -> y p q r
1 a 2 x 3 y p q r //then SWAP
1 a 2 x -> y 3 p q r
1 a 2 -> x y 3 p q r
1 a -> 2 x y 3 p q r
1 -> a 2 x y 3 p q r
1 a 2 x y 3 p q r //final state
Once you have checked the above procedure, you will understand how to proceed in the general situations. In fact, what have been shown above is, basically, the well-known fact that if you can swap any two adjacent elements in an array, you can sort all elements in the array into any permutation you wanted.
x <x arbitrary elements> z <z arbitrary elements> y <y arbitrary elements>
? $\endgroup$3 a b c 4 d e f g 5 h i j k l
, afterwards it should be arranged like:3 a b c 5 h i j k l 4 d e f g
(the lengths are given purely for example). $\endgroup$