OK I meant the IDE's allow assembler to be used in a C program, I know it can be done I was just wondering if the code was simpler to write when dealing with memory.
Most C compilers allow you to include inline assembler, and it is a real pain. Avoid it at all costs
If you really have to, use only one or two instructions that don't need access to data. (e.g. Enabling or disabling interrupts)
Why?
First of, you have to be very familiar with the underlying instruction set and architecture of the target processor
Then you need to know the C compiler's expected assembler syntax, that might not match the vendor's native assembler (looking at you GCC for Intel).
Then you have to work out how you can pass values and addresses between C and assembler (e.g. so you can access C variables), which involves magic incantations.
Inline ASM prevents the optimizer from doing it's job, you have added a little block of magic in the middle of C code.
And you can't format your code nicely, and make it readable, because it is intermixed with C and needs to be quoted
And perhaps worst of all, adding labels so you can do jumps is just ugly. You need to force the C compiler to generate labels and use its naming schemes, rather than sensible meaningful names.
And finally your code isn't portable, so you will only ever use the result of all your blood, sweat and tears once.
See
https://locklessinc.com/articles/gcc_asm/ if interested in a brief guide.
To see how bad it really is, here is the start of some code that I wrote to drive WS2812B LEDs. I wish I had just used the SPI peripheral...
void outputWS2812Bbytes(unsigned char (*leds)[3], unsigned char length)
{
delay(1);
asm volatile(
" cli \n\t" // Disable interrupts
" mov 18,%1\n\t" // Copy length
" add %1, 18\n\t" // Add it back
" add %1, 18\n\t" // Add it back, so it is now x3 what it was
"L_next%=:" "\n\t"
// Bit 7
" SBI 5, 4 \n\t" // Set port b bit 4 Arduino pin 12
" NOP \n\t" // A pause
" LD 18, Z \n\t" // Load and post increment - two cycles
" ANDI 18, 128 \n\t" // Test the bit - one cycle
" BRNE L_bit7%= \n\t" // Skip the clear if the bit is set
" CBI 5, 4 \n\t" // clear port b bit 4
"L_bit7%=:" "\n\t"
" NOP \n\t" // A pause
" NOP \n\t" // A pause
" NOP \n\t" // A pause
" NOP \n\t" // A pause
.....
It is usually better to do the hard yards and get it to work in C