summaryrefslogtreecommitdiff
path: root/test/optimization.asm
blob: d78209d96e9c2380a76744f65c5bc47dc60b2212 (plain)
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
96
97
98
99
100
101
102
103
104
;Testname=O0; Arguments=-O0 -fbin -ooptimization.bin; Files=stdout stderr optimization.bin
;Testname=O1; Arguments=-O1 -fbin -ooptimization.bin; Files=stdout stderr optimization.bin
;Testname=Ox; Arguments=-Ox -fbin -ooptimization.bin; Files=stdout stderr optimization.bin

BITS 32

; Simple
jmp foo
times 124 nop
foo:

; Must start short to converge optimally
jmp car
times 127 nop
car:

; Always near
jmp cdr
times 128 nop
cdr:


; Simple
add eax, quux2 - quux1
quux1:
times 127 nop
quux2:

; Must start short
corge1:
add eax, corge2 - corge1
times 127 - 3 nop
corge2:


; Simple
lea eax, [bolug2-bolug1]
bolug1:
times 127 nop
bolug2:

; Must start short
calog1:
lea eax, [calog2-calog1]
times 127 - 3 nop
calog2:


; Simple
lea eax, [eax+dolug2-dolug1]
dolug1:
times 127 nop
dolug2:

; Must start short
ealog1:
lea eax, [eax+ealog2-ealog1]
times 127 - 3 nop
ealog2:

; Must stay long!
lea eax, [eax+folug2-folug1]
folug1:
times 128 nop
folug2:

; Must stay long!
galog1:
lea eax, [eax+galog2-galog1]
times 128 - 3 nop
galog2:

; Sbyte tests...
onetwentysix	equ 126
onetwentynine	equ 129
	
add eax,onetwentyseven		; sbyte (forward)
add eax,onetwentyeight		; not sbyte (forward)
add eax,onetwentyseven		; sbyte (forward)
add eax,onetwentysix		; sbyte (backward)
add eax,onetwentynine		; not sbyte (backward)
add ecx,onetwentyseven		; sbyte (forward)
add ecx,onetwentyeight		; not sbyte (forward)
add ecx,onetwentyseven		; sbyte (forward)
add ecx,onetwentysix		; sbyte (backward)
add ecx,onetwentynine		; not sbyte (backward)
	
onetwentyseven	equ 127
onetwentyeight	equ 128

; Simple
add eax, holug2-holug1
holug1:
times 127 nop
holug2:

; Must start short
ialog1:
add eax, ialog2-ialog1
times 127 - 3 nop
ialog2:
	
; Do not confuse forward references and segmentless addresses!
jmp 12345