flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > Size operator handling inconsistency. |
Author |
|
cod3b453 09 May 2012, 19:28
It's worth noting that these are 64bit extensions to the the instruction set and so are a little different from the transition between 16 and 32 bit. Effectively most things that were 32 bit were replaced by 64bit operations but with the restriction that immediates were still limited to 32bit and sign extended -- the exception is mov r64,imm64. [The reason for this was to allow the same 32bit code assembled in 64bit to exhibit the same behavior].
The size operators then allow you choose the encoding that is available which can be useful if you want to change the value without changing the size of the assembled code -- usually useful for instruction alignment or debugging. |
|||
09 May 2012, 19:28 |
|
Tomasz Grysztar 09 May 2012, 19:38
First of all: the size operator in fasm always reflects the size of the data the operation is to be performed on, and not the size of any field in the code of instruction. This is because fasm's instruction syntax is primarily focused on operation of instruction and not on the encoding. I had a disagreement with vid over this, you may find some interesting discussions on the board.
Now, the side-effect of size operator for PUSH's immediate operand is the case of same special handling as the size operator for immediate for other basic operations like AND, XOR, OR, etc. - it enforces encoding the immediate value as full-size. For example "or ax,1" and "or ax,word 1" differ in that the first one gets optimized, while the latter will have the longer form where the immediate is 16-bit. It was introduced to aid in working with self-modifying code, something like: Code: or ax,word 1 label immediate at $-2 The extended NOP instruction syntax is another thing missing from documentation - thank you for pointing that out, I will try to remember to add it in a spare time. Yes, NOP is probably the only exception to the rule that you have to specify operand size when there is possible ambiguity in the size of the memory operand - I felt that there is no need for such rigidity since, as you pointed out, not real memory access is made. |
|||
09 May 2012, 19:38 |
|
Tomasz Grysztar 09 May 2012, 19:45
OK, I found out that I did not forget to document it, in fact it has a whole dedicated section in manual.
No wonder I forgot about it, it is just as old as this manual is. Perhaps it might even not be a bad idea to refresh it a little. |
|||
09 May 2012, 19:45 |
|
l_inc 09 May 2012, 20:29
Tomasz Grysztar
Quote: I found out that I did not forget to document it, in fact it has a whole dedicated section in manual Oh. I'm sorry. My bad. So the suffix just enforces the operand size, and the size operator enforces the operand size plus full-size encoding for this operand size. The idea about the inconsistency came from the fact, that in 64 bit mode I should write push qword to achieve full size encoding, but in reality I cannot place a value from the quadword composite range after the operator (however it's also not a value from the double word composite range). Thank you for pointing me out to the documentation. Btw. I wanted to ask for a long time, but always forgot. What's the reasoning of allowing the weird notation push eax+1? |
|||
09 May 2012, 20:29 |
|
Tomasz Grysztar 09 May 2012, 20:52
l_inc wrote: What's the reasoning of allowing the weird notation push eax+1? TASM allowed to write "push eax(+1)", but not "push eax+1" as in the latter case the "eax+1" would be treated as one expression. fasm would need "push +eax+1" to get such interpretation. |
|||
09 May 2012, 20:52 |
|
l_inc 09 May 2012, 21:08
Tomasz Grysztar
OK. I could guess this one by myself too. Thanks again. |
|||
09 May 2012, 21:08 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.