flat assembler
Message board for the users of flat assembler.
Index
> Main > [64-bit] Push and dword directive problems? |
Author |
|
revolution 28 Sep 2016, 13:39
In 64-bit code there is no dword push encoding. Try with "push qword 0xf" instead, or don't put any size prefix and let fasm figure out the size.
|
|||
28 Sep 2016, 13:39 |
|
JohnFound 28 Sep 2016, 13:42
And also use the
Code: [code][/code] Code: jack@JACK-PC MINGW64 ~/tst $ cat asm.asm use32 pushd 0fh push dword 0fh use64 pushd 0fh push dword 0fh |
|||
28 Sep 2016, 13:42 |
|
jiangfasm 28 Sep 2016, 14:12
JohnFound wrote: And also use the I corrected the |
|||
28 Sep 2016, 14:12 |
|
jiangfasm 28 Sep 2016, 14:16
revolution wrote: In 64-bit code there is no dword push encoding. Try with "push qword 0xf" instead, or don't put any size prefix and let fasm figure out the size. Sounds strange! Imm32 is 32bit, but to use the QWORD instead of DWORD, I misunderstood bug. |
|||
28 Sep 2016, 14:16 |
|
revolution 28 Sep 2016, 14:32
The constant is encoded as as 32-bit signed value that expands to 64-bit when executed. For example you cannot encode 0x80000000 as an immediate value because it will get expanded to 0xffffffff80000000 when pushed.
push 0xFFFFFFFF80000000 <--- okay push 0x0000000080000000 <--- not encodable |
|||
28 Sep 2016, 14:32 |
|
jiangfasm 29 Sep 2016, 00:29
revolution wrote: The constant is encoded as as 32-bit signed value that expands to 64-bit when executed. For example you cannot encode 0x80000000 as an immediate value because it will get expanded to 0xffffffff80000000 when pushed. Looks awkward, but thank you! I learn from you! |
|||
29 Sep 2016, 00:29 |
|
CandyMan 29 Sep 2016, 15:46
In 64-bit code there is no dword push encoding but you can use double "push word"
Code: use64 push word 1234h ;\ push dword 12345678h push word 5678h ;/ _________________ smaller is better |
|||
29 Sep 2016, 15:46 |
|
revolution 29 Sep 2016, 16:02
CandyMan wrote: In 64-bit code there is no dword push encoding but you can use double "push word" IIRC (sorry too lazy to find it right now) but I expect a subsequent push will crash your program because of the unaligned RSP. The RSP alignment requirements will bite you. |
|||
29 Sep 2016, 16:02 |
|
CandyMan 29 Sep 2016, 16:20
you are right
Code: push [Value] ; how to push not encodable immediate values ... Value dq 0x00000000_80000000 _________________ smaller is better |
|||
29 Sep 2016, 16:20 |
|
jiangfasm 01 Oct 2016, 12:48
CandyMan wrote: you are right
|
|||||||||||||||||||
01 Oct 2016, 12:48 |
|
revolution 01 Oct 2016, 12:52
jiangfasm: What are you trying to say/ask?
|
|||
01 Oct 2016, 12:52 |
|
jiangfasm 03 Oct 2016, 06:43
revolution wrote: jiangfasm: What are you trying to say/ask? ( fasm ) I think dword directive is modified imm32, now I see is modified, the operand size. Through communication with you to determine this is not a bug in fasm, but also how the fasm works |
|||
03 Oct 2016, 06:43 |
|
revolution 03 Oct 2016, 07:36
jiangfasm: I think firstly we should establish that 'dword' is a size override, not a directive. There is a difference there so I am not just pointing this out to be pedenatic, just to be sure we are talking about the same thing.
So, when you put a 'dword' size override then fasm will try to encode an instruction that results in a dword value that is pushed to the stack. But in 64-bit mode there is no such instruction that exists to do that, so you get an error. This is not a bug, it is intended behaviour. Putting 'dword' does not indicate the instruction encoding detail (i.e. it does not mean "use a dword encoding"), but instead it indicates the destination size (i.e. it means push a dword to the stack). |
|||
03 Oct 2016, 07:36 |
|
jiangfasm 03 Oct 2016, 14:50
revolution wrote: jiangfasm: I think firstly we should establish that 'dword' is a size override, not a directive. There is a difference there so I am not just pointing this out to be pedenatic, just to be sure we are talking about the same thing. "it is intended behaviour." Thank you, there would be many don't understand, to ask you, I learn from you! |
|||
03 Oct 2016, 14:50 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.