...

Text file src/golang.org/x/net/bpf/testdata/all_instructions.txt

Documentation: golang.org/x/net/bpf/testdata

     1# This filter is compiled to all_instructions.bpf by the `bpf_asm`
     2# tool, which can be found in the linux kernel source tree under
     3# tools/bpf.
     4
     5# Load immediate
     6ld #42
     7ldx #42
     8
     9# Load scratch
    10ld M[3]
    11ldx M[3]
    12
    13# Load absolute
    14ldb [42]
    15ldh [42]
    16ld [42]
    17
    18# Load indirect
    19ldb [x + 42]
    20ldh [x + 42]
    21ld [x + 42]
    22
    23# Load IPv4 header length
    24ldx 4*([42]&0xf)
    25
    26# Run extension function
    27ld #len
    28ld #proto
    29ld #type
    30ld #rand
    31
    32# Store scratch
    33st M[3]
    34stx M[3]
    35
    36# A <op> constant
    37add #42
    38sub #42
    39mul #42
    40div #42
    41or #42
    42and #42
    43lsh #42
    44rsh #42
    45mod #42
    46xor #42
    47
    48# A <op> X
    49add x
    50sub x
    51mul x
    52div x
    53or x
    54and x
    55lsh x
    56rsh x
    57mod x
    58xor x
    59
    60# !A
    61neg
    62
    63# Jump A <op> constant
    64ja end
    65jeq #42,prev,end
    66jne #42,end
    67jlt #42,end
    68jle #42,end
    69jgt #42,prev,end
    70jge #42,prev,end
    71jset #42,prev,end
    72
    73# Jump A <op> X
    74jeq x,prev,end
    75jne x,end
    76jlt x,end
    77jle x,end
    78jgt x,prev,end
    79jge x,prev,end
    80jset x,prev,end
    81
    82# Register transfers
    83tax
    84txa
    85
    86# Returns
    87prev: ret a
    88end: ret #42

View as plain text