2 ms·
> why not just pass the second thread a pointer to the first thread's actual stack data, instead of relying on stack-relative addressing? That would probably b
by userbinator 13y ago
> why not just pass the second thread a pointer to the first thread's actual stack data, instead of relying on stack-relative addressing?
That would probably be the only way to do it in a high-level language, but otherwise there really isn't a need to, just like I didn't see a need to setup another stack. I also was not thinking in terms of threads - it was like "swap between these blocks of code", and there were more than 2 of them. Being able to think about and do things like this is why I'm using Asm in the first place - I could restrict myself to writing code using the more limiting conventions of HLLs, almost like a compiler would generate, but I feel that rather defeats the point of using Asm (why not just use a compiler?) Not to say that I don't appreciate using a thread abstraction when it's appropriate, but at this level there are no threads, no functions, no strict relationships between calls and returns, nothing other than a series of instructions.
The "fast-stack-switch" using registers is also something I remember doing before, though it wasn't on x86.