C / C ++ translation to assembly, low memory behavior: how is this done?

I participate in a game programming school, and here we need to learn about code speed, which seems important.

Is there any tutorial or list of things you need to know about when programming in C / C ++?

It is interesting about many things, for example, why the default behavior of C occurs by transferring data rather than a link / address, or how the compiler translates an assembly link or how a C loop translates to JMP.

This bothers me because python uses a different way, but on the other hand, python does not use an operator to copy the value, but rather a function that can be syntactically heavy.

I really don’t think that knowing how to program in an assembly is really necessary, because it is painful, I think it just needs to know about the register, etc.

+6
c ++ c assembly memory-management memory
source share
1 answer

See your switch compiler documentation for the output of the asm step, not the machine code. Every compiler I worked with has it. Use it to send simple code to asm and learn it.

VS also has the ability to "view the assembly" while passing the code.

There will be no clear answer to your question. It all depends on the compiler and architecture. Even to the arguments provided to the compiler.

Edit:

The fact that there is no clear answer to your question will not make people think. One example is stupid things, such as passing a large object (for example, a string: p) by reference instead of returning by value. These things will seem reasonable to the new C ++ developer. OF COURSE, passing a string to a function to fill out is faster than creating a copy and returning it from this function only to copy it again at the destination. The fact is that this does not work; it is very dependent on the compiler, but you can stomp all over your compiler to optimize it, trying to get all smart.

There are TONS of misinformation on how to quickly make your code. Take it all with salt. Most people who claim to know how to make fast code are full of crap. The only reasonable answer to fast code is your code profile. When the time comes for micro-optimization, you will do a bunch of things that are very specific to your target platform. General knowledge, "it's faster", in this case you will not come in handy.

+6
source share

All Articles