我必须将函数从程序集调用到C,这会累加列
extern void sum_col(int n,int m,long int * matrix [],long int new_col []);
用于汇编代码
MOV BP,SP
MOV CX , [BP+4]
MOV N , CX
MOV CX , [BP+6]
MOV M ,CX
MOV SI ,[BP+8]
MOV DI, [BP+10]
;parameters
MOV CX ,N ; CX=4
L1:
PUSH CX ; save first value of cx
PUSH DI
PUSH SI
MOV CX, M; cx = 3
L2:
;new_col[j] = new_col[j] + matrix[i][j]
ADD DI , SI
ADD DI ,4; move next index
ADD SI ,4
LOOP L2
POP SI ; rest j index
POP DI
POP CX
ADD SI ,4 ; move next index matrix
LOOP L1
c中的算法
for ( i = 0; i < n; i++) {
for (j = 0; j < m; i++)
new_col[j] += matrix[i][j];
}