xref: /netbsd-src/external/gpl3/gdb/dist/sim/testsuite/bpf/mem.s (revision 0a3071956a3a9fdebdbf7f338cf2d439b45fc728)
1# mach: bpf
2# output: pass\nexit 0 (0x0)\n
3;;; mem.s
4;;; Tests for BPF memory (ldx, stx, ..) instructions in simulator
5
6    .include "testutils.inc"
7
8    .text
9    .global main
10    .type main, @function
11main:
12    lddw        %r1, 0x1234deadbeef5678
13    mov         %r2, 0x1000
14
15    ;; basic store/load check
16    stxb        [%r2+0], %r1
17    stxh        [%r2+2], %r1
18    stxw        [%r2+4], %r1
19    stxdw       [%r2+8], %r1
20
21    stb         [%r2+16], 0x5a
22    sth         [%r2+18], 0xcafe
23    stw         [%r2+20], 0xbeefface
24    stdw        [%r2+24], 0x7eadbeef
25
26    ldxb        %r1, [%r2+16]
27    fail_ne     %r1, 0x5a
28    ldxh        %r1, [%r2+18]
29    fail_ne     %r1, 0xffffffffffffcafe
30    ldxw        %r1, [%r2+20]
31    fail_ne     %r1, 0xffffffffbeefface
32    ldxdw       %r1, [%r2+24]
33    fail_ne     %r1, 0x7eadbeef
34
35    ldxb        %r3, [%r2+0]
36    fail_ne     %r3, 0x78
37    ldxh        %r3, [%r2+2]
38    fail_ne     %r3, 0x5678
39    ldxw        %r3, [%r2+4]
40    fail_ne     %r3, 0xffffffffbeef5678
41    ldxdw       %r3, [%r2+8]
42    fail_ne     %r3, 0x1234deadbeef5678
43
44    ldxw        %r4, [%r2+10]
45    fail_ne     %r4, 0xffffffffdeadbeef
46
47    ;; negative offsets
48    add         %r2, 16
49    ldxh        %r5, [%r2+-14]
50    fail_ne     %r5, 0x5678
51    ldxw        %r5, [%r2+-12]
52    fail_ne     %r5, 0xffffffffbeef5678
53    ldxdw       %r5, [%r2+-8]
54    fail_ne     %r5, 0x1234deadbeef5678
55
56    pass
57