I have this struct defined
struct outer {
int *x;
struct {
short s[2];
int i;
} inner;
struct outer *next;
};
Along with this function to initialize the struct
void init_outer(struct outer *ss) {
ss->inner.s[1] = ss->inner.s[0];
ss->x = &(ss->inner.i);
ss->next = ss;
ss->inner.i = 18;
}
I need to translate init_outer to assembly.
init_outer:
movw 8(%rdi), %ax
movw %ax, 10(%rdi)
leaq 12(%rdi), %rax
movq %rax, (%rdi)
movq %rdi, 16(%rdi)
// assembly code for ss->inner.i = 18 GOES HERE;
retq
I've managed to translate the first 3 lines to assemply, however I'm not sure about the last one.
I thought that the last line would be movl 18, 12(%rdi)
in assembly, but it's wrong for some reason. Is there something I'm missing?