MIME-Version: 1.0 Server: CERN/3.0 Date: Monday, 16-Dec-96 23:18:38 GMT Content-Type: text/html Content-Length: 8016 Last-Modified: Monday, 13-Mar-95 14:33:34 GMT
------------------------------------------------------------------------------------------------------------- A m x n matrix of 16-bit unsigned integers A is the first matrix in the product. B n x p matrix of 16-bit unsigned integers B is the second matrix in the product. m unsigned 8-bit integer m is the number of rows in A n unsigned 8-bit integer n is the number of columns in A and the number of rows in B. p unsigned 8-bit integer p is the number of columns in B m, n, and p satisfy 1 <= m,n,p <= 16 -------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------- C m x p matrix of 16-bit unsigned integers C = AB mod 2^16 -------------------------------------------------------------------------
Matrices should be output in standard order, i.e., a row of elements in the matrix should correspond to a row of numbers on the screen. For example, if A were a 2 x 2 matrix with elements a11 = 1, a12 = 2, a21 = 3, and a22 = 4, then A would be output as:
1 2 3 4Matrices should be input by prompting the user for elements, one at a time, in the same order in which they would be output. The text of the prompt should include the matrix name and the indices of the element currently being prompted for. For example, the matrix A given above would be entered via the following exchange (underlined text indicates the program's output, non-underlined text indicates the user's input):
A[1][1]: 1 A[1][2]: 2 A[2][1]: 3 A[2][2]: 4
m: 2 n: 3 p: 4 A[1][1]: 0 A[1][2]: 1 A[1][3]: 2 A[2][1]: 3 A[2][2]: 4which corresponds to:A[2][3]: 5 B[1][1]: 10 B[1][2]: 11 B[1][3]: 12 B[1][4]: 13 B[2][1]: 14 B[2][2]: 15 B[2][3]: 16 B[2][4]: 17 B[3][1]: 18 B[3][2]: 65510 B[3][3]: 20 B[3][4]: 21 A: 0 1 2 3 4 5 B: 10 11 12 13 14 15 16 17 18 65510 20 21 Result (A*B): 50 65499 56 59 176 65499 200 212
;------------------------------------------------------------------------- ; ; <Name of function> ; ; ; Synopsis ; <A brief description of what the function does, who calls it, ; why, and any exceptional conditions.> ; ; HLL description: ; ; <Put in high level language (e.g., C, pascal, pseudo-code) ; description of routine here.> ; ; Register usage: ; <Map out what registers are used for> ; ; Input Conditions: ; <What should the format of the registers and stack be on entry ; to the routine?> ; ; Output Conditions: ; <What will the format of the registers and stack be when the ; routine returns?> ; ; Stack frame: ; <What does the stack frame look like? For example:> ; ; Saved Registers ; A6 --> Old A6 0(A6) ; Return Address 4(A6) ; Param 1 8(A6) ; Param 2 12(A6) ; ;-------------------------------------------------------------------------The subroutine code should immediately follow the subroutine header. Try to comment each line and use block comments and blank spaces to separate logical sections of the subroutine. For example, here's the code of a routine that swaps the two registers D0 and D1 if D1 < D0.
SWAP: ; ; Prolog: Save registers, set up stack frame ; LINK A6,#0 ; set frame pointer -- no locals MOVEM.L D2,-(SP) ; Save registers we'll use. ; ; Compare D0 and D1 to see if we need to do anything. ; If not, then just jump to epilog and leave. ; CMP D1,D0 BLT DONE ; ; If we get here, D1 < D0. ; Swap the contents of D0 and D1, using D2 as a scratch register ; MOVE.L D0,D2 ; tmp:= D0 MOVE.L D1,D0 ; D0:= D1 MOVE.L D2,D0 ; D0:= tmp ; ; Epilog: Restore registers, clean up stack frame, return. ; DONE: MOVEM.L (SP)+,D2 ; Restore registers, etc. UNLK A6 RTSTry to give a high level description in the function header, a more detailed description in the block comments, and a blow-by-blow in the individual line comments. Don't just repeat what the code says, if possible.
In addition, for this project, be sure you document the following aspects of your program:
You'll probably need to adapt the 32-bit signed decimal i/o routines in the BasePak library for use as 16-bit unsigned routines. (For this project, simply taking the low-order word of the return from decin_long would be acceptable for inputting 16-bit unsigned integers (though that wouldn't be a such a great idea in a real program), and using decout_long will work for outputting 16-bit unsigned integers as long as you remember to clear the high word of d0.)