Hello Denis,
I read your post about wanting to use other environments to program the Teensy, and it resonated with a little of my experience while returning to the world of microcontrollers again after 30 years. I hope you don't mind the discussion/intrusion.
I don't have your background (well, I have to admit to a little Basic, C and Pascal!), so this may be a little off-course based on your question/request; however, like you, I wanted to do assembly on these contemporary chips. When I realised the structured overlay of modern chips, the complexity in hardware and the (often) RISC approach to the code base, I realised that the learning curve would be so steep as to become a long-winded end in itself, let alone make the machines "do anything".
It was a hard pill to swallow!! I resisted for a short time. Then, I saw the true value of the modern (free!!) tools after simply accepting that I needed to work at the next layer. The modern embedded compilers are amazing, and while I can't compete with your analysis of GCC optimisation, these are crazy fast gizmos, regardless. The Teensy (4.1) hammers!
In the early days with the Z80 and 8051, I used the C environment as a basic structure and would smarten up interrupts or some basic I/O with a dash of assembler. These days, with the PIC32 and the STM32, I realise there is little point in that approach anymore. Now, with the Teensy, it's even more of a contrast to the older Z80/8051 style chips. Since I dispensed with my yearning for low-level bare metal, most programs are easier to follow and debug - and it has been transformational, for me at least.
I have to admit that I hesitated with Teensy for about a year, with work and such taking much of my hobby time away. I also saw that the main programming environment for Teensy is "Arduino", which initially griped a bit. Historically, I have had a few irritations with the Arduino enclave in that it tended (purposely) to significantly abstract elements of the programming environment, the processor and I/O etc. before I was happy that I understood the underlying detail.
I wanted to have the programming reference on one hand and write some register addressing peripheral config on the other (old school).
Sometimes, the details matter, and I feel I cannot easily see them in the Arduino environment. However, the STM32 series with the Eclipse IDE with HAL layers (for better or worse) enabled me to track down all the (untidy!!) interrupt call-back functions, discover the ideas behind them, and model the processor and each peripheral both visually and in code. Arduino is not that.
Otherwise, Arduino gets you going superbly quickly, which is excellent as a starter - "following the bouncing ball". As a temporary minus, the last time I looked, I could not work out how to build a suitably modular program using it. With the
later versions of Arduino IDE, it becomes a non-sequitur. These days I can bake in C++ or bare-bones C with the rest of the supplied libraries and have the modules linked as required. It's great!
Regarding optimisation, I sense there is a definite balance between hard optimisation and simply being able to produce stable, workable code. With the Teensy 600MHz clock, optimised instruction pipelines, close-coupled caches and modern processor design, the burden of code level optimisation pretty much evaporates - unless that's actually your hobby - to find the most efficient code. In which case, you're right; you will have to see how structures are coded and called at that level.
I hope you don't mind the intrusion, Denis. I hope you don't mind me relating here - your thoughts triggered a few little ideas that I hope it's OK to share. For my own concerns, these modern environments are unimaginably powerful compared with 30 years ago. Happy to hear your thoughts.
Kind Regards,
Steve