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

Поділитися
Вставка
  • Опубліковано 5 чер 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017
    -
    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.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

КОМЕНТАРІ • 33

  • @jeroen3648
    @jeroen3648 2 роки тому +7

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

    • @CppCon
      @CppCon  2 роки тому

      Glad it was helpful!

  • @ghostd0g
    @ghostd0g 6 років тому +52

    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.

    • @supercombinecp860
      @supercombinecp860 6 років тому +2

      I thought it was a decent talk. Hasn't dry humor always been the spice of assembly?

    • @figfox2425
      @figfox2425 5 років тому +3

      MMX is still used to optimise code, it's not outdated even if it's obviously not used to calculate 3d matrix as it was its initial purpose.

    • @elbozo5723
      @elbozo5723 Рік тому +1

      I totally agree, one of the major pitfalls of trying to learn assembly nowadays is everyone teaches x86 despite the fact that it’s basically deprecated.
      but then again, this is assembly we’re talking about. no sane person uses assembly unless theyre optimizing some really low level code or they’re messing around for fun.

  • @nullplan01
    @nullplan01 5 років тому +13

    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.

    • @X606
      @X606 4 роки тому +11

      The other big reason is when you want to modify compiled code you don't have the source code to

    • @JacksonBenete
      @JacksonBenete 3 роки тому

      Do you have a book to recommend or some hints to find what more is beneath the surface?
      I've started learning Assembly multiple times before, but this is the first time I'm finishing a book and really understanding the material, I'm interested to dive in.

    • @dmitryhetman1509
      @dmitryhetman1509 Рік тому

      and of course for speed, asm good at speed

    • @billlets5460
      @billlets5460 Рік тому +1

      One reason? Nonsense. A person might want to develop an OS, or a New language--all kinds of stuff.

  • @tomkirbygreen
    @tomkirbygreen 6 років тому +3

    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.

    • @TheSulross
      @TheSulross 2 роки тому +1

      you should indulge some nostalgia - get a Raspberry Pi 4 or the 400 and load RISC OS Direct as the OS - then enjoy the good old days - it's all there including BBC BASIC

  • @forwardvector
    @forwardvector Рік тому +2

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

  • @bonbonpony
    @bonbonpony 6 років тому +6

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

    • @oefzdegoeggl
      @oefzdegoeggl 5 років тому +8

      he is talking about compiled code / machine language, sometimes called "object code" as it is stored in "object files". has nothing to do with c++ objects in the sense of OOP in that context.

    • @TheSulross
      @TheSulross 2 роки тому +2

      it's a terminology that predates object-oriented programming languages and doesn't have anything to do with that context of meaning

    • @ericcurtin412
      @ericcurtin412 2 роки тому +2

      An object in C (sometimes called a translation unit, compiles to an object file) is a compiled .c file and it's included headers with normally one file specific header. I think in many C codebases every .c file is roughly what you'd likely consider to encapsulate in a object in an object-oriented programming language. So object file is somewhat related to an object in OO concept. Because normally every cpp file contains one definition of an object (a class). At the end of the day in C, you can create a similar structure to a class in C++ by using a struct and writing a load of functions with a pointer to that struct.

  • @Sopel997
    @Sopel997 6 років тому +3

    Comparing O0 assembly output

  • @theshopenable
    @theshopenable 6 років тому +20

    I don’t feel dangerous :(

  • @MattGodbolt
    @MattGodbolt 6 років тому +7

    I very fondly remember the Archimedes :)

  • @sad_yorick
    @sad_yorick 6 років тому +5

    Visual bug in the beginning. Mild.

  • @TheSulross
    @TheSulross 2 роки тому +2

    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

  • @17plus9
    @17plus9 6 років тому +10

    You need that stuff for cracking … you know.

  • @abhijitiitr
    @abhijitiitr 6 років тому +22

    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.

    • @llothar68
      @llothar68 6 років тому +18

      I'm not sure if the audience of CppCon is having basic knowledge, and very sure the cppcon youtube viewers have not. I agree that the direction of this talk was not clear but at least there was 30min of ASM talk at CppCon 2017

    • @abhijitiitr
      @abhijitiitr 6 років тому +4

      I probably had different expectations after looking at the title of the video. My bad.

    • @richwalter5322
      @richwalter5322 4 роки тому +7

      You're right, everyone C/C++ programmer should have basic x86 assembly language experience... if it were up to me, every programmer in general.

    • @ericcurtin412
      @ericcurtin412 2 роки тому +2

      Wouldn't you create a barrier to entry for C/C++ newbies then at cppcon? I think these talks should be aimed at all levels of developers, not just experts.

    • @Aurora12488
      @Aurora12488 2 роки тому +3

      Please read the abstract. If you thought this was going to be about "neat tricks around SSE/AVX instructions', that's entirely on you for not reading the description. The abstract says this is an introduction and for all levels, and as it was accepted clearly the convention staff agree it's appropriate.

  • @billlets5460
    @billlets5460 Рік тому

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