| 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 |
0000 | a(4EE90010): SUB SP, SP, 10H |
0001 | a(AFE00000): STR LNK, SP, 0H |
0002 | a(A0E00004): STR R0, SP, 4H |
| IF k = 0 THENb i := 0;c |
0003 | b(80E00004): LDR R0, SP, 4H |
0004 | b(E900001E): BNE 30 [0023H] |
0005 | c(40000000): MOV R0, R0, 0H |
0006 | c(A0E00008): STR R0, SP, 8H |
| WHILE i < n DOd Texts.WriteInt(W,e a[i]f,g 5)h;i i := i+1 ENDj ; |
0007 | d(80E00008): LDR R0, SP, 8H |
0008 | d .FIXUP D |
0008 | d(8D000008): LDR SB, MT, MOD0 [Permutations] |
0009 | d(81D00000): LDR R1, SB, 0H [data] |
000A | d(00090001): SUB R0, R0, R1 |
000B | d(ED000011): BGE 17 [001DH] |
000C | e .FIXUP D |
000C | e(8D000004): LDR SB, MT, MOD0 [Permutations] |
000D | e(40D800A0): ADD R0, SB, A0H [data] |
000E | e .FIXUP D |
000E | e(8D100002): LDR SB, MT, MOD1 [Texts] |
000F | e(41D80005): ADD R1, SB, VAR5 |
0010 | f(82E00008): LDR R2, SP, 8H |
0011 | f(4329000A): SUB R3, R2, AH |
0012 | f(DA011B1C): BLCC MT [trap=1, pos=283] |
0013 | f(42210002): LSL R2, R2, 2H |
0014 | f .FIXUP D |
0014 | f(8D000006): LDR SB, MT, MOD0 [Permutations] |
0015 | f(02D80002): ADD R2, SB, R2 [global array] |
0016 | g(82200004): LDR R2, R2, 4H |
0017 | h(43000005): MOV R3, R0, 5H |
0018 | i .FIXUP P |
0018 | i(F711E018): BL MOD1 [Texts] PROC30 |
0019 | j(80E00008): LDR R0, SP, 8H |
001A | j(40080001): ADD R0, R0, 1H |
001B | j(A0E00008): STR R0, SP, 8H |
001C | j(E7FFFFEA): B -22 [0007H] |
| Texts.WriteLn(W)k |
001D | k .FIXUP D |
001D | k(8D000009): LDR SB, MT, MOD0 [Permutations] |
001E | k(40D800A0): ADD R0, SB, A0H [data] |
001F | k .FIXUP D |
001F | k(8D100002): LDR SB, MT, MOD1 [Texts] |
0020 | k(41D80005): ADD R1, SB, VAR5 |
| ELSEl permm(k-1)n;o i := 0;p |
0021 | l .FIXUP P |
0021 | l(F711C009): BL MOD1 [Texts] PROC28 |
0022 | m(E700004B): B 75 [006EH] |
0023 | n(80E00004): LDR R0, SP, 4H |
0024 | n(40090001): SUB R0, R0, 1H |
0025 | o(F7FFFFDA): BL -38 [0000H] |
0026 | p(40000000): MOV R0, R0, 0H |
0027 | p(A0E00008): STR R0, SP, 8H |
| WHILE i < k-1 DOq |
0028 | q(80E00004): LDR R0, SP, 4H |
0029 | q(40090001): SUB R0, R0, 1H |
002A | q(81E00008): LDR R1, SP, 8H |
002B | q(01190000): SUB R1, R1, R0 |
002C | q(ED000041): BGE 65 [006EH] |
| x := a[i]r;s a[i]t := a[k-1]u;v a[k-1]w := x;x |
002D | r(80E00008): LDR R0, SP, 8H |
002E | r(4109000A): SUB R1, R0, AH |
002F | r(DA018B1C): BLCC MT [trap=1, pos=395] |
0030 | r(40010002): LSL R0, R0, 2H |
0031 | r .FIXUP D |
0031 | r(8D000012): LDR SB, MT, MOD0 [Permutations] |
0032 | r(00D80000): ADD R0, SB, R0 [global array] |
0033 | s(80000004): LDR R0, R0, 4H |
0034 | s(A0E0000C): STR R0, SP, CH |
0035 | t(80E00008): LDR R0, SP, 8H |
0036 | t(4109000A): SUB R1, R0, AH |
0037 | t(DA01911C): BLCC MT [trap=1, pos=401] |
0038 | t(40010002): LSL R0, R0, 2H |
0039 | t(00D80000): ADD R0, SB, R0 |
003A | u(81E00004): LDR R1, SP, 4H |
003B | u(41190001): SUB R1, R1, 1H |
003C | u(4219000A): SUB R2, R1, AH |
003D | u(DA019B1C): BLCC MT [trap=1, pos=411] |
003E | u(41110002): LSL R1, R1, 2H |
003F | u(01D80001): ADD R1, SB, R1 |
0040 | v(81100004): LDR R1, R1, 4H |
0041 | v(A1000004): STR R1, R0, 4H |
0042 | w(80E00004): LDR R0, SP, 4H |
0043 | w(40090001): SUB R0, R0, 1H |
0044 | w(4109000A): SUB R1, R0, AH |
0045 | w(DA01A31C): BLCC MT [trap=1, pos=419] |
0046 | w(40010002): LSL R0, R0, 2H |
0047 | w(00D80000): ADD R0, SB, R0 |
0048 | x(81E0000C): LDR R1, SP, CH |
0049 | x(A1000004): STR R1, R0, 4H |
| perm(k-1)y;z |
004A | y(80E00004): LDR R0, SP, 4H |
004B | y(40090001): SUB R0, R0, 1H |
004C | z(F7FFFFB3): BL -77 [0000H] |
| x := a[i]a;b a[i]c := a[k-1]d;e a[k-1]f := x;g |
004D | a(80E00008): LDR R0, SP, 8H |
004E | a(4109000A): SUB R1, R0, AH |
004F | a(DA01CE1C): BLCC MT [trap=1, pos=462] |
0050 | a(40010002): LSL R0, R0, 2H |
0051 | a .FIXUP D |
0051 | a(8D000020): LDR SB, MT, MOD0 [Permutations] |
0052 | a(00D80000): ADD R0, SB, R0 [global array] |
0053 | b(80000004): LDR R0, R0, 4H |
0054 | b(A0E0000C): STR R0, SP, CH |
0055 | c(80E00008): LDR R0, SP, 8H |
0056 | c(4109000A): SUB R1, R0, AH |
0057 | c(DA01D41C): BLCC MT [trap=1, pos=468] |
0058 | c(40010002): LSL R0, R0, 2H |
0059 | c(00D80000): ADD R0, SB, R0 |
005A | d(81E00004): LDR R1, SP, 4H |
005B | d(41190001): SUB R1, R1, 1H |
005C | d(4219000A): SUB R2, R1, AH |
005D | d(DA01DE1C): BLCC MT [trap=1, pos=478] |
005E | d(41110002): LSL R1, R1, 2H |
005F | d(01D80001): ADD R1, SB, R1 |
0060 | e(81100004): LDR R1, R1, 4H |
0061 | e(A1000004): STR R1, R0, 4H |
0062 | f(80E00004): LDR R0, SP, 4H |
0063 | f(40090001): SUB R0, R0, 1H |
0064 | f(4109000A): SUB R1, R0, AH |
0065 | f(DA01E61C): BLCC MT [trap=1, pos=486] |
0066 | f(40010002): LSL R0, R0, 2H |
0067 | f(00D80000): ADD R0, SB, R0 |
0068 | g(81E0000C): LDR R1, SP, CH |
0069 | g(A1000004): STR R1, R0, 4H |
| i := i+1 |
| ENDh |
006A | h(80E00008): LDR R0, SP, 8H |
006B | h(40080001): ADD R0, R0, 1H |
006C | h(A0E00008): STR R0, SP, 8H |
006D | h(E7FFFFBA): B -70 [0028H] |
| END |
| ENDi perm; |
006E | i(8FE00000): LDR LNK, SP, 0H |
006F | i(4EE80010): ADD SP, SP, 10H |
0070 | i(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 |
0071 | j .PROC 1 |
0071 | j .COMMAND Generate |
0071 | j(4EE90004): SUB SP, SP, 4H |
0072 | j(AFE00000): STR LNK, SP, 0H |
0073 | k .FIXUP D |
0073 | k(8D000022): LDR SB, MT, MOD0 [Permutations] |
0074 | k(40D8002C): ADD R0, SB, 2CH [data] |
0075 | k .FIXUP D |
0075 | k(8D100002): LDR SB, MT, MOD1 [Texts] |
0076 | k(41D80003): ADD R1, SB, VAR3 |
0077 | l .FIXUP D |
0077 | l(8D400002): LDR SB, MT, MOD4 [Oberon] |
0078 | l(42D8000E): ADD R2, SB, VAR14 |
0079 | l(82200008): LDR R2, R2, 8H |
007A | m .FIXUP D |
007A | m(8D400003): LDR SB, MT, MOD4 [Oberon] |
007B | m(43D8000E): ADD R3, SB, VAR14 |
007C | m(8330000C): LDR R3, R3, CH |
007D | n .FIXUP P |
007D | n(F711505C): BL MOD1 [Texts] PROC21 |
007E | o .FIXUP D |
007E | o(8D000004): LDR SB, MT, MOD0 [Permutations] |
007F | o(40D8002C): ADD R0, SB, 2CH [data] |
0080 | o .FIXUP D |
0080 | o(8D100002): LDR SB, MT, MOD1 [Texts] |
0081 | o(41D80003): ADD R1, SB, VAR3 |
0082 | p .FIXUP P |
0082 | p(F7116005): BL MOD1 [Texts] PROC22 |
0083 | q(40000000): MOV R0, R0, 0H |
0084 | q .FIXUP D |
0084 | q(8D000004): LDR SB, MT, MOD0 [Permutations] |
0085 | q(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 ; |
0086 | r .FIXUP D |
0086 | r(8D000002): LDR SB, MT, MOD0 [Permutations] |
0087 | r(80D00068): LDR R0, SB, 68H [data] |
0088 | r(40090003): SUB R0, R0, 3H |
0089 | r(E9000011): BNE 17 [009BH] |
008A | s .FIXUP D |
008A | s(8D000004): LDR SB, MT, MOD0 [Permutations] |
008B | s(80D00000): LDR R0, SB, 0H [data] |
008C | s(4109000A): SUB R1, R0, AH |
008D | s(DA02AF1C): BLCC MT [trap=1, pos=687] |
008E | s(40010002): LSL R0, R0, 2H |
008F | s(00D80000): ADD R0, SB, R0 |
0090 | t(81D0006C): LDR R1, SB, 6CH |
0091 | t(A1000004): STR R1, R0, 4H |
0092 | u(40D80000): ADD R0, SB, 0H |
0093 | u(81000000): LDR R1, R0, 0H |
0094 | u(41180001): ADD R1, R1, 1H |
0095 | u(A1000000): STR R1, R0, 0H |
0096 | v(40D8002C): ADD R0, SB, 2CH |
0097 | v .FIXUP D |
0097 | v(8D10000D): LDR SB, MT, MOD1 [Texts] |
0098 | v(41D80003): ADD R1, SB, VAR3 |
0099 | w .FIXUP P |
0099 | w(F7116017): BL MOD1 [Texts] PROC22 |
009A | w(E7FFFFEB): B -21 [0086H] |
| perm(n)x;y |
009B | x .FIXUP D |
009B | x(8D000004): LDR SB, MT, MOD0 [Permutations] |
009C | x(80D00000): LDR R0, SB, 0H [data] |
009D | y(F7FFFF62): BL -158 [0000H] |
| Texts.Append(Oberon.Log,z W.buf)a |
009E | z .FIXUP D |
009E | z(8D400003): LDR SB, MT, MOD4 [Oberon] |
009F | z(80D0000D): LDR R0, SB, VAR13 |
00A0 | a .FIXUP D |
00A0 | a(8D000002): LDR SB, MT, MOD0 [Permutations] |
00A1 | a(81D000A0): LDR R1, SB, A0H [data] |
| ENDb Generate; |
00A2 | b .FIXUP P |
00A2 | b(F710E009): BL MOD1 [Texts] PROC14 |
00A3 | b(8FE00000): LDR LNK, SP, 0H |
00A4 | b(4EE80004): ADD SP, SP, 4H |
00A5 | b(C700000F): B LNK |
| |
| BEGINc Texts.OpenWriter(W)d |
00A6 | c .PROC 0 |
00A6 | c .ENTRYPOINT |
00A6 | c(4EE90004): SUB SP, SP, 4H |
00A7 | c(AFE00000): STR LNK, SP, 0H |
00A8 | d .FIXUP D |
00A8 | d(8D000008): LDR SB, MT, MOD0 [Permutations] |
00A9 | d(40D800A0): ADD R0, SB, A0H [data] |
00AA | d .FIXUP D |
00AA | d(8D100002): LDR SB, MT, MOD1 [Texts] |
00AB | d(41D80005): ADD R1, SB, VAR5 |
| ENDe Permutations.f |
00AC | e .FIXUP P |
00AC | e(F711700A): BL MOD1 [Texts] PROC23 |
00AD | f(8FE00000): LDR LNK, SP, 0H |
00AE | f(4EE80004): ADD SP, SP, 4H |
00AF | f(C700000F): B LNK |