Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No. This is misleading:

    fs movs byte [edi], [esi]
This is a syntax error:

    movs byte [fs:edi], [esi]
And this is a valid override with sensible syntax:

    movs byte [edi], [fs:esi]


How would you disassemble that instruction with more than one segment prefix in front of it? The hardware accepts this by ignoring all but the final segment prefix. For example, the prefixes might be: FS, REP, GS, FS, FS

Note that code can jump past some of the prefixes. The C library on Linux does this to bypass prefixes. Reasonable assembly syntax needs to be able to describe this. You need to be able to put a label right after a prefix.


Ideally, like this:

    fs rep gs fs ; Note: extraneous prefix
    mov eax, [fs:ebx]
Some of disassemblers may put them as raw bytes (db 0x63, 0xf3, 0x65, 0x64).

> Note that code can jump past some of the prefixes. The C library on Linux does this to bypass prefixes

What's the use case for this?

I wouldn't split the prefix from the instruction and would rather use label+1 where it's absolutely required.


An example is bypassing a LOCK prefix when there is only 1 thread or only 1 CPU.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: