Before I get started on the help I need I will say that yes this is a project for school so I'm not looking for anyone to give me the code but my group is new to MASM and struggling to get the code. We understand how to find the RREF on paper, but not through code. Here is our assignment:
Row-Echelon Matrix Reduction
Write a program that calculates the row-echelon form of a matrix of any size. The matrix values are all integer and stored in an input file. The reduced matrix is stored in an output file. The values of the output matrix should also be integer values.
And here is our current code, it's bad we know:
.MODEL SMALL ;Defines memory model as small which uses separate segments for code and data
.386 ;Microprocessor number
.STACK ;Stack segment defined as 1024 by default
.DATA ;Begins definition of the data type used in this project
ROW DB ?
COLUMN DB ?
RREF DB "matrix.txt", 0
.CODE
;-------------------------------------------------------------------------------------------
READ MACRO
MOV CX, LENGTHOF RREF
MOV DX, OFFSET RREF
MOV AH, 3FH ;Read
INT 21H
JC QUIT
CMP AX, 1
JNE QUIT
;-------------------------------------------------------------------------------------------
Main PROC FAR ;Defines procedure distance as far
.STARTUP
;Program:
MOV BP, 0
MOV SI, 0
MOV AX, 3D02h ;Open file
MOV DX, OFFSET RREF
INT 21H
MOV BX, AX
IF ROW<COLUMN
D=ROW
IF ROW>COLUMN
D=COLUMN
FOR d=1...D
e=M(d,d)
FOR r=d...(ROW-1)
X=M(ROW,d)/e
FOR col=d...COLUMN
M(r,col)=M(r,col)-e*X
PUSH BP
MOV BP, SP
CALL REDUCTION
JC QUIT
ADD SP 2+4
POP BP
MOV AH,40h
INT 21H
MOV AH, 3Eh
INT 21H
QUIT: .EXIT
MAIN ENDP
REDUCTION PROC
PUSHAD
MOVZX EAX, ROW
MOV EDX, EAX
MOVZX EBX, COLUMN
SUB EBX, 1
MUL EBX
JC QUIT
SUB EDX, 1
ADD EAX, EDX
JC QUIT
LOOP
POPAD
RET
REDUCTION ENDP
END
The code itself is all over the place. We have to open a file from MATLAB containing a matrix in the form [R,C,#,#,#,#,#,#,#,#,#,#, etc.] where the first two bytes are the row and column numbers respectively, and the rest are the elements of the matrix stored in 8 bytes each. The matrix can go all the way to R-C dimensions of 255,255 but that is randomly generated in MATLAB. Once we open and read the file, we have to calculate the reduced row echelon form with only the elements below the diagonal zeroed out, everything above the diagonal doesn't matter. Then we must write the RREF matrix to an output file to be opened in MATLAB and displayed.
Any and all help will be greatly appreciated, we just need to be steered in the right direction. Here is our trouble:
1. How to read two separate bytes, then each element, which are 8 bytes long a piece, and what to do with them
2. How to code for reducing the lower half of the matrix
3. How to write to an output file
Programs we are using are Textpad 6 and Codeview debugger