\def\date{04 Jan 2012}\def\source{V1, p.\ 177}\def\author{Udo Wermuth}\input mmix =-3 !!\clearline{\tenbf Program I} ({\tenit Inverse in place\/})\smallskip N IS 6 !! Number of elements in the permutation j IS $2 !! Variables of the algorithm i IS $3 mm IS $4 !! For $m$ the value is multiplied by 8 LOC Data_Segment X GREG @ OCTA 0 !! $X[0]$ is not used OCTA 6,2,1,5,4,3 !! The data of Table 1.3.3--3 LOC #100 * Inverse a permutation in place !! \startnumbering Invert SET mm,N !1! \step I1. Initialize. SL mm,mm,3 !1! $m\gets n$. NEG j,1 !1! $j\gets-1$. 2H LDO i,X,mm !N! \step I2. Next element. $i\gets X[m]$. PBN i,5F !N!\bad C\bad To I5 if $i<0$. 3H STO j,X,mm !N! \step I3. Invert one. $X[m]\gets j$. SR j,mm,3 !N! NEG j,j !N! $j\gets-m$. SL mm,i,3 !N! $m\gets i$. LDO i,X,mm !N! $i\gets X[m]$. 4H PBP i,3B !N!\bad C\bad \steq I4. End of cycle? To I3 if $i>0$. SET i,j !C! Otherwise set $i\gets j$. 5H NEG i,i !N! \step I5. Store final value. STO i,X,mm !N! $X[m]\gets-i$. 6H SUB mm,mm,8 !N! \step I6. Loop on $m$. PBP mm,2B !N!\bad 1\bad To I2 if $m>0$. \stopnumbering * inspect memory locations of array X for the result TRAP 0,Halt,0 Main IS Invert !! \eop !!\endwAoA\bye