Trying to pass a structure to registry via stack; linux, x64
There's a function which accepts a struct and its length as its arguments. I'm trying to pass a struct to it via registers, without using "struc", but manually:
push3; 3rd field of a struct
push2; 2nd field of a struct
push1; 1st field of a struct
movrdi, rsp; load a struct ---(dw, dw, dw) --- into rdi
movrsi, 6; its size dw + dw + dw = 6
The app isn't working as expected. Is there a mistrake in the way of how I'm passing a struct via stack?
Joined: 16 Jun 2003
Location: Kraków, Poland
In AMD64 mode there is no 16 bit push.
The original AMD64 architecture had 16-bit PUSH in long mode (as a side effect of the prefix-opcode symmetries) and it was a documented behavior*. Later, when Intel adopted the same architecture, it removed these atypical encoding variants (I don't blame them).
You can still get fasm to generate the 16-bit variants in long mode with the PUSHW mnemonic. That said, I would not recommend even trying this route. Probably only the earliest CPUs implementing x86-64 architecture really supported this.
* I just opened the original x86-64 manuals to look for this just to make sure that I have no false memory of it. I'm attaching the excerpt I found - the PUSH instruction is listed earlier in the table, but the note below the table is what I wanted to show. This may be one of the first time I opened these paper manuals in ages, the last time I was really reading them was back in 2004 when working on x86-64 support for fasm.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum