Wednesday, November 27, 2019

Coroutine68k - Stackful coroutines for Bare Metal 68k Applications in C++

Recently I've read through the enhancements the C++ fans get with C++20.
I was especially interested in the concept of coroutines as it is an approach for asynchronous programming and an alternative to state machines. The latter always have the problem that they are unstructured and it sometimes is difficult to "see" the flow of the states. On the other hand a synchronous algorithm as a structured program might be easier to understand.

The GCC is still not ready for C++20 so stackless coroutines are currently only possible using the mechanism used by Protothreads. But stackful coroutines on the other hand just need some context switching which can be implemented inside a library.

As I'm currently on a 68k trip I wondered how easy it would be to create a similar thing for that processor. Last weekend I've made a small case study and published it as a small open project on github. Enjoy.