Is there a tool some where that lets you paste in a simple C/C++ code snippet and have it spit out the appropriate optimised assembly code?
I did assembler years ago with the 8086 processor.
And I'd rather learn assembler with Arduino/ESP32 via reverse engineering with a tool.
asm volatile(
"headB:"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n2] , %[lo]"
"\n\t"
"out %[port] , %[n1]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 6"
"\n\t"
"mov %[n2] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"rjmp .+0"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n1] , %[lo]"
"\n\t"
"out %[port] , %[n2]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 5"
"\n\t"
"mov %[n1] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"rjmp .+0"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n2] , %[lo]"
"\n\t"
"out %[port] , %[n1]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 4"
"\n\t"
"mov %[n2] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"rjmp .+0"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n1] , %[lo]"
"\n\t"
"out %[port] , %[n2]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 3"
"\n\t"
"mov %[n1] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"rjmp .+0"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n2] , %[lo]"
"\n\t"
"out %[port] , %[n1]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 2"
"\n\t"
"mov %[n2] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"rjmp .+0"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n1] , %[lo]"
"\n\t"
"out %[port] , %[n2]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 1"
"\n\t"
"mov %[n1] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"rjmp .+0"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n2] , %[lo]"
"\n\t"
"out %[port] , %[n1]"
"\n\t"
"rjmp .+0"
"\n\t"
"sbrc %[byte] , 0"
"\n\t"
"mov %[n2] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"sbiw %[count], 1"
"\n\t"
"out %[port] , %[hi]"
"\n\t"
"mov %[n1] , %[lo]"
"\n\t"
"out %[port] , %[n2]"
"\n\t"
"ld %[byte] , %a[ptr]+"
"\n\t"
"sbrc %[byte] , 7"
"\n\t"
"mov %[n1] , %[hi]"
"\n\t"
"out %[port] , %[lo]"
"\n\t"
"brne headB"
"\n"
: [byte] "+r"(b), [n1] "+r"(n1), [n2] "+r"(n2), [count] "+w"(i)
: [port] "I"(_SFR_IO_ADDR(PORTB)), [ptr] "e"(ptr), [hi] "r"(hi),
[lo] "r"(lo));