【发布时间】:2015-11-27 03:31:37
【问题描述】:
我在 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
【问题讨论】:
-
您需要在
movl (%eax,%esi,4), %edx之后使用movl (%edx), %edx之类的东西取消引用%edx -
这是 AT&T x86x 语法,而不是 NASM Syntax。
-
原型中的
int **m是否意味着你真的用一个由3个指针组成的数组来表示你的3x3矩阵,这些指针指向3个整数数组?与int m[3][3]相比,这是一个巨大的空间浪费。在 asm 中,这就是必须取消引用两次或必须计算i*k + j才能在一块内存中获得正确的偏移量之间的区别。
标签: c linux assembly matrix x86