A Guide to Array Implementation Prepare index registers x and y for runtime. For declaration var w, a[10]; record w as variable and a as array together with the size 10 or 11 according to your definition. For assignment statement such as a[i+j]:=w+a[j-k]; the value of the left index i+j is stored in register y and that of the right index j-k in register x. Those can be processed by expression. To load the value of a[j-k], use the new machine instruction ldx. stx 0,0 store the top of stack into x sty 0,0 store the top of stack into y ldx l,a load s[base(l)+a+x] into the top of stack ssy l,a store the top of stack into s[base(l)+a+y] Example $ for <= var i, y, z[10]; begin i:=1; while i$9 do begin z[i]:=i; i:=i+1; end; y:=0; i:=0; while i$9 do begin y:=y+z[i]; i:=i+1; end; write(y); write(z[5]); end. 0 jmp 0 1 1 inc 0 15 2 lit 0 1 3 sto 0 3 i:=1; 4 lod 0 3 load i 5 lit 0 9 load literal 9 6 opr 0 11 i<=9? 7 jpc 0 17 jump to 17 if false 8 lod 0 3 load i 9 sty 0 0 store stack-top to index register y 10 lod 0 3 load i 11 ssy 0 5 z[i]:=i; 12 lod 0 3 13 lit 0 1 14 opr 0 2 15 sto 0 3 i:=i+1; 16 jmp 0 4 go back to while 17 lit 0 0 18 sto 0 4 y:=0; 19 lit 0 0 20 sto 0 3 i:=0; 21 lod 0 3 22 lit 0 9 23 opr 0 11 i<=9? 24 jpc 0 36 jump to 36 if false 25 lod 0 4 load y 26 lod 0 3 load i 27 stx 0 0 store stack-top to index register x 28 ldx 0 5 load z[i] 29 opr 0 2 y+z[i] 30 sto 0 4 y:=y+z[i]; 31 lod 0 3 32 lit 0 1 33 opr 0 2 34 sto 0 3 i:=i+1; 35 jmp 0 21 go back to while 36 lod 0 4 37 wrt 0 0 38 lit 0 5 39 stx 0 0 index register x is set to 5 40 ldx 0 5 load z[5] 41 wrt 0 0 write z[5], which is stack-top 42 opr 0 0 start PL/0 45 5 END PL/0 start PL/0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 4 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