forked from tehnar/sample-compiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbinops.ref
More file actions
41 lines (36 loc) · 730 Bytes
/
binops.ref
File metadata and controls
41 lines (36 loc) · 730 Bytes
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
http://www.felixcloutier.com/x86/
+ -> addl op1, op2
- -> subl op1, op2
* -> imull op1, op2
'op2' has to be register
/, % ->
'idiv' takes eax and divides it on an argument
op2 / op1:
mov op2, eax
cltd // puts appropriate bits to EDX register
idiv op1
/:
mov eax, op2
%:
mov edx, op2
&& ->
xor eax, eax
andl op1, op1 // 'op1' has to be register
setne al
andl op2, op2 // 'op2' has to be register
setne ah
and al, ah
mov eax, op2
|| ->
xor eax, eax
orl op1, op2
setne al
mov eax, op2
<. <=, ==, !=, >=, > ->
xor eax, eax
cmp op1, op2 // Result to EFLAGS
set(**) al
mov eax, op2
type instructions =
...
| X86Set of string * string