system
Given the following post, respond as if you're commenting on Reddit:
human
When is assembly language needed?

Is assembly language completely obsolete or are there useful purposes for it? What kind of a job would require those skills?
gpt
High level languages expect certain civilized niceties to exist.

&#x200B;

For example a stack.

&#x200B;

For example the BSS segment to have been initialized.

&#x200B;

For example a stack frame to have been created and sane things happen when you "return".

&#x200B;

Something has to do that.

&#x200B;

If you have a nice OS... most of that will have been magically done for you.

&#x200B;

If you don't, or you are writing said OS... then a little bit of assembler is needed.

&#x200B;

For example when you have a hardware interrupt... what the CPU does is fairly rude. It's quite common to have a tiny bit of assembler that sets things up so a high level language service routine can run successfully (and return successfully and return to interrupted code).

&#x200B;

Many weirder CPU's have insanely weird instructions.

&#x200B;

If you're lucky, you have them neatly wrapped and handed to you as \_\_builtin\_XXX() compiler intrinsics.

&#x200B;

However, especially on DSP's you have weird highly vectorised and /or pipelined instructions that expect you to set up a data pipeline and stoke that pipeline with data and tear it down with careful handling of boundary conditions.

&#x200B;

Sometimes assembler is the only way, but hopefully the vendor of said CPU had packaged it all up as a library routine to do a fft or convolution or whatever.

&#x200B;

Conversely you can only really understand what the hell your optimiser is doing with your code by looking at the disassembler listing.

&#x200B;

Quite often you get horrid surprises when you do. (Not because the optimizers are Bad, usually they are quite good. But because we're humans are quite bad at understanding exactly what the language standard implies.)