结构指针

来源:互联网 发布:宁海知豆电动汽车招聘 编辑:程序博客网 时间:2024/05/16 15:42
I kinda like to use a little pattern for structures. I use ecx for the struct pointer, eax for the data, and if need be (ie, for a 2nd struct) I keep edx in reserve.

So the proc might go like so:

Code:

Function proc structaddr:DWORD
mov ecx, structaddr

mov eax, FirstElementVal
mov [ecx].STRUCTURE.member, eax

add ecx, SIZEOF DWORD

mov eax, SecondElementVal
mov [ecx].STRUCTURE.member, eax

; and so on
ret
Function endp