由于以下主题, 使用 MASM 在 win32 汇编编程中初始化结构
我试图纠正我的错误,所以我尝试了以下代码:
.386
.model flat,stdcall
option casemap:none
struct1 struct
first db ?
second dd ?
third db ?
struct1 EndS
.data
Initializedstructure struct1 <4,10>
.code
start:
mov eax, struct1.first
mov ebx , struct1.second
mov ecx , struct1.third
;offsets
mov eax , offset struct1.first
mov ebx , offset struct1.second
mov ecx , offset struct1.third
end start
但是在反汇编代码上没有发现任何东西。我添加了每个结构体成员的偏移量以区分两者之间的差异。
.text:00401000 start:
.text:00401000 mov eax, 0
.text:00401005 mov ebx, 1
.text:0040100A mov ecx, 5
.text:0040100F mov eax, 0
.text:00401014 mov ebx, 1
.text:00401019 mov ecx, 5
我在网上冲浪,但没有找到任何描述结构体使用的文档,所以我决定自己尝试一下。反汇编的代码似乎包含每个结构成员的大小。
主要问题是如何在代码中使用结构体的成员?