ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

lua 5.3 字节码指令手册

2021-12-11 21:35:52  阅读:280  来源: 互联网

标签:5.3 字节 into register value jump lua operator bits


原文

寄存器

Instruction Notation

R(A)
Register A (specified in instruction field A)
R(B)
Register B (specified in instruction field B)
R(C)
Register C (specified in instruction field C)
PC
Program Counter
Kst(n)
Element n in the constant list
Upvalue[n]
Name of upvalue with index n
Gbl[sym]
Global variable indexed by symbol sym
RK(B)
Register B or a constant index
RK(C)
Register C or a constant index
sBx
Signed displacement (in field sBx) for all kinds of jumps

Instruction Summary

Lua bytecode instructions are 32-bits in size. All instructions have an opcode in the first 6 bits. Instructions can have the following fields:

'A' : 8 bits
'B' : 9 bits
'C' : 9 bits
'Ax' : 26 bits ('A', 'B', and 'C' together)
'Bx' : 18 bits ('B' and 'C' together)
'sBx' : signed Bx

A signed argument is represented in excess K; that is, the number value is the unsigned value minus K. K is exactly the maximum value for that argument (so that -max is represented by 0, and +max is represented by 2*max), which is half the maximum for the corresponding unsigned argument.

操作码

Opcode Description
MOVE Copy a value between registers
LOADK Load a constant into a register
LOADKX Load a constant into a register
LOADBOOL Load a boolean into a register
LOADNIL Load nil values into a range of registers
GETUPVAL Read an upvalue into a register
GETTABUP Read a value from table in up-value into a register
GETTABLE Read a table element into a register
SETTABUP Write a register value into table in up-value
SETUPVAL Write a register value into an upvalue
SETTABLE Write a register value into a table element
NEWTABLE Create a new table
SELF Prepare an object method for calling
ADD Addition operator
SUB Subtraction operator
MUL Multiplication operator
MOD Modulus (remainder) operator
POW Exponentation operator
DIV Division operator
IDIV Integer division operator
BAND Bit-wise AND operator
BOR Bit-wise OR operator
BXOR Bit-wise Exclusive OR operator
SHL Shift bits left
SHR Shift bits right
UNM Unary minus
BNOT Bit-wise NOT operator
NOT Logical NOT operator
LEN Length operator
CONCAT Concatenate a range of registers
JMP Unconditional jump
EQ Equality test, with conditional jump
LT Less than test, with conditional jump
LE Less than or equal to test, with conditional jump
TEST Boolean test, with conditional jump
TESTSET Boolean test, with conditional jump and assignment
CALL Call a closure
TAILCALL Perform a tail call
RETURN Return from function call
FORLOOP Iterate a numeric for loop
FORPREP Initialization for a numeric for loop
TFORLOOP Iterate a generic for loop
TFORCALL Initialization for a generic for loop
SETLIST Set a range of array elements for a table
CLOSURE Create a closure of a function prototype
VARARG Assign vararg function arguments to registers

标签:5.3,字节,into,register,value,jump,lua,operator,bits
来源: https://www.cnblogs.com/jiftle/p/15677183.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有