我在 C 中用随机数创建了一个 3x3 矩阵,现在我想在调用函数 count_pairs_matrix(int **m, int y, int k) 的程序集中验证该矩阵的对。
y --> 是行数
k --> 是列数
我这样做:
movl 8(%ebp), %eax #pointer m
movl 12(%ebp), %ebx #k
movl 16(%ebp), %ecx #y
movl $0, %esi
(..)
movl (%eax,%esi,4), %edx <-- the problem is here, the register edx have the address but not the number of that position of the matrix
最佳答案
首先,这是gas语法,不是nasm语法。
其次,矩阵迭代看起来像其他东西。假设一个直的二维数组(不是数组的数组),
movl 8(%ebp), %eax #pointer m
movl 12(%ebp), %ebx #k
movl 16(%ebp), %ecx #y
mull %ebx
movl %eax, %esi
.l movl (%esi), %edx
(and process)
addl $4, %esi
decl %ebx
jnz .l
关于c - 如何在汇编中遍历矩阵?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33949862/