diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 11:58:26 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 11:58:26 -0300 |
| commit | 3c9d999424520c809e05bee11d81788b488434f6 (patch) | |
| tree | 7556d9ea10bda42b226aec4dd956753467cc0864 /lopcodes.h | |
| parent | f7840a3e0bc07813246b2bad6bf4579848187908 (diff) | |
| download | lua-3c9d999424520c809e05bee11d81788b488434f6.tar.gz lua-3c9d999424520c809e05bee11d81788b488434f6.tar.bz2 lua-3c9d999424520c809e05bee11d81788b488434f6.zip | |
many details (most by lhf).
Diffstat (limited to '')
| -rw-r--r-- | lopcodes.h | 15 |
1 files changed, 9 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.41 2000/02/22 13:30:11 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.42 2000/03/02 12:32:53 roberto Exp roberto $ |
| 3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -21,9 +21,11 @@ | |||
| 21 | 2nd unsigned argument in the middle 8 bits (`B') | 21 | 2nd unsigned argument in the middle 8 bits (`B') |
| 22 | 22 | ||
| 23 | The signed argument is represented in excess 2^23; that is, the real value | 23 | The signed argument is represented in excess 2^23; that is, the real value |
| 24 | is 2^23 minus the usigned value. | 24 | is the usigned value minus 2^23. |
| 25 | ===========================================================================*/ | 25 | ===========================================================================*/ |
| 26 | 26 | ||
| 27 | #define EXCESS_S (1<<23) /* == 2^23 */ | ||
| 28 | |||
| 27 | /* | 29 | /* |
| 28 | ** the following macros help to manipulate instructions | 30 | ** the following macros help to manipulate instructions |
| 29 | */ | 31 | */ |
| @@ -35,13 +37,13 @@ | |||
| 35 | 37 | ||
| 36 | #define GET_OPCODE(i) ((OpCode)((i)&0xFF)) | 38 | #define GET_OPCODE(i) ((OpCode)((i)&0xFF)) |
| 37 | #define GETARG_U(i) ((int)((i)>>8)) | 39 | #define GETARG_U(i) ((int)((i)>>8)) |
| 38 | #define GETARG_S(i) ((int)((i)>>8)-(1<<23)) | 40 | #define GETARG_S(i) ((int)((i)>>8)-EXCESS_S) |
| 39 | #define GETARG_A(i) ((int)((i)>>16)) | 41 | #define GETARG_A(i) ((int)((i)>>16)) |
| 40 | #define GETARG_B(i) ((int)(((i)>>8) & 0xFF)) | 42 | #define GETARG_B(i) ((int)(((i)>>8) & 0xFF)) |
| 41 | 43 | ||
| 42 | #define SET_OPCODE(i,o) (((i)&0xFFFFFF00u) | (Instruction)(o)) | 44 | #define SET_OPCODE(i,o) (((i)&0xFFFFFF00u) | (Instruction)(o)) |
| 43 | #define SETARG_U(i,u) (((i)&0x000000FFu) | ((Instruction)(u)<<8)) | 45 | #define SETARG_U(i,u) (((i)&0x000000FFu) | ((Instruction)(u)<<8)) |
| 44 | #define SETARG_S(i,s) (((i)&0x000000FFu) | ((Instruction)((s)+(1<<23))<<8)) | 46 | #define SETARG_S(i,s) (((i)&0x000000FFu) | ((Instruction)((s)+EXCESS_S)<<8)) |
| 45 | #define SETARG_A(i,a) (((i)&0x0000FFFFu) | ((Instruction)(a)<<16)) | 47 | #define SETARG_A(i,a) (((i)&0x0000FFFFu) | ((Instruction)(a)<<16)) |
| 46 | #define SETARG_B(i,b) (((i)&0xFFFF00FFu) | ((Instruction)(b)<<8)) | 48 | #define SETARG_B(i,b) (((i)&0xFFFF00FFu) | ((Instruction)(b)<<8)) |
| 47 | 49 | ||
| @@ -55,8 +57,9 @@ | |||
| 55 | */ | 57 | */ |
| 56 | 58 | ||
| 57 | typedef enum { | 59 | typedef enum { |
| 58 | /* name parm before after side effect | 60 | /*---------------------------------------------------------------------- |
| 59 | -----------------------------------------------------------------------------*/ | 61 | name args stack before stack after side effects |
| 62 | ------------------------------------------------------------------------*/ | ||
| 60 | ENDCODE,/* - - (return) */ | 63 | ENDCODE,/* - - (return) */ |
| 61 | RETCODE,/* U - (return) */ | 64 | RETCODE,/* U - (return) */ |
| 62 | 65 | ||
