Here is a teaser:
I started with BASIC in 1988 and have used higher-level languages since then. I have never gone the opposite way and worked with assembly. But your source is so insanely well-commented that I think it would make a good study guide, even though you're working close to the metal and I can tell your code is very optimized. I am actually really excited about this!
BTW, were all the remarks already in the code from 2019, or did you recently spruce it up for our benefit?
I started with Fortran, and then assembly because I built my own computer before they were commercially available. I wrote an unbeatable tic-tac-toe program that was stored on paper tape. Nobody wanted to play it because it always won, so I had to make the first move random to give the player a chance. After that I did a lot of compiled basic, but stayed mostly with assembly code. In basic I wrote a lunar lander program using the actual LEM specifications and orbital dynamics. It was tough to land successfully.
Regarding the XTB assembly code, I counted clock cycles for the critical timing loops, so yes it is optimized. And no it was not spruced up for publication. This is how all of them are commented.
This is still on my to do list. My immediate task involves swapping the battery bank for my emergency solar system. The battery warning indicator I designed a year ago started beeping a few days ago, indicating that one of the batteries in the 48V system did not match the others anymore. This time of year there are a lot of short charge/discharge cycles due to the A/C system. Watching with a meter showed one of the gel cells had significantly higher resistance than the others. I installed them back in September 2021, so they have gone through over 1300 complete charge/discharge cycles.
I went lead acid back then because lithium was way more expensive. But now they are almost the same price. The problem is my charge controller doesn't directly support lithium batteries, but can be programmed to do so. I didn't have the necessary cable or program, and that controller is no longer sold. I ordered a cable for one that looks similar, and I hope the program for that one will also work with the old controller. I should find out in a couple of days.
Jeff