4 ms·
Thanks for this. There is a really good blog post to understand coroutines from an assembly perspective here: https://blog.dziban.net/coroutines/ https://blog.
by samsquire 4y ago
Thanks for this.
There is a really good blog post to understand coroutines from an assembly perspective here:
https://blog.dziban.net/coroutines/ https://blog.dziban.net/coroutines/
I ported the intel assembly syntax in that blog post to at&t syntax and assembled it with GNU Assembler
https://github.com/samsquire/assembly https://github.com/samsquire/assembly as coroutines.S
there is also protothreads and Tina
http://dunkels.com/adam/pt/ http://dunkels.com/adam/pt/
https://github.com/slembcke/Tina https://github.com/slembcke/Tina
- anfilt 4y agoNo problem. If you have any questions feel free to ask.
- qprofyeh 4y agoMy C is a bit rusty. What do (void*)0xcafe and (void*)0xbeef in the example mean?
- anfilt 4y agoThe example just shows some of the functions for the library being used. Mainly the storing and returning of values. As for the numbers like "(void*)0xcafe" it's casting the number 0xcafe (in hex) to a void*. Why those constants they just easy to read in hex since they happen to spell a word. They could be anything, depending on your application like a pointer to data or some important constant ect...
- qprofyeh 4y agoThanks, so void* is the any type in C. And the argument is not necessarily a pointer nor should it be dereferenced. I think I understand.
- Warwolt 4y agoMore particularly, I would describe it as a "pointer to anything". The size of the value will be exactly the size used for pointers in the given system (e.g. 8 bytes). If you happen to know what a void* is pointing to, you can cast it to another type like "my_struct_t*" and deference the value. I would call it a work around for C lacking true polymorphism.
- quietbritishjim 4y agoThat is pretty much the opposite of what GP said: they're using void* to directly store an integer value rather than a pointer to anything (in that case).