referencing C structure elements in assembly

This is a discussion on referencing C structure elements in assembly within the C Programming forums, part of the General Programming Boards category; I have an array of structure defined in C language. And I want to copy one of system register onto ...

The problem is that there is no equivalent of
> mov [memorylocation], AX
for segment registers. You can only move segment registers to/from general registers. Just do someting like
> mov AX, DS
> mov [memorylocation], AX
instead.

state[state_ptr].stack_segment requires some calculation to find the address of the variable: you want it to address byte state + state_ptr*sizeof(state) + offsetoff(stack_segment). I think this is illegal in inline asm.