-
Notifications
You must be signed in to change notification settings - Fork 0
/
instruction_notes.txt
95 lines (78 loc) · 2.48 KB
/
instruction_notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Reference https://software.intel.com/content/www/us/en/develop/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-2a-2b-2c-and-2d-instruction-set-reference-a-z.html
`*` after an operand implies that it is optional
`~` in the description of an instruction means that at least one of the possible interpretations of the instruction has been left out due to complexity
===================
ADD dest, src
dest = dest + src
===================
===================
SUB dest, src
dest = dest - src
===================
===================
XOR dest, src
dest = dest XOR src
===================
===================
SHR dest, src
Shift `src` bits to right on `dest`
===================
===================
SHL dest, src
Shift `src` bits to left on `dest`
===================
===================
MOV dest, src
copy `src` to `dest`
===================
===================
MOVZX dest, src
copy `src` to `dest` and zero-extend it
===================
===================
LEA dest, complex_src
Evaluate `complex_src` and store in `dest`
NOTE - `complex_src` here means multiple registers/constants might be involved in the expression
===================
===================
IMUL dest, src1, src2*
dest = dest * src1
dest = src1 * src2
~ One-operand
===================
===================
CMP src1, src2
Compare 2 sources and store difference in temp
===================
===================
PUSH src
Decrements the stack pointer and then stores `src` on the top of the stack
===================
===================
JMP dest
Jumps to `dest` in instructions
~ task-switches
===================
===================
POP dest
Pop the stack to load that value into `dest` and increment the stack pointer
===================
# can't add IMUL code as parsing src2 is involved but crucial for determining `dest` is read from or written to
elif self.inst == DEPENDENCY_COMPATIBLE_INSTS[8]:
# imul
# either read src1 and dest, write dest
# or read src1 and src2, write dest
if len(temp_split_array) >= 2: # ignoring one-operand form
dest = temp_split_array[0]
src1 = re.search("^[a-z]+", temp_split_array[1]).group()
src2 = re.search("^[a-z]+", temp_split_array[2]).group()
if src1 in VALID_REGS:
self.reads.append(src1)
if src2 in VALID_REGS:
self.reads.append(src2)
if dest in VALID_REGS:
self.write = dest
else:
if dest in VALID_REGS:
self.reads.append(dest)
self.write = dest