lua-users home
lua-l archive

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


On Sat, Jun 6, 2020 at 9:09 AM Baozeng <sploving1@gmail.com> wrote:
Hi all, 

As we know, Lua instruction format is the opcode with 6 bits,  `A` with 8 bits, `B` and `C` with 9 bits (together 32 bits)

I custom opcode with 8 bits, `A` with 8 bits,  `B` and `C` with 8 bits.  and use the lua test-suite (https://www.lua.org/tests/) to test it and It have passed all the test.    I want to know does it  affect user's program? 
I only know that with 8 bits for `B` and `C`, the max jump offset is shorter than before. will it affect the normal user? Thank you.

Lua 5.4 (currently in release candidate stage) has changed the format. Now for instructions in ABC format, the opcode is the lowest 7 bits (increased from 6 to accommodate new opcodes), 8 bits for A, 1 bit for "k" (used as a boolean in some compare/test instructions), 8 bits for B, and the highest 8 bits for C. You can view the layout at the top of lopcodes.h in the Lua 5.4 source. Note that I'm looking at 5.4rc1, and we're now up to 5.4rc4, but I don't think there's been any changes.

If you reorder that so that the "k" is bit 7, between the opcode and A, then the new ABC format neatly divides into 8-8-8-8 like yours. The only rub, if you truly want to separate the bytes so that each byte serves one purpose, is that you lose one bit from the larger arguments (Bx, sBx, Ax, and sJ) in the other instruction formats.