Daily Thought - 2024-11-24
< back to listSo what about the efficiency of
using micro-instructions as undo instructions? Let's get
back to our example, the expression 1 2 +
which
translates to the instructions push 1
, push 2
, add
. We can undo the add
with pop
, push 1
, push 2
, the push 2
with a pop
, and the push 1
with
another pop
.
So pop
, push 1
, push 2
, pop
, pop
. Five micro-instructions to undo
three regular ones; pretty much the same as before. This
does not seem any more efficient. But remember, there are far fewer
micro-instructions than regular instructions. So their encoding can be more
compact. Those five wouldn't take up a lot of bytes.
Is this the best approach? I don't know. But it seems like the best bet for an initial attempt, for the implementation simplicity alone.