\def\date{06 Jan 2012}\def\source{V1, p.\ 178}\def\author{Udo Wermuth}\input mmix =-3 !!\clearline{\tenbf Program J} ({\tenit Inverse in place\/})\smallskip N IS 6 !! Number of elements in the permutation t IS $255 !! Temporary storage i IS $2 !! Variables of the algorithm ii IS i !! Two characters indicate that the jj IS $3 !! \quad variable is multiplied by 8 k IS jj mm IS $4 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--4 LOC #100 * Inverse a permutation in place !! \startnumbering Invert SET t,N !1! \step J1. Negate all. $t\gets n$. SL mm,t,3 !1! $m\gets n$. 1H LDO k,X,mm !N! NEG k,k !N! STO k,X,mm !N! $X[k]\gets -X[k]$. SUB mm,mm,8 !N! $m\gets m-1$. PBP mm,1B !N!\bad 1\bad Branch if $m>0$. SL mm,t,3 !1! $m\gets n$. 2H SR i,mm,3 !N! \step J2. Initialize. $i\gets m$. 3H SL jj,i,3 !A! \step J3. Find neagtive entry. $j\gets i$. LDO i,X,jj !A! $i\gets X[j]$. PBP i,3B !A!\bad N\bad To J3 if $i>0$. 4H NEG i,i !N! \step J4. Invert. SL ii,i,3 !N! LDO t,X,ii !N! $t\gets X[-i]$ STO t,X,jj !N! \quad and $X[j]\gets X[-i]$. SR t,mm,3 !N! $t\gets m$ STO t,X,ii !N! \quad and $X[-i]\gets m$. 5H SUB mm,mm,8 !N! \step J5. Loop on $m$. $m\gets m-1$. PBP mm,2B !N!\bad 1\bad Branch if $m>0$.\stopnumbering * inspect memory locations of array X for the result TRAP 0,Halt,0 Main IS Invert !! \eop !!\endwAoA\bye