lua-users home
lua-l archive

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

> I am interested in adding some opcodes to the VM. As I want to
> increase the range of opcodes I have made following changes to
> lopcodes.h:
> #define SIZE_C 8
> #define SIZE_B 8
> #define SIZE_Bx (SIZE_C + SIZE_B)
> #define SIZE_A 8
> #define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A)
> #define SIZE_OP 8
> I can't see any negative impact - but wanted to confirm if this is okay to do?

I assume you have lopcodes.h right in front of you.

The 9th bit in B and C is used to distinguish between constants and registers,
so your machine will on all instructions that use RK() be able to access only
half of your registers. That's all of the arithmetic instructions and
quite a few
more. So you might as well reduce SIZE_A to 7 and accept that you have
a 7-bit machine with a 9-bit opcode space rather than an 8-bit machine with
a 6-bit opcode space.