Pascal Implementation by Steven Pemberton and Martin Daniels

Appendix 1: Routines

Routine Headings and Classification

The following is a list of all routine headings in the compiler, showing what line they occur on, their nesting, and which chapter deals with them.

Chapter Line Name and nesting
- 300 procedure mark(var p: marktype); begin end;
- 301 procedure release(p: marktype); begin end;
Lexical 303 procedure endofline;
Lexical 338 procedure error(ferrnr: integer);
Lexical 349 procedure insymbol;
Lexical 358 procedure nextch;
Lexical 373 procedure options;
Semantic 551 procedure enterid(fcp: ctp);
Semantic 575 procedure searchsection(fcp: ctp; var fcp1: ctp);
Semantic 588 procedure searchid(fidcls: setofids; var fcp: ctp);
Semantic 628 procedure getbounds(fsp: stp; var fmin,fmax: integer);
Code generation 646 function alignquot(fsp: stp): integer;
Code generation 668 procedure align(fsp: stp; var flc: addrrange);
- 676 procedure printtables(fb: boolean);
- 680 procedure marker;
- 684 procedure markctp(fp: ctp); forward;
- 686 procedure markstp(fp: stp);
- 707 procedure markctp;
- 721 procedure followctp(fp: ctp); forward;
- 723 procedure followstp(fp: stp);
- 775 procedure followctp;
Code generation 847 procedure genlabel(var nxtlab: integer);
Program 852 procedure block(fsys: setofsys; fsy: symbol; fprocp: ctp);
Syntax 855 procedure skip(fsys: setofsys);
Expressions 864 procedure constant(fsys: setofsys; var fsp: stp; var fvalu: valu);
Semantic 934 function equalbounds(fsp1,fsp2: stp): boolean;
Semantic 946 function comptypes(fsp1,fsp2: stp) : boolean;
Semantic 1018 function string(fsp: stp) : boolean;
Declarations 1025 procedure typ(fsys: setofsys; var fsp: stp; var fsize: addrrange);
Declarations 1029 procedure simpletype(fsys:setofsys; var fsp:stp; var fsize:addrrange);
Declarations 1114 procedure fieldlist(fsys: setofsys; var frecvar: stp);
Declarations 1387 procedure labeldeclaration;
Declarations 1417 procedure constdeclaration;
Declarations 1440 procedure typedeclaration;
Declarations 1483 procedure vardeclaration;
Declarations 1528 procedure procdeclaration(fsy: symbol);
Declarations 1533 procedure parameterlist(fsy: setofsys; var fpar: ctp);
Program 1808 procedure body(fsys: setofsys);
Code generation 1825 procedure mes(i: integer);
Code generation 1830 procedure putic;
Code generation 1833 procedure gen0(fop: oprange);
Code generation 1839 procedure gen1(fop: oprange; fp2: integer);
Code generation 1868 procedure gen2(fop: oprange; fp1,fp2: integer);
Code generation 1904 procedure gentypindicator(fsp: stp);
Code generation 1925 procedure gen0t(fop: oprange; fsp: stp);
Code generation 1936 procedure gen1t(fop: oprange; fp2: integer; fsp: stp);
Code generation 1947 procedure gen2t(fop: oprange; fp1,fp2: integer; fsp: stp);
Code generation 1958 procedure load;
Code generation 1995 procedure store(var fattr: attr);
Code generation 2008 procedure loadaddress;
Code generation 2036 procedure genfjp(faddr: integer);
Code generation 2044 procedure genujpxjp(fop: oprange; fp2: integer);
Code generation 2052 procedure gencupent(fop: oprange; fp1,fp2: integer);
Code generation 2062 procedure checkbnds(fsp: stp);
Code generation 2076 procedure putlabel(labname: integer);
Statements 2080 procedure statement(fsys: setofsys);
Expressions 2084 procedure expression(fsys: setofsys); forward;
Expressions 2086 procedure selector(fsys: setofsys; fcp: ctp);
Procedures 2227 procedure call(fsys: setofsys; fcp: ctp);
Procedures 2230 procedure variable(fsys: setofsys);
Procedures 2239 procedure getputresetrewrite;
Procedures 2247 procedure read;
Procedures 2304 procedure write;
Procedures 2398 procedure pack;
Procedures 2426 procedure unpack;
Procedures 2454 procedure new;
Procedures 2499 procedure mark;
Procedures 2507 procedure release;
Procedures 2517 procedure abs;
Procedures 2526 procedure sqr;
Procedures 2535 procedure trunc;
Procedures 2543 procedure odd;
Procedures 2551 procedure ord;
Procedures 2559 procedure chr;
Procedures 2567 procedure predsucc;
Procedures 2575 procedure eof;
Procedures 2595 procedure callnonstandard;
Expressions 2739 procedure expression;
Expressions 2742 procedure simpleexpression(fsys: setofsys);
Expressions 2745 procedure term(fsys: setofsys);
Expressions 2748 procedure factor(fsys: setofsys);
Statements 3104 procedure assignment(fcp: ctp);
Statements 3146 procedure gotostatement;
Statements 3174 procedure compoundstatement;
Statements 3185 procedure ifstatement;
Statements 3200 procedure casestatement;
Statements 3291 procedure repeatstatement;
Statements 3309 procedure whilestatement;
Statements 3317 procedure forstatement;
Statements 3390 procedure withstatement;
Program 3590 procedure programme(fsys:setofsys);
Program 3624 procedure stdnames;
Program 3641 procedure enterstdtypes;
Program 3669 procedure entstdnames;
Program 3764 procedure enterundecl;
Program 3798 procedure initscalars;
Program 3811 procedure initsets;
Program 3823 procedure inittables;
Program 3824 procedure reswords;
Program 3843 procedure symbols;
Program 3867 procedure rators;
Program 3878 procedure procmnemonics;
Program 3888 procedure instrmnemonics;
Program 3908 procedure chartypes;
Program 3946 procedure initdx;

Alphabetic Index of Routines

Chapter Line Name
Procedures 2517 abs
Code generation 668 align
Code generation 646 alignquot
Statements 3104 assignment
Procedures 852 block
Program 1808 body
Procedures 2227 call
Procedures 2595 callnonstandard
Statements 3200 casestatement
Program 3908 chartypes
Code generation 2062 checkbnds
Procedures 2559 chr
Statements 3174 compoundstatement
Semantic 946 comptypes
Expressions 864 constant
Declarations 1417 constdeclaration
Lexical 303 endofline
Semantic 551 enterid
Program 3641 enterstdtypes
Program 3764 enterundecl
Program 3669 entstdnames
Procedures 2575 eof
Semantic 934 equalbounds
Lexical 338 error
Expressions 2739 expression
Expressions 2748 factor
Declarations 1114 fieldlist
- 721 followctp
- 775 followctp
- 723 followstp
Statements 3317 forstatement
Code generation 1833 gen0
Code generation 1925 gen0t
Code generation 1839 gen1
Code generation 1936 gen1t
Code generation 1868 gen2
Code generation 1947 gen2t
Code generation 2052 gencupent
Code generation 2036 genfjp
Code generation 847 genlabel
Code generation 1904 gentypindicator
Code generation 2044 genujpxjp
Semantic 628 getbounds
Procedures 2239 getputresetrewrite
Statements 3146 gotostatement
Statements 3185 ifstatement
Program 3946 initdx
Program 3798 initscalars
Program 3811 initsets
Program 3823 inittables
Program 3888 instrmnemonics
Lexical 349 insymbol
Declarations 1387 labeldeclaration
Code generation 1958 load
Code generation 2008 loadaddress
Procedures 300 mark
Procedures 2499 mark
- 684 markctp
- 707 markctp
- 680 marker
- 686 markstp
Code generation 1825 mes
Procedures 2454 new
Lexical 358 nextch
Procedures 2543 odd
Lexical 373 options
Procedures 2551 ord
Procedures 2398 pack
Declarations 1533 parameterlist
Procedures 2567 predsucc
- 676 printtables
Declarations 1528 procdeclaration
Program 3878 procmnemonics
Program 3590 programme
Code generation 1830 putic
Code generation 2076 putlabel
Program 3867 rators
Procedures 2247 read
Procedures 301 release
Procedures 2507 release
Statements 3291 repeatstatement
Program 3824 reswords
Semantic 588 searchid
Semantic 575 searchsection
Expressions 2086 selector
Expressions 2742 simpleexpression
Declarations 1029 simpletype
Syntax 855 skip
Procedures 2526 sqr
Statements 2080 statement
Program 3624 stdnames
Code generation 1995 store
Semantic 1018 string
Program 3843 symbols
Expressions 2745 term
Procedures 2535 trunc
Declarations 1025 typ
Declarations 1440 typedeclaration
Procedures 2426 unpack
Declarations 1483 vardeclaration
Procedures 2230 variable
Statements 3309 whilestatement
Statements 3390 withstatement
Procedures 2304 write

Appendix 2: Errors

Error Numbers Generated by the Compiler

These are the meanings of the error numbers as reported in the Pascal User Manual, and the lines that they occur on. Some errors are used differently in the P4 compiler – the text indicates where. A few are not used, and a few are additional, as indicated below with a '+'.

1: error in simple type
1034

2: identifier expected
1057, 1133, 1190, 1192, 1277, 1421, 1444, 1498, 1562, 1606, 1663, 1745, 1778, 2202, 2235, 2621, 3343, 3396, 3594, 3607

3: 'program' expected

4: ')' expected
1062, 1232, 1681, 2295, 2389, 2579, 2681, 2713, 2733, 2820, 3609

5: ':' expected
1077, 1094, 1140, 1173, 1218, 1504, 1610, 1667, 3249, 3444

6: illegal symbol
929, 1059, 1109, 1135, 1230, 1381, 1410, 1434, 1470, 1500, 1515, 1679, 1791, 1799, 2223, 2632, 2894, 3447, 3465, 3586

7: error in parameter list
1538, 1543, 1564, 1587, 1608, 1631, 1665, 1673

8: 'of' expected
1194, 1313, 1354, 3218

9: '(' expected
1219, 2700, 2719

10: error in type
1248, 1285

11: '[' expected
1290

12: ']' expected
1312, 2173, 2870

13: 'end' expected
1349, 3182, 3288, 3505

14: ';' expected
1414, 1436, 1472, 1517, 1783, 1789, 1801, 3295, 3300, 3595, 3612

15: integer expected
1408, 3171

16: '=' expected
1427, 1450

17: 'begin' expected
3583

18: error in declaration part
3580

19: error in field-list
1119, 1152

20: ',' expected
2407, 2413, 2435, 2446, 3605

21: '*' expected
3616

50: error in constant
869

51: ':=' expected
3143, 3354

52: 'then' expected
3189

53: 'until' expected
3306

54: 'do' expected
3313, 3380, 3426

55: 'to'/'downto' expected
3378

56: 'if' expected

57: 'file' expected

58: error in factor
2753

59: error in variable
2128

101: identifier declared twice
564

102: low bound exceeds highbound
1105

103: identifier is not of appropriate class
598

104: identifier not declared
610

105: sign not allowed
912

106: number expected
926

107: incompatible subrange types
1080, 1097

108: file not allowed here
1272

109: type must not be real
1182, 1302

110: tagfield type must be scalar or subrange
1186

111: incompatible with tagfield type
1201

112: index type must not be real

113: index type must be scalar or subrange
1308, 2142

114: base type must not be real
1361

115: base type must be scalar or subrange
1358

116: error in type of standard procedure parameter
2242, 2264, 2269, 2289, 2297, 2321, 2326, 2340, 2347, 2382, 2391, 2406, 2410, 2412, 2421, 2423, 2434, 2443, 2445, 2449, 2451, 2469, 2493, 2504, 2512

117: unsatisfied forward reference
1475, 1520

118: forward reference type identifier in variable declaration

119: forward declared; repetition of parameter list not allowed
1540

120: function result type must be scalar, subrange or pointer
1597, 1775

121: file value parameter not allowed
1645

122: forward declared function repetition of result type not allowed
1769

123: missing result type in function declaration
1781

124: F-format for real only
2348

125: error in type of standard function parameter
2523, 2532, 2538, 2546, 2554, 2562, 2570, 2588

126: number of parameters does not agree with declaration
2608, 2684

127: illegal parameter substitution

128: result type of parameter function does not agree
2628

129: type conflict of operands
3042, 3098, 3140

130: expression is not of set type
3043

131: tests on equality allowed only
3068

132: strict inclusion not allowed
3072

133: file comparison not allowed
3087

134: illegal type of operand(s)
2924, 2937, 2941, 2944, 2947, 2963, 2989, 3011, 3016, 3078, 3083

135: type of operand must be boolean
2827

136: set element type must be scalar or subrange
2845

137: set element types not compatible
2866

138: type of variable is not array
2137

139: index type is not compatible with declaration
2160

140: type of variable is not record
2182, 3422

141: type of variable must be file or pointer
2219

142: illegal parameter substitution
2670

143: illegal type of loop control variable
3339

144: illegal type of expression
2039, 3215, 3347, 3358

145: type conflict
3351, 3376

146: assignment of files not allowed
3138

147: label type incompatible with selecting expression
3245

148: subrange bounds must be scalar
1074, 1091

149: index type must not be integer
1305

150: assignment to standard function is not allowed
2115

151: assignment to formal function is not allowed
2118

152: no such field in this record
2189

153: type error in read

154: actual parameter must be a variable
2668

155: control variable must neither be formal nor non local
3334

156: multidefined case label
3232

157: too many cases in case statement
3286

158: missing corresponding variant declaration
2474

159: real or string tagfields not allowed
2479

160: previous declaration was not forward
1714

161: again forward declared
1786

162: parameter size must be constant
2476

163: missing variant in declaration

164: substitution of standard proc/func not allowed

165: multidefined label
3437

166: multideclared label
1397

167: undeclared label
3168, 3442

168: undefined label
3511

169: error in base set
1363, 1367

170: value parameter expected

171: standard file was redeclared

172: undeclared external file

173: Fortran procedure or function expected

174: Pascal procedure or function expected

175: missing file "input" in program heading

176: missing file "output" in program heading

+ 177: You may only assign to the identifier of a function in the body of that function occurs on lines:
2120

+ 178: Duplicated variant part in record declaration
1211

201: error in real constant: digit expected
435, 448

202: string constant must not exceed source line
487

203: integer constant exceeds range
459, 467, 475

204: 8 or 9 in octal number

+ 205: zero length string
490

250: too many nested scopes of identifiers
1340, 1758, 3421

251: too many nested procedures and/or functions
1747

252: too many forward references of procedure entries

253: procedure too long

254: too many long constants in this procedure
1973, 2015, 2877

255: too many errors on this source line

256: too many external references

257: too many externals

258: too many local files

259: expression too complicated

300: division by zero

301: no case provided for this value

302: index expression out of bounds

303: value to be assigned is out of bounds

304: element expression out of range
2852

398: implementation restriction

399: variable dimension arrays not implemented
404, 495, 1103, 1183, 1376, 1547, 1570, 2244, 2262, 2288, 2319, 2349, 2372, 2400, 2428, 2610, 2619, 3163

+ 400: internal compiler error
1987, 2002, 2004, 2021, 2027, 2029, 2196

+ 500: internal compiler error
1921

+ 501: internal compiler error
664

Appendix 3: Code Generation

Code Generation Calls

The following is a list of all the calls to the code generator indicating what line they occurred on. The instruction-generation calls are sorted alphabetically by instruction.

Line Call

2520 gen0(0(*abi*))

2522 gen0(1(*abr*))

2972 gen0(2(*adi*))

2985 gen0(3(*adr*))

2946 gen0(4(*and*))

2071 gen2t(45(*chk*),lmin,lmax,fsp)

2153 gen2t(45(*chk*),lmin,lmax,intptr);

2211 gen2t(45(*chk*),1,maxaddr,nilptr);

3132 gen2t(45(*chk*),0,maxaddr,nilptr);

3270 gen2t(45(*chk*),lmin,lmax,intptr);

2563 gen0(59(*chr*));

2243 gen1(30(*csp*),lkey(*get,put*))

2281 gen1(30(*csp*),3(*rdi*))

2284 gen1(30(*csp*),4(*rdr*))

2287 gen1(30(*csp*),5(*rdc*))

2300 gen1(30(*csp*),21(*rln*))

2355 gen1(30(*csp*),6(*wri*))

2361 gen1(30(*csp*),8(*wrr*))

2367 gen1(30(*csp*),9(*wrc*))

2380 gen1(30(*csp*),10(*wrs*))

2394 gen1(30(*csp*),22(*wln*))

2496 gen1(30(*csp*),12(*new*));

2503 gen1(30(*csp*),23(*sav*))

2511 gen1(30(*csp*),13(*rst*))

2589 gen1(30(*csp*),14(*eln*));

2687 gen1(30(*csp*),pfname)

2688 gencupent(46(*cup*),locpar,pfname);

3538 gencupent(46(*cup*),0,entname);

2154 gen1t(31(*dec*),lmin,intptr)

2571 gen1t(31(*dec*),1,gattr.typtr)

3384 gen1t(31(*dec*),1,gattr.typtr);

3010 gen0(5(*dif*))

2940 gen0(6(*dvi*))

2936 gen0(7(*dvr*))

3474 gencupent(32(*ent1*),1,segsize);

3474 gencupent(32(*ent2*),2,stacktop);

2589 gen0(8(*eof*))

3095 gen2(47(*equ*),ord(typind),lsize)

3188 genfjp(lcix1);

3304 genfjp(laddr)

3312 genfjp(lcix);

3379 genujpxjp(33(*fjp*),lcix);

2910 gen0(9(*flo*));

2932 gen0(9(*flo*));

2976 gen0(9(*flo*));

2997 gen0(9(*flo*));

3048 gen0(9(*flo*));

2650 gen0(10(*flt*));

2915 gen0(10(*flt*));

2928 gen0(10(*flt*));

2981 gen0(10(*flt*));

3002 gen0(10(*flt*));

3053 gen0(10(*flt*));

3120 gen0(10(*flt*));

3093 gen2(48(*geq*),ord(typind),lsize);

3374 gen2(48(*geq*),ord('i'),1);

3092 gen2(49(*grt*),ord(typind),lsize);

2026 gen1t(34(*inc*),idplmt,nilptr);

2156 gen1t(34(*inc*),-lmin,intptr);

2572 gen1t(34(*inc*),1,gattr.typtr)

3383 gen1t(34(*inc*),1,gattr.typtr)

1986 gen1t(35(*ind*),idplmt,typtr);

3041 gen0(11(*inn*))

2923 gen0(12(*int*))

3015 gen0(13(*ior*))

2169 gen1(36(*ixa*),lsize)

2023 gen1(37(*lao*),dplmt)

2019 gen1(38(*lca*),cstptrix)

2024 gen2(50(*lda*),level-vlevel,dplmt);

2277 gen2(50(*lda*),level-llev,laddr);

2299 gen2(50(*lda*),level-llev,laddr);

2354 gen2(50(*lda*),level-llev,laddr);

2360 gen2(50(*lda*),level-llev,laddr);

2366 gen2(50(*lda*),level-llev,laddr);

2379 gen2(50(*lda*),level-llev,laddr);

2393 gen2(50(*lda*),level-llev,laddr);

3488 gen2(50(*lda*),0,vaddr);

1965 gen2(51(*ldc*),3,cval.ival)

1968 gen2(51(*ldc*),6,cval.ival)

1969 gen2(51(*ldc*),1,cval.ival)

1971 gen2(51(*ldc*),4,0)

1978 gen2(51(*ldc*),2,cstptrix)

1980 gen2(51(*ldc*),5,cstptrix)

2353 gen2(51(*ldc*),1,10);

2359 gen2(51(*ldc*),1,20);

2365 gen2(51(*ldc*),1,1);

2377 gen2(51(*ldc*),1,len);

2378 gen2(51(*ldc*),1,len);

2495 gen2(51(*ldc*),1,lsize);

2881 gen2(51(*ldc*),5,cstptrix);

3271 gen2(51(*ldc*),1,lmin);

1984 gen1t(39(*ldo*),dplmt,typtr)

2109 gen1t(39(*ldo*),vdspl,nilptr)

3091 gen2(52(*leq*),ord(typind),lsize);

3373 gen2(52(*leq*),ord('i'),1)

3090 gen2(53(*les*),ord(typind),lsize);

1985 gen2t(54(*lod*),level-vlevel,dplmt,typtr);

2098 gen2t(54(*lod*),level-vlev,vaddr,nilptr);

2110 gen2t(54(*lod*),0,vdspl,nilptr);

3370 gen2t(54(*lod*),0,lc,intptr);

3489 gen2t(54(*lod*),0,llc1,nilptr);

2943 gen0(14(*mod*))

3137 gen1(40(*mov*),lattr.typtr^.size);

3490 gen1(40(*mov*),idtype^.size);

2906 gen0(15(*mpi*))

2919 gen0(16(*mpr*))

2601 gen1(41(*mst*),level-pflev)

3538 gen1(41(*mst*),0);

3094 gen2(55(*neq*),ord(typind),lsize);

2960 gen0(17(*ngi*))

2962 gen0(18(*ngr*))

2824 gen0(19(*not*));

2547 gen0(20(*odd*));

2144 gen0t(58(*ord*),gattr.typtr);

2555 gen0t(58(*ord*),gattr.typtr);

2858 gen0t(58(*ord*),gattr.typtr);

3032 gen0t(58(*ord*),gattr.typtr);

3216 gen0t(58(*ord*),lsp);

3363 gen0t(58(*ord*),gattr.typtr);

3369 gen0t(58(*ord*),gattr.typtr);

3519 gen1(42(*ret*),ord('p'))

3520 gen0t(42(*ret*),fprocp^.idtype);

3528 gen1(42(*ret*),ord('p'));

3271 gen0(21(*sbi*));

2993 gen0(21(*sbi*))

3006 gen0(22(*sbr*))

2859 gen0(23(*sgs*));

2529 gen0(24(*sqi*))

2531 gen0(25(*sqr*))

2000 gen1t(43(*sro*),dplmt,typtr)

2003 gen0t(26(*sto*),typtr);

3538 gen0(29(*stp*));

2001 gen2t(56(*str*),level-vlevel,dplmt,typtr);

3365 gen2t(56(*str*),0,lc,intptr);

3414 gen2t(56(*str*),0,lc,nilptr);

2539 gen0(27(*trc*));

3277 gen0(60(*ujc error*));

3162 genujpxjp(57(*ujp*),labname)

3192 genujpxjp(57(*ujp*),lcix2);

3217 genujpxjp(57(*ujp*),lcix);

3254 genujpxjp(57(*ujp*),laddr);

3280 genujpxjp(57(*ujp*),csstart);

3314 genujpxjp(57(*ujp*),laddr);

3385 genujpxjp(57(*ujp*),laddr);

2860 gen0(28(*uni*))

2882 gen0(28(*uni*));

2988 gen0(28(*uni*))

3272 genujpxjp(44(*xjp*),lcix);

3471 genlabel(entname);

3219 genlabel(laddr);

3311 genlabel(laddr);

3366 genlabel(laddr);

3293 genlabel(laddr);

1401 genlabel(lbname);

1722 genlabel(lbname);

3211 genlabel(lcix);

3271 genlabel(lcix);

3312 genlabel(lcix);

3379 genlabel(lcix);

3188 genlabel(lcix1);

3221 genlabel(lcix1);

3192 genlabel(lcix2);

3787 genlabel(pfname);

3793 genlabel(pfname);

3473 genlabel(segsize);

3473 genlabel(stacktop);

1930 gentypindicator(fsp);

1941 gentypindicator(fsp);

1952 gentypindicator(fsp);

1917 gentypindicator(rangetype);

3473 putlabel(entname);

3438 putlabel(labname);

3284 putlabel(laddr)

3293 putlabel(laddr);

3311 putlabel(laddr);

3366 putlabel(laddr);

3314 putlabel(lcix)

3259 putlabel(lcix);

3272 putlabel(lcix);

3385 putlabel(lcix);

3197 putlabel(lcix1)

3193 putlabel(lcix1);

3250 putlabel(lcix1);

3195 putlabel(lcix2)

An Example of Code Produced by the Compiler

     1        9 (*$c+*) 
     2        9 program example(input, output); 
     3        9 var a, b: integer; 
     4       11   
     5       11 procedure divideby(r: integer); 
     6        6 var q: integer; 
     7        7 begin
     8        3      q:=0; 
     9        7      while r>=b do 
    10       11      begin 
    11       11           r:=r-b; 
    12       15           q:=q+1 
    13       16      end; 
    14       20      writeln('Quotient ', q:4, ' remander ', r:4); 
    15       40 end; 
    16       41     
    17       41 begin 
    18       41      read(a, b); 
    19       49      if (a>0) and (b>0) then divideby(a) 
    20       59 end. 
l   3
 ent   1   l   4
 ent   2   l   5
 ldci            0
 stri  0       6
l   6
 lodi  0       5
 ldoi          9
 geqi
i   10
 fjp       l   7
 lodi  0       5
 ldoi          9
 sbi
 stri  0       5
 lodi  0       6
 ldci            1
 adi
 stri  0       6
 ujp       l   6
l   7
i   20
 lca'Quotient        '
 ldci            9
 ldci            9
 lda   1       6
 csp         wrs
 lodi  0       6
 ldci            4
 lda   1       6
 csp         wri
 lca' remander       '
i   30
 ldci           10
 ldci           10
 lda   1       6
 csp         wrs
 lodi  0       5
 ldci            4
 lda   1       6
 csp         wri
 lda   1       6
 csp         wln
i   40
 retp
l   4=           7
l   5=           9
l   8
 ent   1   l   9
 ent   2   l  10
 lao          10
 lda   0       5
 csp         rdi
 lao           9
 lda   0       5
 csp         rdi
 ldoi         10
i   50
 ldci            0
 grti
 ldoi          9
 ldci            0
 grti
 and
 fjp       l  11
 mst           0
 ldoi         10
 cup   1   l   3
l  11
i   60
 retp
l   9=          11
l  10=           8
q
i    0
 mst           0
 cup   0   l   8
 stp
q

Pascal Implementation by Steven Pemberton and Martin Daniels