From e0c0e2ee14f519ad33429533f87519753f07051a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 18 Sep 2017 13:07:54 -0300 Subject: [PATCH] comments (documentation about instruction formats) --- lopcodes.h | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lopcodes.h b/lopcodes.h index 7f17de1c..3d69196c 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.157 2017/09/13 19:50:08 roberto Exp roberto $ +** $Id: lopcodes.h,v 1.158 2017/09/15 14:19:06 roberto Exp roberto $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -11,21 +11,20 @@ /*=========================================================================== - We assume that instructions are unsigned numbers. + We assume that instructions are unsigned 32-bit integers. 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 + Instructions can have the following formats: - 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. + 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +iABC | C(9) | | B(9) | | A(8) | | Op(6) | +iABx | Bx(18) | | A(8) | | Op(6) | +iAsBx | sBx (signed)(18) | | A(8) | | Op(6) | +iAx | Ax(26) | | Op(6) | + + A signed argument is represented in excess K: the represented value is + the written unsigned value minus K, where K is half the maximum for the + corresponding unsigned argument. ===========================================================================*/