The intention here is (probably!) to calculate the size of the foo
structure.
In 'bare' assembly (without any fancy tricks like structures), the only way to do this without manually counting is to determine difference between the addresses of the first and last byte of the structure, plus one. Or, in this case, the difference between the address of the first byte of the structure and the address of the first byte past the structure.
In C, you have the sizeof
operator, which determines (at compile time) the size of an instance of a type. This captures the intention much better. In your case, you'd say
struct foo f;
// ...
f.d = sizeof(struct foo);
or alternatively,
struct foo f;
// ...
f.d = sizeof(f);