How to write assembly language as following:
1.please create a 6*6 integer matrix and initializes all elements to 0
2.And reads a user input signed integer , sets the diagonal elements to the
input value and displays the matrix

E.G. User Input : 9

Program Output : 9 0 0 0 0 0
0 9 0 0 0 0
0 0 9 0 0 0
0 0 0 9 0 0
0 0 0 0 9 0
0 0 0 0 0 9


Please help me ~ Thanx !!!


My code is here:


Title matrix
INCLUDE Irvine32.inc

.data

source BYTE "000000",0
target BYTE sizeof source DUP(0)
count DWORD ?

msgA BYTE "Please input a number:",0

tableA BYTE 0d , 0d, 0d, 0d, 0d, 0d
BYTE 0d , 0d, 0d, 0d, 0d, 0d
BYTE 0d , 0d, 0d, 0d, 0d, 0d
BYTE 0d , 0d, 0d, 0d, 0d, 0d
BYTE 0d , 0d, 0d, 0d, 0d, 0d
BYTE 0d , 0d, 0d, 0d, 0d, 0d
NumCols = 6
RowNumber DWORD ?
ColumnNumber DWORD ?


.code

diagonal PROC

mov ecx , 6
L3:


push eax
mov RowNumber , 0
mov ColumnNumber , 0
mov ebx , OFFSET tableA
mov eax , NumCols
mul RowNumber
add ebx , eax
mov esi , ColumnNumber
mov edx ,
pop eax
mov edx , eax


; Trouble in here :
; How to print the matrix out?



inc RowNumber
inc ColumnNumber
Loop L3




diagonal ENDP



main PROC
mov ecx , 6
L1:
mov count , ecx
mov esi , 0
mov ecx , sizeof source

L2: mov al , source
mov target , al
inc esi

Loop L2
mov ecx , count
mov edx , OFFSET target
call WriteString
call Crlf

Loop L1

call Crlf
mov edx , OFFSET msgA
call WriteString
call ReadInt
call diagonal

exit
main ENDP
END main


:stupid:
Posted on 2004-06-06 03:33:15 by Angus
Sounds like homework? :)
And I have no idea what helper functions you're using there (WriteString, ReadInt etc?).
I guess your teacher supplied them, ask him :P
Posted on 2004-06-06 04:25:56 by Scali
Yeah~Scali , you are right
the homework almost drives me crazy
mm....I think I would use "WriteString"and "ReadInt"
Please help me to overcome it

Sigh...I have tried to solve it for several days without
nice sleepness
Posted on 2004-06-06 11:43:17 by Angus