#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 %begin
int main(int argc, char **argv) { /*%begin*/
_imp_initialise(argc, argv);
// 2
// 3 %integer first subscript, second subscript
int FIRSTSUBSCRIPT;
int SECONDSUBSCRIPT;
// 4 %integername element
int *ELEMENT;
// 5 %integer i
int I;
// 6
// 7 ! imp77 doesn't allow initialised multi-dimensional arrays. (Imp80 would!)
// 8 ! So I'll initialise these explicitly:
// 9 %integerarray A(1:3, 1:2)
int A[3][2];
// 10
// 11
// 12 { EMAS IMP80 and IMP77: in a two-dimensional array whose first element was (1,1), }
// 13 { the order would be (1,1), (2,1), (3,1), i.e. first subscript changing fastest. }
// 14 element == A(1,1); element = i %and element == INTEGER(ADDR(element)+4) %for i = 1, 1, 3*2
ELEMENT = (int *)/*?*/ &A[0][0];
// %for I = 1, 1, 3 * 2 %cycle
{
int _final = 3 * 2;
if (invalid_for_loop(1, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = 1, 1, 3 * 2");
I = 0;
L_0001:
if (I == _final) goto L_0002;
I += 1;
*ELEMENT = I;
ELEMENT = (int *)_imp_INTEGER(_imp_ADDR(ELEMENT) + 4);
goto L_0001;
}
L_0002:;
// 15
// 16 %for second subscript = 1,1,2 %cycle
// %for SECONDSUBSCRIPT = 1, 1, 2 %cycle
{
SECONDSUBSCRIPT = 0;
L_0004:
if (SECONDSUBSCRIPT == 2) goto L_0005;
SECONDSUBSCRIPT += 1;
// 17 %for first subscript = 1,1,3 %cycle
// %for FIRSTSUBSCRIPT = 1, 1, 3 %cycle
{
FIRSTSUBSCRIPT = 0;
L_0006:
if (FIRSTSUBSCRIPT == 3) goto L_0007;
FIRSTSUBSCRIPT += 1;
// 18 print string("A("); write(first subscript, -1)
_imp_PRINTSTRING(_imp_str_literal("A("));
_imp_WRITE(FIRSTSUBSCRIPT, -1);
// 19 print string(", "); write(second subscript, -1)
_imp_PRINTSTRING(_imp_str_literal(", "));
_imp_WRITE(SECONDSUBSCRIPT, -1);
// 20 print string(") = "); write(A(first subscript, second subscript), -1)
_imp_PRINTSTRING(_imp_str_literal(") = "));
_imp_WRITE(A[FIRSTSUBSCRIPT - 1][SECONDSUBSCRIPT - 1], -1);
// 21 print string(", ")
_imp_PRINTSTRING(_imp_str_literal(", "));
// 22 %repeat
goto L_0006;
}
L_0007:;
// 23 newline
_imp_NEWLINE();
// 24 %repeat
goto L_0004;
}
L_0005:;
// 25 newline
_imp_NEWLINE();
// 26
// 27 %endofprogram
_imp_stop(0);
return 0;
end_0:;
}