Permutations

Used Exports

BUILTINS: INC INTEGER
Oberon: Log Par Par.pos Par.text
Texts: Append Int OpenScanner OpenWriter Scan Scanner Scanner.class Scanner.i WriteInt WriteLn Writer Writer.buf

MODULE Permutations; (*NW 22.1.2013*)
.MODULE Permutations (KEY 100537F4, VERSION 1, SIZE 000003F0)
.IMPORT Texts (KEY 0B9E9984)
.IMPORT Fonts (KEY F4C9F557)
.IMPORT Files (KEY 73F5D686)
.IMPORT Oberon (KEY A89CCEE2)
.IMPORT Display (KEY 4C08D3EA)
.IMPORT Viewers (KEY 25ABF199)
.DATA C8H
.POINTER_REFERENCES 30H 3CH 5CH 50H 30H 3CH 5CH 50H A0H A4H C4H B8H
.FIXUP T 0H
IMPORT Texts, Oberon;
VAR n: INTEGER;
a: ARRAY 10 OF INTEGER;
S: Texts.Scanner;
W: Texts.Writer;
PROCEDURE perm(k: INTEGER);
VAR i, x: INTEGER;
BEGINa
0000a(4EE90010): SUB SP, SP, 10H
0001a(AFE00000): STR LNK, SP, 0H
0002a(A0E00004): STR R0, SP, 4H
IF k = 0 THENb i := 0;c
0003b(80E00004): LDR R0, SP, 4H
0004b(E900001E): BNE 30 [0023H]
0005c(40000000): MOV R0, R0, 0H
0006c(A0E00008): STR R0, SP, 8H
WHILE i < n DOd Texts.WriteInt(W,e a[i]f,g 5)h;i i := i+1 ENDj ;
0007d(80E00008): LDR R0, SP, 8H
0008d .FIXUP D
0008d(8D000008): LDR SB, MT, MOD0 [Permutations]
0009d(81D00000): LDR R1, SB, 0H [data]
000Ad(00090001): SUB R0, R0, R1
000Bd(ED000011): BGE 17 [001DH]
000Ce .FIXUP D
000Ce(8D000004): LDR SB, MT, MOD0 [Permutations]
000De(40D800A0): ADD R0, SB, A0H [data]
000Ee .FIXUP D
000Ee(8D100002): LDR SB, MT, MOD1 [Texts]
000Fe(41D80005): ADD R1, SB, VAR5
0010f(82E00008): LDR R2, SP, 8H
0011f(4329000A): SUB R3, R2, AH
0012f(DA011B1C): BLCC MT [trap=1, pos=283]
0013f(42210002): LSL R2, R2, 2H
0014f .FIXUP D
0014f(8D000006): LDR SB, MT, MOD0 [Permutations]
0015f(02D80002): ADD R2, SB, R2 [global array]
0016g(82200004): LDR R2, R2, 4H
0017h(43000005): MOV R3, R0, 5H
0018i .FIXUP P
0018i(F711E018): BL MOD1 [Texts] PROC30
0019j(80E00008): LDR R0, SP, 8H
001Aj(40080001): ADD R0, R0, 1H
001Bj(A0E00008): STR R0, SP, 8H
001Cj(E7FFFFEA): B -22 [0007H]
Texts.WriteLn(W)k
001Dk .FIXUP D
001Dk(8D000009): LDR SB, MT, MOD0 [Permutations]
001Ek(40D800A0): ADD R0, SB, A0H [data]
001Fk .FIXUP D
001Fk(8D100002): LDR SB, MT, MOD1 [Texts]
0020k(41D80005): ADD R1, SB, VAR5
ELSEl permm(k-1)n;o i := 0;p
0021l .FIXUP P
0021l(F711C009): BL MOD1 [Texts] PROC28
0022m(E700004B): B 75 [006EH]
0023n(80E00004): LDR R0, SP, 4H
0024n(40090001): SUB R0, R0, 1H
0025o(F7FFFFDA): BL -38 [0000H]
0026p(40000000): MOV R0, R0, 0H
0027p(A0E00008): STR R0, SP, 8H
WHILE i < k-1 DOq
0028q(80E00004): LDR R0, SP, 4H
0029q(40090001): SUB R0, R0, 1H
002Aq(81E00008): LDR R1, SP, 8H
002Bq(01190000): SUB R1, R1, R0
002Cq(ED000041): BGE 65 [006EH]
x := a[i]r;s a[i]t := a[k-1]u;v a[k-1]w := x;x
002Dr(80E00008): LDR R0, SP, 8H
002Er(4109000A): SUB R1, R0, AH
002Fr(DA018B1C): BLCC MT [trap=1, pos=395]
0030r(40010002): LSL R0, R0, 2H
0031r .FIXUP D
0031r(8D000012): LDR SB, MT, MOD0 [Permutations]
0032r(00D80000): ADD R0, SB, R0 [global array]
0033s(80000004): LDR R0, R0, 4H
0034s(A0E0000C): STR R0, SP, CH
0035t(80E00008): LDR R0, SP, 8H
0036t(4109000A): SUB R1, R0, AH
0037t(DA01911C): BLCC MT [trap=1, pos=401]
0038t(40010002): LSL R0, R0, 2H
0039t(00D80000): ADD R0, SB, R0
003Au(81E00004): LDR R1, SP, 4H
003Bu(41190001): SUB R1, R1, 1H
003Cu(4219000A): SUB R2, R1, AH
003Du(DA019B1C): BLCC MT [trap=1, pos=411]
003Eu(41110002): LSL R1, R1, 2H
003Fu(01D80001): ADD R1, SB, R1
0040v(81100004): LDR R1, R1, 4H
0041v(A1000004): STR R1, R0, 4H
0042w(80E00004): LDR R0, SP, 4H
0043w(40090001): SUB R0, R0, 1H
0044w(4109000A): SUB R1, R0, AH
0045w(DA01A31C): BLCC MT [trap=1, pos=419]
0046w(40010002): LSL R0, R0, 2H
0047w(00D80000): ADD R0, SB, R0
0048x(81E0000C): LDR R1, SP, CH
0049x(A1000004): STR R1, R0, 4H
perm(k-1)y;z
004Ay(80E00004): LDR R0, SP, 4H
004By(40090001): SUB R0, R0, 1H
004Cz(F7FFFFB3): BL -77 [0000H]
x := a[i]a;b a[i]c := a[k-1]d;e a[k-1]f := x;g
004Da(80E00008): LDR R0, SP, 8H
004Ea(4109000A): SUB R1, R0, AH
004Fa(DA01CE1C): BLCC MT [trap=1, pos=462]
0050a(40010002): LSL R0, R0, 2H
0051a .FIXUP D
0051a(8D000020): LDR SB, MT, MOD0 [Permutations]
0052a(00D80000): ADD R0, SB, R0 [global array]
0053b(80000004): LDR R0, R0, 4H
0054b(A0E0000C): STR R0, SP, CH
0055c(80E00008): LDR R0, SP, 8H
0056c(4109000A): SUB R1, R0, AH
0057c(DA01D41C): BLCC MT [trap=1, pos=468]
0058c(40010002): LSL R0, R0, 2H
0059c(00D80000): ADD R0, SB, R0
005Ad(81E00004): LDR R1, SP, 4H
005Bd(41190001): SUB R1, R1, 1H
005Cd(4219000A): SUB R2, R1, AH
005Dd(DA01DE1C): BLCC MT [trap=1, pos=478]
005Ed(41110002): LSL R1, R1, 2H
005Fd(01D80001): ADD R1, SB, R1
0060e(81100004): LDR R1, R1, 4H
0061e(A1000004): STR R1, R0, 4H
0062f(80E00004): LDR R0, SP, 4H
0063f(40090001): SUB R0, R0, 1H
0064f(4109000A): SUB R1, R0, AH
0065f(DA01E61C): BLCC MT [trap=1, pos=486]
0066f(40010002): LSL R0, R0, 2H
0067f(00D80000): ADD R0, SB, R0
0068g(81E0000C): LDR R1, SP, CH
0069g(A1000004): STR R1, R0, 4H
i := i+1
ENDh
006Ah(80E00008): LDR R0, SP, 8H
006Bh(40080001): ADD R0, R0, 1H
006Ch(A0E00008): STR R0, SP, 8H
006Dh(E7FFFFBA): B -70 [0028H]
END
ENDi perm;
006Ei(8FE00000): LDR LNK, SP, 0H
006Fi(4EE80010): ADD SP, SP, 10H
0070i(C700000F): B LNK
PROCEDURE Generate*;
BEGINj Texts.OpenScanner(S,k Oberon.Par.text,l Oberon.Par.pos)m;n Texts.Scan(S)o;p n := 0;q
0071j .PROC 1
0071j .COMMAND Generate
0071j(4EE90004): SUB SP, SP, 4H
0072j(AFE00000): STR LNK, SP, 0H
0073k .FIXUP D
0073k(8D000022): LDR SB, MT, MOD0 [Permutations]
0074k(40D8002C): ADD R0, SB, 2CH [data]
0075k .FIXUP D
0075k(8D100002): LDR SB, MT, MOD1 [Texts]
0076k(41D80003): ADD R1, SB, VAR3
0077l .FIXUP D
0077l(8D400002): LDR SB, MT, MOD4 [Oberon]
0078l(42D8000E): ADD R2, SB, VAR14
0079l(82200008): LDR R2, R2, 8H
007Am .FIXUP D
007Am(8D400003): LDR SB, MT, MOD4 [Oberon]
007Bm(43D8000E): ADD R3, SB, VAR14
007Cm(8330000C): LDR R3, R3, CH
007Dn .FIXUP P
007Dn(F711505C): BL MOD1 [Texts] PROC21
007Eo .FIXUP D
007Eo(8D000004): LDR SB, MT, MOD0 [Permutations]
007Fo(40D8002C): ADD R0, SB, 2CH [data]
0080o .FIXUP D
0080o(8D100002): LDR SB, MT, MOD1 [Texts]
0081o(41D80003): ADD R1, SB, VAR3
0082p .FIXUP P
0082p(F7116005): BL MOD1 [Texts] PROC22
0083q(40000000): MOV R0, R0, 0H
0084q .FIXUP D
0084q(8D000004): LDR SB, MT, MOD0 [Permutations]
0085q(A0D00000): STR R0, SB, 0H [data]
WHILE S.class = Texts.Int DOr a[n]s := S.i;t INC(n);u Texts.Scan(S)v ENDw ;
0086r .FIXUP D
0086r(8D000002): LDR SB, MT, MOD0 [Permutations]
0087r(80D00068): LDR R0, SB, 68H [data]
0088r(40090003): SUB R0, R0, 3H
0089r(E9000011): BNE 17 [009BH]
008As .FIXUP D
008As(8D000004): LDR SB, MT, MOD0 [Permutations]
008Bs(80D00000): LDR R0, SB, 0H [data]
008Cs(4109000A): SUB R1, R0, AH
008Ds(DA02AF1C): BLCC MT [trap=1, pos=687]
008Es(40010002): LSL R0, R0, 2H
008Fs(00D80000): ADD R0, SB, R0
0090t(81D0006C): LDR R1, SB, 6CH
0091t(A1000004): STR R1, R0, 4H
0092u(40D80000): ADD R0, SB, 0H
0093u(81000000): LDR R1, R0, 0H
0094u(41180001): ADD R1, R1, 1H
0095u(A1000000): STR R1, R0, 0H
0096v(40D8002C): ADD R0, SB, 2CH
0097v .FIXUP D
0097v(8D10000D): LDR SB, MT, MOD1 [Texts]
0098v(41D80003): ADD R1, SB, VAR3
0099w .FIXUP P
0099w(F7116017): BL MOD1 [Texts] PROC22
009Aw(E7FFFFEB): B -21 [0086H]
perm(n)x;y
009Bx .FIXUP D
009Bx(8D000004): LDR SB, MT, MOD0 [Permutations]
009Cx(80D00000): LDR R0, SB, 0H [data]
009Dy(F7FFFF62): BL -158 [0000H]
Texts.Append(Oberon.Log,z W.buf)a
009Ez .FIXUP D
009Ez(8D400003): LDR SB, MT, MOD4 [Oberon]
009Fz(80D0000D): LDR R0, SB, VAR13
00A0a .FIXUP D
00A0a(8D000002): LDR SB, MT, MOD0 [Permutations]
00A1a(81D000A0): LDR R1, SB, A0H [data]
ENDb Generate;
00A2b .FIXUP P
00A2b(F710E009): BL MOD1 [Texts] PROC14
00A3b(8FE00000): LDR LNK, SP, 0H
00A4b(4EE80004): ADD SP, SP, 4H
00A5b(C700000F): B LNK
BEGINc Texts.OpenWriter(W)d
00A6c .PROC 0
00A6c .ENTRYPOINT
00A6c(4EE90004): SUB SP, SP, 4H
00A7c(AFE00000): STR LNK, SP, 0H
00A8d .FIXUP D
00A8d(8D000008): LDR SB, MT, MOD0 [Permutations]
00A9d(40D800A0): ADD R0, SB, A0H [data]
00AAd .FIXUP D
00AAd(8D100002): LDR SB, MT, MOD1 [Texts]
00ABd(41D80005): ADD R1, SB, VAR5
ENDe Permutations.f
00ACe .FIXUP P
00ACe(F711700A): BL MOD1 [Texts] PROC23
00ADf(8FE00000): LDR LNK, SP, 0H
00AEf(4EE80004): ADD SP, SP, 4H
00AFf(C700000F): B LNK