summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt
blob: 304550155360d7ebe7087d9683cc1ad48f7892ff (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
# This filter is compiled to all_instructions.bpf by the `bpf_asm`
# tool, which can be found in the linux kernel source tree under
# tools/net.

# Load immediate
ld #42
ldx #42

# Load scratch
ld M[3]
ldx M[3]

# Load absolute
ldb [42]
ldh [42]
ld [42]

# Load indirect
ldb [x + 42]
ldh [x + 42]
ld [x + 42]

# Load IPv4 header length
ldx 4*([42]&0xf)

# Run extension function
ld #len
ld #proto
ld #type
ld #rand

# Store scratch
st M[3]
stx M[3]

# A <op> constant
add #42
sub #42
mul #42
div #42
or #42
and #42
lsh #42
rsh #42
mod #42
xor #42

# A <op> X
add x
sub x
mul x
div x
or x
and x
lsh x
rsh x
mod x
xor x

# !A
neg

# Jumps
ja end
jeq #42,prev,end
jne #42,end
jlt #42,end
jle #42,end
jgt #42,prev,end
jge #42,prev,end
jset #42,prev,end

# Register transfers
tax
txa

# Returns
prev: ret a
end: ret #42