[Open]Launch Another .BIN File (And Pass Parameters?)


#21

could see it more as a giant switch case you go true with every byte


#22

Spoiler: all loops are actually gotos under the surface (or ‘jump’ as the machine code instruction is usually called.)

As the stdlib is available, a std::map would be more flexible, but yes, a switch would work.
Or even just an array of function pointers.


#23

std::map might be a waste for that purpose, and in this case the array of functions/methods pointers and codes starting from 0 going up to N is straightforward :slight_smile:

(Hehe talking about my favorite book again)


#24

Oh, yes, definitely! That is what I did in Ore, as well. :stuck_out_tongue:


#25

The advantage of std::map is that it would be possible to swap out individual functions with alternatives (e.g. if there was a debug version and a non-debug verison).

Granted it would be a bit of a waste of memory, but it would be easier to get up and running than a more memory efficient array of function pointers (because the order that the instructions are added/created in don’t matter) and it’s easier to maintain than a massive switch statement.

At the very least a std::map would be easiest for the prototype.
Once all the instructions have been decided, then they can be appropriately ordered and turned into an array of function pointers.

(And of course an enum class for the opcodes themselves.)


#26

Enum class, for classy people :sunglasses: