Programming with Ophis | ||
---|---|---|
<<< Previous | Functionals | Next >>> |
We've been talking about all these routines as if they could be copy-pasted or hand-compiled from C++ or Java code. This isn't really the case, primarily because "local variables" in your average assembler routines aren't really local, so multiple calls to the same method will tend to trash the program state. And since a lot of the machinery described here shares a lot of memory (in particular, every single method invocation everywhere shares a this), attempting to shift over standard OO code into this format is likely to fail miserably.
You can get an awful lot of flexibility out of even just one layer of method-calls, though, given a thoughtful design. The do'jump'table routine, or one very like it, was extremely common in NES games in the mid-1980s and later, usually as the beginning of the frame-update loop.
If you find you really need multiple layers of method calls, though, then you really are going to need a full-on program stack, and that's going to be several kinds of mess. That's the topic for the final chapter.
<<< Previous | Home | Next >>> |
VTables and Object-Oriented Assembler | Up | Call Stacks |