much love
[mu.git] / subx_opcodes
blob19fa1dbd9f6ceb25404203d0a72cc2dd3cb43bac
1 Opcodes currently supported by SubX:
2   01: add r32 to rm32 (add)
3   03: add rm32 to r32 (add)
4   05: add imm32 to EAX (add)
5   09: rm32 = bitwise OR of r32 with rm32 (or)
6   0b: r32 = bitwise OR of r32 with rm32 (or)
7   0d: EAX = bitwise OR of imm32 with EAX (or)
8   21: rm32 = bitwise AND of r32 with rm32 (and)
9   23: r32 = bitwise AND of r32 with rm32 (and)
10   25: EAX = bitwise AND of imm32 with EAX (and)
11   29: subtract r32 from rm32 (sub)
12   2b: subtract rm32 from r32 (sub)
13   2d: subtract imm32 from EAX (sub)
14   31: rm32 = bitwise XOR of r32 with rm32 (xor)
15   33: r32 = bitwise XOR of r32 with rm32 (xor)
16   35: EAX = bitwise XOR of imm32 with EAX (xor)
17   39: compare: set SF if rm32 < r32 (cmp)
18   3b: compare: set SF if r32 < rm32 (cmp)
19   3d: compare: set SF if EAX < imm32 (cmp)
20   40: increment EAX (inc)
21   41: increment ECX (inc)
22   42: increment EDX (inc)
23   43: increment EBX (inc)
24   44: increment ESP (inc)
25   45: increment EBP (inc)
26   46: increment ESI (inc)
27   47: increment EDI (inc)
28   48: decrement EAX (dec)
29   49: decrement ECX (dec)
30   4a: decrement EDX (dec)
31   4b: decrement EBX (dec)
32   4c: decrement ESP (dec)
33   4d: decrement EBP (dec)
34   4e: decrement ESI (dec)
35   4f: decrement EDI (dec)
36   50: push EAX to stack (push)
37   51: push ECX to stack (push)
38   52: push EDX to stack (push)
39   53: push EBX to stack (push)
40   54: push ESP to stack (push)
41   55: push EBP to stack (push)
42   56: push ESI to stack (push)
43   57: push EDI to stack (push)
44   58: pop top of stack to EAX (pop)
45   59: pop top of stack to ECX (pop)
46   5a: pop top of stack to EDX (pop)
47   5b: pop top of stack to EBX (pop)
48   5c: pop top of stack to ESP (pop)
49   5d: pop top of stack to EBP (pop)
50   5e: pop top of stack to ESI (pop)
51   5f: pop top of stack to EDI (pop)
52   68: push imm32 to stack (push)
53   69: multiply rm32 by imm32 and store result in r32 (imul)
54   70: jump disp8 bytes away if OF is set (jcc/jo)
55   71: jump disp8 bytes away if OF is unset (jcc/jno)
56   72: jump disp8 bytes away if lesser (addr, float), if CF is set (jcc/jb/jnae)
57   73: jump disp8 bytes away if greater or equal (addr, float), if CF is unset (jcc/jae/jnb)
58   74: jump disp8 bytes away if equal, if ZF is set (jcc/jz/je)
59   75: jump disp8 bytes away if not equal, if ZF is not set (jcc/jnz/jne)
60   76: jump disp8 bytes away if lesser or equal (addr, float), if ZF is set or CF is set (jcc/jbe/jna)
61   77: jump disp8 bytes away if greater (addr, float), if ZF is unset and CF is unset (jcc/ja/jnbe)
62   7c: jump disp8 bytes away if lesser, if SF != OF (jcc/jl/jnge)
63   7d: jump disp8 bytes away if greater or equal, if SF == OF (jcc/jge/jnl)
64   7e: jump disp8 bytes away if lesser or equal, if ZF is set or SF != OF (jcc/jle/jng)
65   7f: jump disp8 bytes away if greater, if ZF is unset and SF == OF (jcc/jg/jnle)
66   81: combine rm32 with imm32 based on subop (add/sub/and/or/xor/cmp)
67   87: swap the contents of r32 and rm32 (xchg)
68   88: copy r8 to r8/m8-at-r32
69   89: copy r32 to rm32 (mov)
70   8a: copy r8/m8-at-r32 to r8
71   8b: copy rm32 to r32 (mov)
72   8d: copy address in rm32 into r32 (lea)
73   8f: pop top of stack to rm32 (pop)
74   99: sign-extend EAX into EDX (cdq)
75   b8: copy imm32 to EAX (mov)
76   b9: copy imm32 to ECX (mov)
77   ba: copy imm32 to EDX (mov)
78   bb: copy imm32 to EBX (mov)
79   bc: copy imm32 to ESP (mov)
80   bd: copy imm32 to EBP (mov)
81   be: copy imm32 to ESI (mov)
82   bf: copy imm32 to EDI (mov)
83   c1: shift rm32 by imm8 bits depending on subop (sal/sar/shl/shr)
84   c3: return from most recent unfinished call (ret)
85   c6: copy imm8 to r8/m8-at-r32 with subop 0 (mov)
86   c7: copy imm32 to rm32 with subop 0 (mov)
87   cd: software interrupt (int)
88   d3: shift rm32 by CL bits depending on subop (sal/sar/shl/shr)
89   e8: call disp32 (call)
90   e9: jump disp32 bytes away (jmp)
91   eb: jump disp8 bytes away (jmp)
92   f4: halt (hlt)
93   f7: negate/multiply/divide rm32 (with EAX and EDX if necessary) depending on subop (neg/mul/idiv)
94   ff: increment/decrement/jump/push/call rm32 based on subop (inc/dec/jmp/push/call)
95   0f 2f: compare: set CF if x32 < xm32 (comiss)
96   0f 80: jump disp32 bytes away if OF is set (jcc/jo)
97   0f 81: jump disp32 bytes away if OF is unset (jcc/jno)
98   0f 82: jump disp32 bytes away if lesser (addr, float), if CF is set (jcc/jb/jnae)
99   0f 83: jump disp32 bytes away if greater or equal (addr, float), if CF is unset (jcc/jae/jnb)
100   0f 84: jump disp32 bytes away if equal, if ZF is set (jcc/jz/je)
101   0f 85: jump disp32 bytes away if not equal, if ZF is not set (jcc/jnz/jne)
102   0f 86: jump disp32 bytes away if lesser or equal (addr, float), if ZF is set or CF is set (jcc/jbe/jna)
103   0f 87: jump disp32 bytes away if greater (addr, float), if ZF is unset and CF is unset (jcc/ja/jnbe)
104   0f 8c: jump disp32 bytes away if lesser, if SF != OF (jcc/jl/jnge)
105   0f 8d: jump disp32 bytes away if greater or equal, if SF == OF (jcc/jge/jnl)
106   0f 8e: jump disp32 bytes away if lesser or equal, if ZF is set or SF != OF (jcc/jle/jng)
107   0f 8f: jump disp32 bytes away if greater, if ZF is unset and SF == OF (jcc/jg/jnle)
108   0f 92: set r8/m8-at-rm32 to 1 if lesser (addr, float), if CF is set, 0 otherwise (setcc/setb/setnae)
109   0f 93: set r8/m8-at-rm32 to 1 if greater or equal (addr, float), if CF is unset, 0 otherwise (setcc/setae/setnb)
110   0f 94: set r8/m8-at-rm32 to 1 if equal, if ZF is set, 0 otherwise (setcc/setz/sete)
111   0f 95: set r8/m8-at-rm32 to 1 if not equal, if ZF is not set, 0 otherwise (setcc/setnz/setne)
112   0f 96: set r8/m8-at-rm32 to 1 if lesser or equal (addr, float), if ZF is set or CF is set, 0 otherwise (setcc/setbe/setna)
113   0f 97: set r8/m8-at-rm32 to 1 if greater (addr, float), if ZF is unset and CF is unset, 0 otherwise (setcc/seta/setnbe)
114   0f 9c: set r8/m8-at-rm32 to 1 if lesser, if SF != OF, 0 otherwise (setcc/setl/setnge)
115   0f 9d: set r8/m8-at-rm32 to 1 if greater or equal, if SF == OF, 0 otherwise (setcc/setge/setnl)
116   0f 9e: set r8/m8-at-rm32 to 1 if lesser or equal, if ZF is set or SF != OF, 0 otherwise (setcc/setle/setng)
117   0f 9f: set r8/m8-at-rm32 to 1 if greater, if ZF is unset and SF == OF, 0 otherwise (setcc/setg/setnle)
118   0f af: multiply rm32 into r32 (imul)
119   f3 0f 10: copy xm32 to x32 (movss)
120   f3 0f 11: copy x32 to xm32 (movss)
121   f3 0f 2a: convert integer to floating-point (cvtsi2ss)
122   f3 0f 2c: truncate floating-point to int (cvttss2si)
123   f3 0f 2d: convert floating-point to int (cvtss2si)
124   f3 0f 51: square root of float (sqrtss)
125   f3 0f 52: inverse square root of float (rsqrtss)
126   f3 0f 53: reciprocal of float (rcpss)
127   f3 0f 58: add floats (addss)
128   f3 0f 59: multiply floats (mulss)
129   f3 0f 5c: subtract floats (subss)
130   f3 0f 5d: minimum of two floats (minss)
131   f3 0f 5e: divide floats (divss)
132   f3 0f 5f: maximum of two floats (maxss)
133 Run `bootstrap help instructions` for details on words like 'r32' and 'disp8'.
134 For complete details on these instructions, consult the IA-32 manual (volume 2).
135 There's various versions of it online, such as https://c9x.me/x86.
136 The mnemonics in brackets will help you locate each instruction.