Reformatted using CODE tags to enhance readability.thank you All
Im so happy
Ok..
I m working with 8086
I want to solve the matrix multiplications
that is A and B and the result will stor at C
it defined as:
Cik = Aij * Bik
A,B and C there size is 4*4
where j is summed over for all possible values of i and k,there for , in order for matrix multiplication to be defined , the dimensions of the matrix must satisfy
(n*m)(m*p)=(n*p)
....................................................
this is my code but Ithink it not good
I want better one
Rich (BB code):.model small .data m equ 4 k equ 2 n equ 4 xmat dw m*k dup(0) ymat dw k*n dup(0) buffer db m*n*20 dup(0) result dw m*n*2 dup (0) marker db (0) f_input db "input.dat",0 f_output db "output.dat",0 inhandle dw ? outhandle dw ? buffersize dw ? err_open db "couldn't open file !","$" err_creat db "couldn't create the file","$" err_write db "couldn't write the file","$" err_close db "couldn't write the file","$" msg db "Press any key to continue...","$" ;---------------------------------------------------------------------------- .code main: mov ax,@data mov ds,ax call open call read mov di,offset buffer mov si,offset xmat mov cl,m*k call asciitobin mov cl,k*n mov si,offset ymat call asciitobin call matrixmul call bintoascii call creatfile call writefile mov bx,inhandle call closefile mov bx,outhandle call closefile mov dx,offset buffer call err_msg mov dx,offset msg call err_msg mov ah,07h int 21h mov ah,4ch int 21h ;----------------------------------------------------------------------------- open proc near mov ah,3dh mov al,0 mov dx,offset f_input int 21h jc o_error mov inhandle,ax jmp o_exit o_error: mov dx,offset err_open call err_msg o_exit: ret open endp ;------------------------------------------------------------------------------ err_msg proc near mov ah,9h int 21h ret err_msg endp ;------------------------------------------------------------------------------ read proc near mov ah,3fh mov bx,inhandle mov cx,m*n*20 mov dx,offset buffer int 21h ret read endp ;------------------------------------------------------------------------------ asciitobin proc near mov bh,0 mov bp,10d next: mov ax,0 here: mov bl,[di] cmp bl,20h je there sub bl,30h mul bp add ax,bx inc di jmp here there: mov word ptr[si],ax inc di add si,2 dec cl jnz next add di,2 ret asciitobin endp ;------------------------------------------------------------------------------ matrixmul proc near mov si,0 mov di,0 mov cl,m lp2: mov ch,n mov bx,0 lp1: call vectormul mov result[di],ax mov result[di+2],dx add di,4 add bx,2 dec ch jnz lp1 add si,k*2 dec cl jnz lp2 ret matrixmul endp ;-------------------------------------------------- vectormul proc near push si push bx push cx push bp push di mov bp,0 mov di,0 mov cl,k lp: mov ax,xmat[si] mul ymat[bx] add bp,ax adc di,dx add si,2 add bx,2*n dec cl jnz lp mov ax,bp mov dx,di pop di pop bp pop cx pop bx pop si ret vectormul endp ;------------------------------------------------- bintoascii proc near mov si,offset marker sub si,4 mov bx,10 mov cl,m*n mov bp,sp lp4: mov ax,word ptr[si] mov dx,word ptr[si+2] mov ch,0 lp3: div bx add dx,30h push dx inc ch mov dx,0 or ax,ax jnz lp3 push cx sub si,4 dec cl jnz lp4 ;------------------------------------------------------ ; storeing in buffer section ;------------------------------------------------------ mov di,offset buffer mov bl,m mov dx,0 lp7: mov bh,n lp6: pop cx lp5: pop ax mov [di],al inc di inc dx dec ch jnz lp5 mov byte ptr[di],20h inc di inc dx dec bh jnz lp6 mov byte ptr[di],0dh mov byte ptr[di+1],0ah add di,2 add dx,2 dec bl jnz lp7 mov byte ptr[di],'$' mov buffersize,dx mov sp,bp ret bintoascii endp ;------------------------------------------------- creatfile proc near mov ah,3ch mov cx,0 mov dx,offset f_output int 21h jc c_error mov outhandle,ax jmp c_exit c_error: mov dx,offset err_creat call err_msg c_exit: ret creatfile endp ;------------------------------------------------- writefile proc near mov ah,40h mov bx,outhandle mov cx,buffersize mov dx,offset buffer int 21h jnc w_exit mov dx,offset err_write call err_msg w_exit: ret writefile endp ;------------------------------------------------------------------------------ closefile proc near mov ah,3eh int 21h jnc cl_exit mov dx,offset err_close call err_msg cl_exit: ret closefile endp ;------------------------------------------------------------------------------ end main
Did your teacher indicate what he/she did not like about your code?hi every body
the code is correct
but my teacher dont like it
I must solve it in another way But Icant chagne my idea
So I need your help
These would be 80186, 80286, 80386, 80486, and 80586, although I'm not sure that Intel used the last number much, and seemed to prefer Pentium instead.And then 8186 was born stillborn, after wiggling for a short while.
And the 8286 was born, and DOS found it good, but everyone else scratched their heads.
And thus the 8386 was born, which devolved into a SX. No one knew why. Windows Loved It.
Which begat the 8486, the last of the absolute standards.
Which begat the 8586, which the Supreme Court found copyrightable, and the tower of Bedlam was brought low.
It might be that your teacher actually likes this code but suspects that you might not have written it. If you wrote this code yourself, you would understand it well enough to be able to change it. If you didn't write it, and therefore are less likely to understand it, it will be difficult for you to change it.hi every body
the code is correct
but my teacher dont like it
I must solve it in another way But Icant chagne my idea
So I need your help