// // The following routine demonstrates missappropriation of registers // on the LSI-11 (Runs OK on the VAX) // while doing operations on items in an array of 4 bit integers // if the index into the array is a variable. // If the index is a constant, this routine works OK. // // The routine should print 1 2 3 4 but it prints -1 0 -1 0 instead. // // The M11 code can be modified so that this routine works correctly // by changing the overused R5 to R4 which is not used at all // (see the edited M11 file) // main module test //%set debug_print_ccode = true %set use_routine_names = true //%set tree_list = true use TEXTIO procedure T () endprocedure out_line (TTY, "Test dynamic indexing into 4 bit integer arrays") out_line (TTY, "by assigning then retrieving a number in each element") out_line (TTY, " ") out_line (TTY, "Following should print out 1 2 3 4") declare A : static packed array [1..4] of 4 bit integer enddeclare T () // put a mark in M11 thats easy to find for I := 1 to 4 do A [I] := I endfor T () // put a mark in M11 thats easy to find out_integer (TTY, A[1]) out_string (TTY, " ") out_integer (TTY, A[2]) out_string (TTY, " ") out_integer (TTY, A[3]) out_string (TTY, " ") out_integer (TTY, A[4]) out_record (TTY) endmodule