@Radon
2014-10-23T09:33:14.000000Z
字数 1306
阅读 1729
1100012749
int var_prod_ele(int n, int A[n][n], int B[n][n], int i, int k) {
void *Arow = (void *)&A[i][0];
void *Bcol = (void *)&B[0][k];
int j;
int result = 0;
int NN = 4*n;
for (j = 0; j < NN; j+=4){
result += *((int *)(Arow+j)) * *((int *)Bcol);
Bcol += NN;
}
return result;
}
$ gcc -O2 -S ics3.61.c -m32
.L4:
movl (%ebx), %ecx
addl %esi, %ebx #esi->NN, ebx->Bcol
imull (%edi,%edx), %ecx #ecx=(*Bcol) * *(Arow+j), edi->Arow
addl $4, %edx #edx->j
addl %ecx, %eax #eax->result
cmpl %edx, %esi
jg .L4
A. 13
B. i: %edi; j: %ecx
C.
void transpose(int M, int A[M][M]){
int i, j, *A1, t;
for (i = 0; i < M; i++){
A1 = &A[0][i];
A_ = A[i];
for (j = 0; j < i;){
t = A_[j];
A_[j] = *A1;
j++;
*A1 = t;
A1 += M;
}
}
}
A.
8(%ebp)存放返回值的地址
12(%ebp)存放s1.a
16(%ebp)存放s1.p
B.
%ebp-> | |
---|---|
s2.diff | |
s2.sum | |
s1.p | |
s1.a | |
%esp-> | &s2 |
C.
将结构的每一个成员逆序压入栈中
D.
预先从低到高地址分配结构各个成员的空间,在栈中retaddr+4的位置提供一个指向结构的指针作为返回地址
A.
e1.p: 0
e1.y: 4
e2.x: 0
e2.next: 4
B. 8个
C. up->next->y = *(up->next->p) - up->x;
#include <stdio.h>
#define MAX_INPUT 10
int good_echo()
{
char s[MAX_INPUT];
char *ret;
do{
ret = fgets(s, MAX_INPUT, stdin);
if(ret == NULL){
if(feof(stdin)) return 0;
else return 1;
}
fputs(s, stdout);
} while(true);
}
int main()
{
return good_echo();
}
#define MIN_VAL -9223372036854775807-1
long traverse(tree_ptr tp)
{
if (!tp)
return MIN_VAL; //movabsq??
long v = tp->val;
long vLeft = traverse(tp->left);
long vRight = traverse(tp->right);
if (vLeft >= vRight) vRight = vLeft;
if (vRight < v) vRight = v;
return vRight;
}