在程序集和c中指定一个指向指针的指针

时间:2014-10-14 17:12:51

标签: c assembly x86

在C方法中,给定唯一的局部变量int i(未初始化),我想存储在寄存器%ecx中,并给出位于%ebp + 8中的以下结构:

typedef struct {
  char c;
  int k;
  int *m;
} S1;

如何将以下代码转换为汇编语言(& t语法):

i=*(a.m);
i=i+a.k;

谢谢!

1 个答案:

答案 0 :(得分:0)

鉴于我是int,在masm中它将会是:

;i = *(a.m);
mov eax, [ebp+13]  ; 13 = +8+1+4
mov ecx, [eax]     ; store i in ecx

;i = i + a.k;
mov eax, ptr [ebp+9]  ; 9 = +8+1
add ecx, eax          ; new value of i
相关问题