Fractions

Used Exports

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

MODULE Fractions; (*NW 10.10.07; Tabulate fractions 1/n*)
.MODULE Fractions (KEY 94BFA2E6, VERSION 1, SIZE 00000354)
.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 28H
.POINTER_REFERENCES 0H 4H 24H 18H
.FIXUP T 0H
IMPORT Texts, Oberon;
CONST Base = 10; N = 32;
VAR W: Texts.Writer;
PROCEDURE Generate*;
VAR i, j, m, r: INTEGER;
d: ARRAY N OF INTEGER; (*digits*)
x: ARRAY N OF INTEGER; (*index*)
S: Texts.Scanner;
BEGINa Texts.OpenScanner(S,b Oberon.Par.text,c Oberon.Par.pos)d;e Texts.Scan(S)f;g
0000a .PROC 1
0000a .COMMAND Generate
0000a(4EE90188): SUB SP, SP, 188H
0001a(AFE00000): STR LNK, SP, 0H
0002b(40E80114): ADD R0, SP, 114H
0003b .FIXUP D
0003b(8D100003): LDR SB, MT, MOD1 [Texts]
0004b(41D80003): ADD R1, SB, VAR3
0005c .FIXUP D
0005c(8D400002): LDR SB, MT, MOD4 [Oberon]
0006c(42D8000E): ADD R2, SB, VAR14
0007c(82200008): LDR R2, R2, 8H
0008d .FIXUP D
0008d(8D400003): LDR SB, MT, MOD4 [Oberon]
0009d(43D8000E): ADD R3, SB, VAR14
000Ad(8330000C): LDR R3, R3, CH
000Be .FIXUP P
000Be(F711500B): BL MOD1 [Texts] PROC21
000Cf(40E80114): ADD R0, SP, 114H
000Df .FIXUP D
000Df(8D100005): LDR SB, MT, MOD1 [Texts]
000Ef(41D80003): ADD R1, SB, VAR3
000Fg .FIXUP P
000Fg(F7116004): BL MOD1 [Texts] PROC22
IF (S.class = Texts.Int)h & (iS.i < N)j THENk
0010h(80E00150): LDR R0, SP, 150H
0011h(40090003): SUB R0, R0, 3H
0012i(E9000099): BNE 153 [00ACH]
0013j(80E00154): LDR R0, SP, 154H
0014j(40090020): SUB R0, R0, 20H
0015k(ED000096): BGE 150 [00ACH]
i := 2;l
0016l(40000002): MOV R0, R0, 2H
0017l(A0E00004): STR R0, SP, 4H
WHILE i <= S.i DOm j := 0;n
0018m(80E00004): LDR R0, SP, 4H
0019m(81E00154): LDR R1, SP, 154H
001Am(00090001): SUB R0, R0, R1
001Bm(EE000090): BGT 144 [00ACH]
001Cn(40000000): MOV R0, R0, 0H
001Dn(A0E00008): STR R0, SP, 8H
WHILE j < i DOo x[j]p := 0;q INC(j) ENDr ;
001Eo(80E00008): LDR R0, SP, 8H
001Fo(81E00004): LDR R1, SP, 4H
0020o(00090001): SUB R0, R0, R1
0021o(ED00000B): BGE 11 [002DH]
0022p(80E00008): LDR R0, SP, 8H
0023p(41090020): SUB R1, R0, 20H
0024p(DA01EF1C): BLCC MT [trap=1, pos=495]
0025p(40010002): LSL R0, R0, 2H
0026p(00E80000): ADD R0, SP, R0
0027q(41000000): MOV R1, R0, 0H
0028q(A1000094): STR R1, R0, 94H
0029r(80E00008): LDR R0, SP, 8H
002Ar(40080001): ADD R0, R0, 1H
002Br(A0E00008): STR R0, SP, 8H
002Cr(E7FFFFF1): B -15 [001EH]
m := 0;s r := 1;t
002Ds(40000000): MOV R0, R0, 0H
002Es(A0E0000C): STR R0, SP, CH
002Ft(40000001): MOV R0, R0, 1H
0030t(A0E00010): STR R0, SP, 10H
WHILE x[r]u = 0 DOv
0031u(80E00010): LDR R0, SP, 10H
0032u(41090020): SUB R1, R0, 20H
0033u(DA022D1C): BLCC MT [trap=1, pos=557]
0034u(40010002): LSL R0, R0, 2H
0035u(00E80000): ADD R0, SP, R0
0036v(80000094): LDR R0, R0, 94H
0037v(E900001E): BNE 30 [0056H]
x[r]w := m;x r := Base*r;y d[m]z := r DIV i;a r := r MOD i;b INC(m)
0038w(80E00010): LDR R0, SP, 10H
0039w(41090020): SUB R1, R0, 20H
003Aw(DA02431C): BLCC MT [trap=1, pos=579]
003Bw(40010002): LSL R0, R0, 2H
003Cw(00E80000): ADD R0, SP, R0
003Dx(81E0000C): LDR R1, SP, CH
003Ex(A1000094): STR R1, R0, 94H
003Fy(80E00010): LDR R0, SP, 10H
0040y(400A000A): MUL R0, R0, AH
0041y(A0E00010): STR R0, SP, 10H
0042z(80E0000C): LDR R0, SP, CH
0043z(41090020): SUB R1, R0, 20H
0044z(DA025B1C): BLCC MT [trap=1, pos=603]
0045z(40010002): LSL R0, R0, 2H
0046z(00E80000): ADD R0, SP, R0
0047a(81E00004): LDR R1, SP, 4H
0048a(D602676C): BLLE MT [trap=6, pos=615]
0049a(82E00010): LDR R2, SP, 10H
004Aa(012B0001): DIV R1, R2, R1
004Ba(A1000014): STR R1, R0, 14H
004Cb(80E00004): LDR R0, SP, 4H
004Db(D602756C): BLLE MT [trap=6, pos=629]
004Eb(81E00010): LDR R1, SP, 10H
004Fb(001B0000): DIV R0, R1, R0
0050b(20000000): MOV' R0, R0, R0
0051b(A0E00010): STR R0, SP, 10H
ENDc ;
0052c(80E0000C): LDR R0, SP, CH
0053c(40080001): ADD R0, R0, 1H
0054c(A0E0000C): STR R0, SP, CH
0055c(E7FFFFDB): B -37 [0031H]
Texts.WriteInt(W,d i,e 5)f;g Texts.Write(W,h 9X)i;j Texts.Write(W,k ".")l;m j := 0;n
0056d .FIXUP D
0056d(8D000049): LDR SB, MT, MOD0 [Fractions]
0057d(40D80000): ADD R0, SB, 0H [data]
0058d .FIXUP D
0058d(8D100002): LDR SB, MT, MOD1 [Texts]
0059d(41D80005): ADD R1, SB, VAR5
005Ae(82E00004): LDR R2, SP, 4H
005Bf(43000005): MOV R3, R0, 5H
005Cg .FIXUP P
005Cg(F711E04D): BL MOD1 [Texts] PROC30
005Dh .FIXUP D
005Dh(8D000005): LDR SB, MT, MOD0 [Fractions]
005Eh(40D80000): ADD R0, SB, 0H [data]
005Fh .FIXUP D
005Fh(8D100002): LDR SB, MT, MOD1 [Texts]
0060h(41D80005): ADD R1, SB, VAR5
0061i(42000009): MOV R2, R0, 9H
0062j .FIXUP P
0062j(F711B006): BL MOD1 [Texts] PROC27
0063k .FIXUP D
0063k(8D000004): LDR SB, MT, MOD0 [Fractions]
0064k(40D80000): ADD R0, SB, 0H [data]
0065k .FIXUP D
0065k(8D100002): LDR SB, MT, MOD1 [Texts]
0066k(41D80005): ADD R1, SB, VAR5
0067l(4200002E): MOV R2, R0, 2EH
0068m .FIXUP P
0068m(F711B006): BL MOD1 [Texts] PROC27
0069n(40000000): MOV R0, R0, 0H
006An(A0E00008): STR R0, SP, 8H
WHILE j < x[r]o DOp Texts.Write(W,q CHR(d[j]r + 48)s);t INC(j) ENDu ;
006Bo(80E00010): LDR R0, SP, 10H
006Co(41090020): SUB R1, R0, 20H
006Do(DA02F31C): BLCC MT [trap=1, pos=755]
006Eo(40010002): LSL R0, R0, 2H
006Fo(00E80000): ADD R0, SP, R0
0070p(81E00008): LDR R1, SP, 8H
0071p(80000094): LDR R0, R0, 94H
0072p(01190000): SUB R1, R1, R0
0073p(ED000010): BGE 16 [0084H]
0074q .FIXUP D
0074q(8D00000F): LDR SB, MT, MOD0 [Fractions]
0075q(40D80000): ADD R0, SB, 0H [data]
0076q .FIXUP D
0076q(8D100002): LDR SB, MT, MOD1 [Texts]
0077q(41D80005): ADD R1, SB, VAR5
0078r(82E00008): LDR R2, SP, 8H
0079r(43290020): SUB R3, R2, 20H
007Ar(DA030E1C): BLCC MT [trap=1, pos=782]
007Br(42210002): LSL R2, R2, 2H
007Cr(02E80002): ADD R2, SP, R2
007Ds(82200014): LDR R2, R2, 14H
007Es(42280030): ADD R2, R2, 30H
007Ft .FIXUP P
007Ft(F711B017): BL MOD1 [Texts] PROC27
0080u(80E00008): LDR R0, SP, 8H
0081u(40080001): ADD R0, R0, 1H
0082u(A0E00008): STR R0, SP, 8H
0083u(E7FFFFE7): B -25 [006BH]
Texts.Write(W,v "'")w;x
0084v .FIXUP D
0084v(8D00000E): LDR SB, MT, MOD0 [Fractions]
0085v(40D80000): ADD R0, SB, 0H [data]
0086v .FIXUP D
0086v(8D100002): LDR SB, MT, MOD1 [Texts]
0087v(41D80005): ADD R1, SB, VAR5
0088w(42000027): MOV R2, R0, 27H
0089x .FIXUP P
0089x(F711B00A): BL MOD1 [Texts] PROC27
WHILE j < m DOy Texts.Write(W,z CHR(d[j]a + 48)b);c INC(j) ENDd ;
008Ay(80E00008): LDR R0, SP, 8H
008By(81E0000C): LDR R1, SP, CH
008Cy(00090001): SUB R0, R0, R1
008Dy(ED000010): BGE 16 [009EH]
008Ez .FIXUP D
008Ez(8D000008): LDR SB, MT, MOD0 [Fractions]
008Fz(40D80000): ADD R0, SB, 0H [data]
0090z .FIXUP D
0090z(8D100002): LDR SB, MT, MOD1 [Texts]
0091z(41D80005): ADD R1, SB, VAR5
0092a(82E00008): LDR R2, SP, 8H
0093a(43290020): SUB R3, R2, 20H
0094a(DA036F1C): BLCC MT [trap=1, pos=879]
0095a(42210002): LSL R2, R2, 2H
0096a(02E80002): ADD R2, SP, R2
0097b(82200014): LDR R2, R2, 14H
0098b(42280030): ADD R2, R2, 30H
0099c .FIXUP P
0099c(F711B010): BL MOD1 [Texts] PROC27
009Ad(80E00008): LDR R0, SP, 8H
009Bd(40080001): ADD R0, R0, 1H
009Cd(A0E00008): STR R0, SP, 8H
009Dd(E7FFFFEC): B -20 [008AH]
Texts.WriteLn(W)e;f Texts.Append(Oberon.Log,g W.buf)h;i INC(i)
009Ee .FIXUP D
009Ee(8D00000E): LDR SB, MT, MOD0 [Fractions]
009Fe(40D80000): ADD R0, SB, 0H [data]
00A0e .FIXUP D
00A0e(8D100002): LDR SB, MT, MOD1 [Texts]
00A1e(41D80005): ADD R1, SB, VAR5
00A2f .FIXUP P
00A2f(F711C009): BL MOD1 [Texts] PROC28
00A3g .FIXUP D
00A3g(8D400003): LDR SB, MT, MOD4 [Oberon]
00A4g(80D0000D): LDR R0, SB, VAR13
00A5h .FIXUP D
00A5h(8D000002): LDR SB, MT, MOD0 [Fractions]
00A6h(81D00000): LDR R1, SB, 0H [data]
00A7i .FIXUP P
00A7i(F710E005): BL MOD1 [Texts] PROC14
ENDj
00A8j(80E00004): LDR R0, SP, 4H
00A9j(40080001): ADD R0, R0, 1H
00AAj(A0E00004): STR R0, SP, 4H
00ABj(E7FFFF6C): B -148 [0018H]
END
ENDk Generate;
00ACk(8FE00000): LDR LNK, SP, 0H
00ADk(4EE80188): ADD SP, SP, 188H
00AEk(C700000F): B LNK
BEGINl Texts.OpenWriter(W)m
00AFl .PROC 0
00AFl .ENTRYPOINT
00AFl(4EE90004): SUB SP, SP, 4H
00B0l(AFE00000): STR LNK, SP, 0H
00B1m .FIXUP D
00B1m(8D00000C): LDR SB, MT, MOD0 [Fractions]
00B2m(40D80000): ADD R0, SB, 0H [data]
00B3m .FIXUP D
00B3m(8D100002): LDR SB, MT, MOD1 [Texts]
00B4m(41D80005): ADD R1, SB, VAR5
ENDn Fractions.o
00B5n .FIXUP P
00B5n(F711700E): BL MOD1 [Texts] PROC23
00B6o(8FE00000): LDR LNK, SP, 0H
00B7o(4EE80004): ADD SP, SP, 4H
00B8o(C700000F): B LNK