Comparing C to Assembly

preview_player
Показать описание
In this video I compare a few simple C programs to their assembly counter parts.

Compiler explorer is a great way study how C compilers produce assembly, check it out below.

00:00 intro
00:10 Variable
02:55 Pointer
05:10 Array
07:10 While loop
09:19 For loop
Рекомендации по теме
Комментарии
Автор

for increment in assembly we have "INC" instruction which also works with memory pointers, like: inc dword [rsp+04h]

PianoElipse
Автор

Amazing video, thank you! Ive never had a good experience trying to learn ASM, but this was a great overview.

bradt
Автор

I've always wondered, in e.g. MOV you use square brackets if you want to basically dereference a pointer (e.g. EBP-1 being an address) but in LEA the address is specified in [brackets] even though we're not dereferencing anything, and just use the address itself - all I could find after researching it online is that "it's just how it is" in some stackoverflow post and 15 people telling eachother they're wrong

kipchickensout
Автор

why doesnt it add 1 instead of doing the variable change when i+=?

pablo.v.roldan
Автор

I also would like to see how code would look like when we using an optimization (like /O2, /O3, /O1).

PianoElipse
Автор

Could it do it the other way. Like you write ASM and it turns it into C counterpart?

rejisha
Автор

Very uneffective and slow assembly code.

maximsl