CppCon 2017: Charles Bailey “Enough x86 Assembly to Be Dangerous”

preview_player
Показать описание


This tutorial is an introduction to x86 assembly language aimed at C++ programmers of all levels who are interested in what the compiler does with their source code.

C++ is a programming language that cares about performance. As with any technology, a deep understanding of C++ is helped by knowledge of the layer below, and this means knowledge of assembly language. Knowing what the compiler does with your source code and the limitations under which it operates can inform how you design and write your C++.

We learn how to generate, inspect and interpret the assembly language for your C++ functions and programs. We take a short tour of common assembly instructions and constructs, and discover why extreme caution should be exercised if we are trying to infer performance characteristics from a simple inspection of assembly code.

Starting with a simple `operator+` for a user-defined class, we take a look at how interface and implementation choices affect the generated assembly code and observe the effect of copy elisions and related optimizations that compilers commonly perform.

Charles Bailey: Bloomberg LP, Software Engineer

Charles Bailey is a software developer at Bloomberg LP. He works in Developer Experience Engineering London, where he consults and advises on all aspects of software development. His previous experience in software development has included roles in many areas, including business intelligence, data warehousing, defence, radar and financial derivatives. In addition to C++, Charles has a keen interest in source control in general and Git in particular. He can be found answering questions on both subjects on Stack Overflow and in person.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Thank you for this talk, it really helps me to understand why a shorter code might not always be the fastest.

jeroen
Автор

No disrespect to the presenter. I know it takes a lot to give a talk. So kudos to him anyway. Plus I like the spirit of the talk - I'm always interested in more assembly and low level knowledge, even if it is legacy, old war stories or repeating the basics. That being said I'm not really sure what the purpose or the direction of this talk was!?! Was it w.r.t. code gen for performance, was it about ultimate control, was it to scare you away from assembler?

I felt the level was relatively basic / foundational and as I said that is not bad per se, I enjoy that as a refresher. But for this level I think it would have been much better to speak about x64, because it is much saner and cleaner (calling conventions). Not a lot of people are dealing with 32bit anymore anyway so why even bother to explain it if you are not dealing with in great detail. The stack visualiZation could have been so much better and clearer with color and code side by side.

Also minor nitpick: why did he keep on saying MMX? ;) I understand where he comes from (both SIMD) but MMX is what like 20 years old and worked very differently.

Long story short: I would enjoy more talks about topics like this. But the message in this talk was not clear to me.

ghostdg
Автор

There is only one reason to ever use assembly language in a project, and that is to get control over things you could not control with C or C++. Like writing a boot sector, because there you have exactly 512 bytes to work with, and some of them even already have a special meaning. Or writing synchronization functions, because you need opcodes the compiler wouldn't emit. This stuff is not even scratching the surface.

nullplan
Автор

Awesome talk. I remember the Acorn machine, I had a Risk PC and fondly remember dabbling with conditional execution in ARM, before that I was all a pout 68000 on the ATARI ST. Good times. I’ve never tried x86 but I occasionally have to grok the disassembly window in the debugger so your talk is spot on. Kudos.

tomkirbygreen
Автор

12:19 he was thinking of esp like wallhacks for a second.. extra sensory projection.

forwardvector
Автор

03:35 Why is it called "object code" anyway? I was always wondering about that. What does it have to do with objects?

bonbonpony
Автор

anyone can get that Acorn Archimedes experience today for not much quid - get a Raspberry Pi 4 or 400 and load RISC OS Direct as the OS. Then relieve the late 80s innovation - even good old BBC BASIC can be summoned with a keystroke. And its not fossilized - the OS is still being developed for and upgraded with an active community

TheSulross
Автор

I very fondly remember the Archimedes :)

MattGodbolt
Автор

You need that stuff for cracking … you know.

plus
Автор

No disrespect to the presenter. He did a good job. But at an event like CppCon in 2017, basic knowledge of x86 assembly is expected from everyone. How can such a basic talk get selected?. I was probably looking for him to tell more about neat tricks around SSE/AVX instructions as he had indicated in the beginning. Disappointed.

abhijitiitr
Автор

His jokes are not funny, it is a waste of a students time and it lowers the quality of his instructions.

billlets