With x.inc defining the offsets of members and the size of the structure, we can now easily access and use structure of type struct X.
If obj is a local variable of the type struct X, then the following definition reserves space for it (assuming it is the only local variable):
If obj is a parameter (passed by value) or a local variable of the type struct X, then we can initialize member i to zero using the following code:
This assumes that ebp is properly initialized as the frame pointer, and obj is properly defined as the offset from where ebp points to the beginning of obj.
To computer &obj.c.score and put it in register eax, we can use the following code:
Assuming eax points to a struct X, we can initialize member i to 0 using the following code: