# lopcodes.h File Reference

`#include "llimits.h"`

Go to the source code of this file.

## Defines
#define | SIZE_C 9
#define | SIZE_B 9
#define | SIZE_Bx (SIZE_C + SIZE_B)
#define | SIZE_A 8
#define | SIZE_OP 6
#define | POS_OP 0
#define | POS_A (POS_OP + SIZE_OP)
#define | POS_C (POS_A + SIZE_A)
#define | POS_B (POS_C + SIZE_C)
#define | POS_Bx POS_C
#define | MAXARG_Bx MAX_INT
#define | MAXARG_sBx MAX_INT
#define | MAXARG_A ((1<<SIZE_A)-1)
#define | MAXARG_B ((1<<SIZE_B)-1)
#define | MAXARG_C ((1<<SIZE_C)-1)
#define | MASK1(n, p) ((~((~(Instruction)0)<<n))<<p)
#define | MASK0(n, p) (~MASK1(n,p))
#define | GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
#define | SET_OPCODE(i, o)
#define | GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
#define | SETARG_A(i, u)
#define | GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
#define | SETARG_B(i, b)
#define | GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
#define | SETARG_C(i, b)
#define | GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
#define | SETARG_Bx(i, b)
#define | GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
#define | SETARG_sBx(i, b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
#define | CREATE_ABC(o, a, b, c)
#define | CREATE_ABx(o, a, bc)
#define | BITRK (1 << (SIZE_B - 1))
#define | ISK(x) ((x) & BITRK)
#define | INDEXK(r) ((int)(r) & ~BITRK)
#define | MAXINDEXRK (BITRK - 1)
#define | RKASK(x) ((x) | BITRK)
#define | NO_REG MAXARG_A
#define | NUM_OPCODES (cast(int, OP_VARARG) + 1)
#define | getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
#define | getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
#define | getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
#define | testAMode(m) (luaP_opmodes[m] & (1 << 6))
#define | testTMode(m) (luaP_opmodes[m] & (1 << 7))
#define | LFIELDS_PER_FLUSH 50
## Enumerations
enum | OpMode { iABC, iABx, iAsBx }
enum | OpCode { OP_MOVE, OP_LOADK, OP_LOADBOOL, OP_LOADNIL, OP_GETUPVAL, OP_GETGLOBAL, OP_GETTABLE, OP_SETGLOBAL, OP_SETUPVAL, OP_SETTABLE, OP_NEWTABLE, OP_SELF, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_POW, OP_UNM, OP_NOT, OP_LEN, OP_CONCAT, OP_JMP, OP_EQ, OP_LT, OP_LE, OP_TEST, OP_TESTSET, OP_CALL, OP_TAILCALL, OP_RETURN, OP_FORLOOP, OP_FORPREP, OP_TFORLOOP, OP_SETLIST, OP_CLOSE, OP_CLOSURE, OP_VARARG }
enum | OpArgMask { OpArgN, OpArgU, OpArgR, OpArgK }
## Variables
LUAI_DATA const lu_byte | luaP_opmodes [NUM_OPCODES]
LUAI_DATA const char *const | luaP_opnames [NUM_OPCODES+1]

## Define Documentation

#define BITRK (1 << (SIZE_B - 1))

#define CREATE_ABC | ( | o,
|  | a,
|  | b,
|  | c |  | ) |

Value:

    ((cast(Instruction, o)<<POS_OP) \
                            | (cast(Instruction, a)<<POS_A) \
                            | (cast(Instruction, b)<<POS_B) \
                            | (cast(Instruction, c)<<POS_C))

#define CREATE_ABx | ( | o,
|  | a,
|  | bc |  | ) |

Value:

    ((cast(Instruction, o)<<POS_OP) \
                            | (cast(Instruction, a)<<POS_A) \
                            | (cast(Instruction, bc)<<POS_Bx))

#define GET_OPCODE | ( | i |  | ) | (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))

#define GETARG_A | ( | i |  | ) | (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))

#define GETARG_B | ( | i |  | ) | (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))

#define GETARG_Bx | ( | i |  | ) | (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))

#define GETARG_C | ( | i |  | ) | (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))

#define GETARG_sBx | ( | i |  | ) | (GETARG_Bx(i)-MAXARG_sBx)

#define getBMode | ( | m |  | ) | (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))

#define getCMode | ( | m |  | ) | (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))

#define getOpMode | ( | m |  | ) | (cast(enum OpMode, luaP_opmodes[m] & 3))

#define INDEXK | ( | r |  | ) | ((int)(r) & ~BITRK)

#define ISK | ( | x |  | ) | ((x) & BITRK)

#define LFIELDS_PER_FLUSH 50

#define MASK0 | ( | n,
|  | p |  | ) | (~MASK1(n,p))

#define MASK1 | ( | n,
|  | p |  | ) | ((~((~(Instruction)0)<<n))<<p)

#define MAXARG_A ((1<<SIZE_A)-1)

#define MAXARG_B ((1<<SIZE_B)-1)

#define MAXARG_Bx MAX_INT

#define MAXARG_C ((1<<SIZE_C)-1)

#define MAXARG_sBx MAX_INT

#define MAXINDEXRK (BITRK - 1)

#define NO_REG MAXARG_A

#define NUM_OPCODES (cast(int, OP_VARARG) + 1)

#define POS_A (POS_OP + SIZE_OP)

#define POS_B (POS_C + SIZE_C)

#define POS_Bx POS_C

#define POS_C (POS_A + SIZE_A)

#define POS_OP 0

#define RKASK | ( | x |  | ) | ((x) | BITRK)

#define SET_OPCODE | ( | i,
|  | o |  | ) |

Value:

    ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
                    ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))

#define SETARG_A | ( | i,
|  | u |  | ) |

Value:

    ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
                    ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))

#define SETARG_B | ( | i,
|  | b |  | ) |

Value:

    ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
                    ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))

#define SETARG_Bx | ( | i,
|  | b |  | ) |

Value:

    ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
                    ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))

#define SETARG_C | ( | i,
|  | b |  | ) |

Value:

    ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
                    ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))

#define SETARG_sBx | ( | i,
|  | b |  | ) | SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))

#define SIZE_A 8

#define SIZE_B 9

#define SIZE_Bx (SIZE_C + SIZE_B)

#define SIZE_C 9

#define SIZE_OP 6

#define testAMode | ( | m |  | ) | (luaP_opmodes[m] & (1 << 6))

#define testTMode | ( | m |  | ) | (luaP_opmodes[m] & (1 << 7))

## Enumeration Type Documentation

enum OpArgMask

Enumerator:

  OpArgN |
  OpArgU |
  OpArgR |
  OpArgK |

enum OpCode

Enumerator:

  OP_MOVE |
  OP_LOADK |
  OP_LOADBOOL |
  OP_LOADNIL |
  OP_GETUPVAL |
  OP_GETGLOBAL |
  OP_GETTABLE |
  OP_SETGLOBAL |
  OP_SETUPVAL |
  OP_SETTABLE |
  OP_NEWTABLE |
  OP_SELF |
  OP_ADD |
  OP_SUB |
  OP_MUL |
  OP_DIV |
  OP_MOD |
  OP_POW |
  OP_UNM |
  OP_NOT |
  OP_LEN |
  OP_CONCAT |
  OP_JMP |
  OP_EQ |
  OP_LT |
  OP_LE |
  OP_TEST |
  OP_TESTSET |
  OP_CALL |
  OP_TAILCALL |
  OP_RETURN |
  OP_FORLOOP |
  OP_FORPREP |
  OP_TFORLOOP |
  OP_SETLIST |
  OP_CLOSE |
  OP_CLOSURE |
  OP_VARARG |

enum OpMode

Enumerator:

  iABC |
  iABx |
  iAsBx |

## Variable Documentation

LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]

LUAI_DATA const char* const luaP_opnames[NUM_OPCODES+1]