在 2024-01-19 16:19, Fangrui Song 写道: > It is also unfortunate that whether the displacement is an immediate > or not change the behavior of brackets. > > mov eax, DWORD PTR 0 # mov $0x0,%eax > mov eax, DWORD PTR [0] # mov 0x0,%eax > mov eax, DWORD PTR sym # mov 0x0,%eax with relocation > mov eax, DWORD PTR [sym] # mov 0x0,%eax with relocation > > The above reveals yet another inconsistency. For a memory reference, > it seems that we should use [] but [sym] could be ambiguous if sym > matches a register name or operator name. This is sort of tautology, as `DWORD PTR` and `[]` means the same thing. It's unfortunate that neither could replace the other; not to mention the `DWORD BCST` thing in AVX512. That is to say, these two mov eax, DWORD PTR 0 mov eax, DWORD PTR [0] should denote the same operation. This is more useful with a segment override, to access thread-local data, as in mov rax, QWORD PTR 0 # 48 8B0425 00000000 mov rax, QWORD PTR gs:0 # 65 48 8B0425 00000000 > Does the proposal change the placement of the displacement depending > on whether it is an immediate? > This is inconsistent, but perhaps there is not much we can improve... The proposal is about elimination of ambiguity. Roughly speaking, an identifier that follows `PTR`, `BCST` or `OFFSET` is to be interpreted as a symbol, and an identifier that appears with in a pair of brackets is to be interpreted as a register. As a numeric displacement does not cause ambiguity, it can be accepted either way. -- Best regards, LIU Hao