Opis OPCodes Kompilatora AMXX

Opis OPCodes używanych przez maszynę wirtualną AMXX’a i kompilator.

Przydatne dla ludzi którzy dekompilują pluginy.

*** HEX VALUES:
 - OP_NONE  = 0x00
 - OP_LOAD_PRI  = 0x01
 - OP_LOAD_ALT  = 0x02
 - OP_LOAD_S_PRI  = 0x03
 - OP_LOAD_S_ALT  = 0x04
 - OP_LREF_PRI  = 0x05
 - OP_LREF_ALT  = 0x06
 - OP_LREF_S_PRI  = 0x07
 - OP_LREF_S_ALT  = 0x08
 - OP_LOAD_I  = 0x09
 - OP_LODB_I  = 0x0a
 - OP_CONST_PRI  = 0x0b
 - OP_CONST_ALT  = 0x0c
 - OP_ADDR_PRI  = 0x0d
 - OP_ADDR_ALT  = 0x0e
 - OP_STOR_PRI  = 0x0f
 - OP_STOR_ALT  = 0x10
 - OP_STOR_S_PRI  = 0x11
 - OP_STOR_S_ALT  = 0x12
 - OP_SREF_PRI  = 0x13
 - OP_SREF_ALT  = 0x14
 - OP_SREF_S_PRI  = 0x15
 - OP_SREF_S_ALT  = 0x16
 - OP_STOR_I  = 0x17
 - OP_STRB_I  = 0x18
 - OP_LIDX  = 0x19
 - OP_LIDX_B  = 0x1a
 - OP_IDXADDR  = 0x1b
 - OP_IDXADDR_B  = 0x1c
 - OP_ALIGN_PRI  = 0x1d
 - OP_ALIGN_ALT  = 0x1e
 - OP_LCTRL  = 0x1f
 - OP_SCTRL  = 0x20
 - OP_MOVE_PRI  = 0x21
 - OP_MOVE_ALT  = 0x22
 - OP_XCHG  = 0x23
 - OP_PUSH_PRI  = 0x24
 - OP_PUSH_ALT  = 0x25
 - OP_PUSH_R  = 0x26
 - OP_PUSH_C  = 0x27
 - OP_PUSH  = 0x28
 - OP_PUSH_S  = 0x29
 - OP_POP_PRI  = 0x2a
 - OP_POP_ALT  = 0x2b
 - OP_STACK  = 0x2c
 - OP_HEAP  = 0x2d
 - OP_PROC  = 0x2e
 - OP_RET  = 0x2f
 - OP_RETN  = 0x30
 - OP_CALL  = 0x31
 - OP_CALL_PRI  = 0x32
 - OP_JUMP  = 0x33
 - OP_JREL  = 0x34
 - OP_JZER  = 0x35
 - OP_JNZ  = 0x36
 - OP_JEQ  = 0x37
 - OP_JNEQ  = 0x38

 - OP_JLESS  = 0x39
 - OP_JLEQ  = 0x3a
 - OP_JGRTR  = 0x3b
 - OP_JGEQ  = 0x3c
 - OP_JSLESS  = 0x3d
 - OP_JSLEQ  = 0x3e
 - OP_JSGRTR  = 0x3f
 - OP_JSGEQ  = 0x40
 - OP_SHL  = 0x41
 - OP_SHR  = 0x42
 - OP_SSHR  = 0x43
 - OP_SHL_C_PRI  = 0x44
 - OP_SHL_C_ALT  = 0x45
 - OP_SHR_C_PRI  = 0x46
 - OP_SHR_C_ALT  = 0x47
 - OP_SMUL  = 0x48
 - OP_SDIV  = 0x49
 - OP_SDIV_ALT  = 0x4a
 - OP_UMUL  = 0x4b
 - OP_UDIV  = 0x4c
 - OP_UDIV_ALT  = 0x4d
 - OP_ADD  = 0x4e
 - OP_SUB  = 0x4f
 - OP_SUB_ALT  = 0x50
 - OP_AND  = 0x51
 - OP_OR  = 0x52
 - OP_XOR  = 0x53
 - OP_NOT  = 0x54
 - OP_NEG  = 0x55
 - OP_INVERT  = 0x56
 - OP_ADD_C  = 0x57
 - OP_SMUL_C  = 0x58
 - OP_ZERO_PRI  = 0x59
 - OP_ZERO_ALT  = 0x5a
 - OP_ZERO  = 0x5b
 - OP_ZERO_S  = 0x5c
 - OP_SIGN_PRI  = 0x5d
 - OP_SIGN_ALT  = 0x5e
 - OP_EQ  = 0x5f
 - OP_NEQ  = 0x60
 - OP_LESS  = 0x61
 - OP_LEQ  = 0x62
 - OP_GRTR  = 0x63
 - OP_GEQ  = 0x64
 - OP_SLESS  = 0x65
 - OP_SLEQ  = 0x66
 - OP_SGRTR  = 0x67
 - OP_SGEQ  = 0x68
 - OP_EQ_C_PRI  = 0x69
 - OP_EQ_C_ALT  = 0x6a
 - OP_INC_PRI  = 0x6b
 - OP_INC_ALT  = 0x6c
 - OP_INC  = 0x6d
 - OP_INC_S  = 0x6e
 - OP_INC_I  = 0x6f
 - OP_DEC_PRI  = 0x70
 - OP_DEC_ALT  = 0x71
 - OP_DEC  = 0x72
 - OP_DEC_S  = 0x73
 - OP_DEC_I  = 0x74
 - OP_MOVS  = 0x75
 - OP_CMPS  = 0x76
 - OP_FILL  = 0x77
 - OP_HALT  = 0x78
 - OP_BOUNDS  = 0x79
 - OP_SYSREQ_PRI  = 0x7a
 - OP_SYSREQ_C  = 0x7b
 - OP_FILE  = 0x7c
 - OP_LINE  = 0x7d
 - OP_SYMBOL  = 0x7e
 - OP_SRANGE  = 0x7f
 - OP_JUMP_PRI  = 0x80
 - OP_SWITCH  = 0x81
 - OP_CASETBL  = 0x82
 - OP_SWAP_PRI  = 0x83
 - OP_SWAP_ALT  = 0x84
 - OP_PUSHADDR  = 0x85
 - OP_NOP  = 0x86
 - OP_SYSREQ_D  = 0x87
 - OP_SYMTAG  = 0x88
 - OP_BREAK  = 0x89
 - OP_FLOAT_MUL  = 0x8a
 - OP_FLOAT_DIV  = 0x8b
 - OP_FLOAT_ADD  = 0x8c
 - OP_FLOAT_SUB  = 0x8d
 - OP_FLOAT_TO  = 0x8e
 - OP_FLOAT_ROUND  = 0x8f
 - OP_FLOAT_CMP  = 0x90

*** OPCode INFO:
0, NONE, , invalid  - OPcode
1, LOAD.pri, address, PRI   =  [address]
2, LOAD.alt, address, ALT   =  [address]
3, LOAD.S.pri, offset, PRI   =  [FRM + offset]
4, LOAD.S.alt, offset, ALT   =  [FRM + offset]
5, LREF.pri, address, PRI   =  [ [address] ]
6, LREF.alt, address, ALT   =  [ [address] ]
7, LREF.S.pri, offset, PRI   =  [ [FRM + offset] ]
8, LREF.S.alt, offset, ALT   =  [ [FRM + offset] ]
9, LOAD.I, , PRI   =  [PRI] (full cell)
10, LODB.I, number, PRI   =  "number" bytes from [PRI] (read 1/2/4 bytes)
11, CONST.pri, value, PRI   =  value
12, CONST.alt, value, ALT   =  value
13, ADDR.pri, offset, PRI   =  FRM + offset
14, ADDR.alt, offset, ALT   =  FRM + offset
15, STOR.pri, address, [address]   =  PRI
16, STOR.alt, address, [address]   =  ALT
17, STOR.S.pri, offset, [FRM + offset]   =  PRI
18, STOR.S.alt, offset, [FRM + offset]   =  ALT
19, SREF.pri, address, [ [address] ]   =  PRI
20, SREF.alt, address, [ [address] ]   =  ALT
21, SREF.S.pri, offset, [ [FRM + offset] ]   =  PRI
22, SREF.S.alt, offset, [ [FRM + offset] ]   =  ALT
23, STOR.I, , [ALT]   =  PRI (full cell)
24, STRB.I, number, "number" bytes at [ALT]   =  PRI (write 1/2/4 bytes)
25, LIDX, , PRI   =  [ ALT + (PRI * cell size) ]
26, LIDX.B, shift, PRI   =  [ ALT + (PRI << shift) ]
27, IDXADDR, , PRI   =  ALT + (PRI * cell size) (calculate indexed address)
28, IDXADDR.B, shift, PRI   =  ALT + (PRI << shift) (calculate indexed address)
29, ALIGN.pri, number, Little Endian: PRI ^   =  cell size
30, ALIGN.alt, number, Little Endian: ALT ^   =  cell size
31, LCTRL, index, PRI is set to the current value of any of the special registers. The index parameter must be: 0  = COD, 1  = DAT, 2  = HEA,3  = STP, 4  = STK, 5  = FRM, 6  = CIP (of the next instruction)
32, SCTRL, index, set the indexed special registers to the value in PRI. The index parameter must be: 2  = HEA, 4  = STK, 5  = FRM, 6  = CIP
33, MOVE.pri, , PRI  = ALT
34, MOVE.alt, , ALT  = PRI
35, XCHG, , Exchange PRI and ALT
36, PUSH.pri, , [STK]   =  PRI, STK   =  STK 
37, PUSH.alt, , [STK]   =  ALT, STK   =  STK 
38, PUSH.R, value, Repeat value: [STK]   =  PRI, STK   =  STK 
39, PUSH.C, value, [STK]   =  value, STK   =  STK 
40, PUSH, address, [STK]   =  [address], STK   =  STK 
41, PUSH.S, offset, [STK]   =  [FRM + offset], STK   =  STK 
42, POP.pri, , STK   =  STK + cell size, PRI   =  [STK]
43, POP.alt, , STK   =  STK + cell size, ALT   =  [STK]
44, STACK, value, ALT   =  STK, STK   =  STK + value
45, HEAP, value, ALT   =  HEA, HEA   =  HEA + value
46, PROC, , [STK]   =  FRM, STK   =  STK 
47, RET, , STK   =  STK + cell size, FRM   =  [STK], STK   =  STK + cell size, CIP   =  [STK], The RET instruction cleans up the stack frame and returns from the function to the instruction after the call.
48, RETN, , STK   =  STK + cell size, FRM   =  [STK], STK   =  STK + cell size, CIP   =  [STK], STK   =  STK + [STK] The RETN instruction removes a specifed number of bytes from the stack. The value to adjust STK with must be pushed prior to the call.
49, CALL, address, [STK]   =  CIP + 5, STK   =  STK The CALL instruction jumps to an address after storing the address of the next sequential instruction on the stack.
50, CALL.pri, , [STK]   =  CIP + 1, STK   =  STK 
51, JUMP, address, CIP   =  address (jump to the address)
52, JREL, offset, CIP   =  CIP + offset (jump offset bytes from currentposition)
53, JZER, address, if PRI   =   =  0 then CIP   =  [CIP + 1]
54, JNZ, address, if PRI !  =  0 then CIP   =  [CIP + 1]
55, JEQ, address, if PRI   =   =  ALT then CIP   =  [CIP + 1]
56, JNEQ, address, if PRI !  =  ALT then CIP   =  [CIP + 1]
57, JLESS, address, if PRI < ALT then CIP   =  [CIP + 1] (unsigned)
58, JLEQ, address, if PRI <   =  ALT then CIP   =  [CIP + 1] (unsigned)
59, JGRTR, address, if PRI > ALT then CIP   =  [CIP + 1] (unsigned)
60, JGEQ, address, if PRI >   =  ALT then CIP   =  [CIP + 1] (unsigned)
61, JSLESS, address, if PRI < ALT then CIP   =  [CIP + 1] (signed)
62, JSLEQ, address, if PRI <   =  ALT then CIP   =  [CIP + 1] (signed)
63, JSGRTR, address, if PRI > ALT then CIP   =  [CIP + 1] (signed)
64, JSGEQ, address, if PRI >   =  ALT then CIP   =  [CIP + 1] (signed)
65, SHL, , PRI   =  PRI << ALT
66, SHR, , PRI   =  PRI >> ALT (without sign extension)
67, SSHR, , PRI   =  PRI >> ALT with sign extension
68, SHL.C.pri, value, PRI   =  PRI << value
69, SHL.C.alt, value, ALT   =  ALT << value
70, SHR.C.pri, value, PRI   =  PRI >> value (without sign extension)
71, SHR.C.alt, value, ALT   =  ALT >> value (without sign extension)
72, SMUL, , PRI   =  PRI * ALT (signed multiply)
73, SDIV, , PRI   =  PRI / ALT (signed divide), ALT   =  PRI mod ALT
74, SDIV.alt, , PRI   =  ALT / PRI (signed divide), ALT   =  ALT mod PRI
75, UMUL, , PRI   =  PRI * ALT (unsigned multiply)
76, UDIV, , PRI   =  PRI / ALT (unsigned divide), ALT   =  PRI mod ALT
77, UDIV.alt, , PRI   =  ALT / PRI (unsigned divide), ALT   =  ALT mod PRI
78, ADD, , PRI   =  PRI + ALT
79, SUB, , PRI   =  PRI - ALT
80, SUB.alt, , PRI   =  ALT - PRI
81, AND, , PRI   =  PRI & ALT
82, OR, , PRI   =  PRI | ALT
83, XOR, , PRI   =  PRI ^ ALT
84, NOT, , PRI   =  !PRI
85, NEG, , PRI   =  PRI   =  --PRI
86, INVERT, , PRI   =  ~ PRI
87, ADD.C, value, PRI   =  PRI + value
88, SMUL.C, value, PRI   =  PRI * value
89, ZERO.pri, , PRI   =  0
90, ZERO.alt, , ALT   =  0
91, ZERO, address, [address]   =  0
92, ZERO.S, offset, [FRM + offset]   =  0
93, SIGN.pri, , sign extent the byte in PRI to a cell
94, SIGN.alt, , sign extent the byte in ALT to a cell
95, EQ, , PRI   =  PRI   =   =  ALT ? 1 : 0
96, NEQ, , PRI   =  PRI !  =  ALT ? 1 : 0
97, LESS, , PRI   =  PRI < ALT ? 1 : 0 (unsigned)
98, LEQ, , PRI   =  PRI <   =  ALT ? 1 : 0 (unsigned)
99, GRTR, , PRI   =  PRI > ALT ? 1 : 0 (unsigned)
100, GEQ, , PRI   =  PRI >   =  ALT ? 1 : 0 (unsigned)
101, SLESS, , PRI   =  PRI < ALT ? 1 : 0 (signed)
102, SLEQ, , PRI   =  PRI <   =  ALT ? 1 : 0 (signed)
103, SGRTR, , PRI   =  PRI > ALT ? 1 : 0 (signed)
104, SGEQ, , PRI   =  PRI >   =  ALT ? 1 : 0 (signed)
105, EQ.C.pri, value, PRI   =  PRI   =   =  value ? 1 : 0
106, EQ.C.alt, value, PRI   =  ALT   =   =  value ? 1 : 0
107, INC.pri, , PRI   =  PRI + 1
108, INC.alt, , ALT   =  ALT + 1
109, INC, address, [address]   =  [address] + 1
110, INC.S, offset, [FRM + offset]   =  [FRM + offset] + 1
111, INC.I, , [PRI]   =  [PRI] + 1
112, DEC.pri, , PRI   =  PRI - 1
113, DEC.alt, , PRI   =  PRI - 1
114, DEC, address, [address]   =  [address]  - 1
115, DEC.S, offset, [FRM + offset]   =  [FRM + offset]  - 1
116, DEC.I, , [PRI]   =  [PRI] - 1
117, MOVS, number, Copy memory from [PRI] to [ALT]. The parameter specifes the number of bytes. The blocks should not overlap.
118, CMPS, number, Compare memory blocks at [PRI] and [ALT]. The parameter specifes the number of bytes. The blocks should not overlap.
119, FILL, number, Fill memory at [ALT] with value in [PRI]. The parameter specifes the number of bytes, which must be a multiple of the cell size.
120, HALT, 0, Abort execution (exit value in PRI), parameters other than 0 have a special meaning.
121, BOUNDS, value, Abort execution if PRI > value or if PRI < 0
122, SYSREQ.pri, , call system service, service number in PRI
123, SYSREQ.C, value, call system service
124, FILE, size ord name..., source file information pair: name and ordinal (see below)
125, LINE, line ord, source line number and file ordinal (see below)
126, SYMBOL, sze off flg name..., symbol information (see below)
127, SRANGE, lvl size, symbol range and dimensions (see below)
128, JUMP.pri, , CIP   =  PRI (indirect jump)
129, SWITCH, address, Compare PRI to the values in the case table (whose address is passed) and jump to the associated address.
130, CASETBL, ... , casetbl num default num*[case jump]
131, SWAP.pri, , [STK]   =  PRI and PRI   =  [STK]
132, SWAP.alt, , [STK]   =  ALT and ALT   =  [STK]
133, PUSHADDR, offset, [STK]   =  FRM + offset, STK   =  STK 
134, NOP, , no-operation, for code alignment
135, SYSREQ.D, address, call system service directly (by address)
136, SYMTAG, value, symbol tag
137, BREAK, , invokes  optional debugger

Dodaj komentarz