lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> > There is this quote in that section, I know that. But what do you want
> > to know?  (What is the meaning of "is ... what?" ?)
> >
> I think this is not a difference between stack-based and register-based but
> vm implementations: "goto and branch instructions use a two-byte
> displacement"
> So, my doubt is correct? And is there better example for the second factor?
> This is my second question.

The difference is not directly related to stack-based, but it is related
in an indirect way. One of the advantages of stack-based implementations
is that opcodes are small (typically one byte), because most operands
are implicit (top of the stack). However, several instructions still
need explicit operands (e.g., goto, branch, call), and typically these
operands need more than one byte.

On the other hand, because register-based instructions need explicit
operands for most (all?) operations, it makes sense to use a longer
instruction format (Lua uses 32-bit instructions). With these longer
instructions, fetching explicit operands is cheaper.

-- Roberto