XlogicX Blog

Assembly_Is_Too_High-Level_-_Fences

I like to find any opportunity that I can to write completely valid machine code that would not be produced by an assembler. When it comes down to it, that's mostly the theme of what I'm trying to capture in this series of "Assembly Is Too High-Level" posts. This post is no exception. Let's talk about fences:

lfence sfence mfence

Keep that machine code in mind while we write these instructions in assembly and view it in the debugger:

 

Nothing shocking so far; this is completely what we expect to see. What I find more interesting than all of this completely normal stuff is the below output:

 

This isn't entirely unexpected though; this is mentioned in the manual for each of the fences:

Even though this stuff isn't all too unusual, it still stands that given this knowledge, you can write completely valid machine code that assemblers will not write.