File: mem.s

package info (click to toggle)
gdb-doc 13.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 234,284 kB
  • sloc: ansic: 1,988,072; asm: 373,465; exp: 187,579; cpp: 75,697; makefile: 69,432; sh: 24,829; yacc: 11,654; python: 9,602; ada: 6,680; xml: 6,073; perl: 5,077; pascal: 3,357; f90: 2,555; tcl: 1,902; lisp: 1,578; cs: 879; lex: 759; sed: 228; awk: 154; objc: 137; fortran: 57
file content (56 lines) | stat: -rw-r--r-- 1,403 bytes parent folder | download | duplicates (6)
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
# mach: bpf
# output: pass\nexit 0 (0x0)\n
;;; mem.s
;;; Tests for BPF memory (ldx, stx, ..) instructions in simulator

    .include "testutils.inc"

    .text
    .global main
    .type main, @function
main:
    lddw        %r1, 0x1234deadbeef5678
    mov         %r2, 0x1000

    ;; basic store/load check
    stxb        [%r2+0], %r1
    stxh        [%r2+2], %r1
    stxw        [%r2+4], %r1
    stxdw       [%r2+8], %r1

    stb         [%r2+16], 0x5a
    sth         [%r2+18], 0xcafe
    stw         [%r2+20], 0xbeefface
    stdw        [%r2+24], 0x7eadbeef

    ldxb        %r1, [%r2+16]
    fail_ne     %r1, 0x5a
    ldxh        %r1, [%r2+18]
    fail_ne     %r1, 0xffffffffffffcafe
    ldxw        %r1, [%r2+20]
    fail_ne     %r1, 0xffffffffbeefface
    ldxdw       %r1, [%r2+24]
    fail_ne     %r1, 0x7eadbeef

    ldxb        %r3, [%r2+0]
    fail_ne     %r3, 0x78
    ldxh        %r3, [%r2+2]
    fail_ne     %r3, 0x5678
    ldxw        %r3, [%r2+4]
    fail_ne     %r3, 0xffffffffbeef5678
    ldxdw       %r3, [%r2+8]
    fail_ne     %r3, 0x1234deadbeef5678

    ldxw        %r4, [%r2+10]
    fail_ne     %r4, 0xffffffffdeadbeef

    ;; negative offsets
    add         %r2, 16
    ldxh        %r5, [%r2+-14]
    fail_ne     %r5, 0x5678
    ldxw        %r5, [%r2+-12]
    fail_ne     %r5, 0xffffffffbeef5678
    ldxdw       %r5, [%r2+-8]
    fail_ne     %r5, 0x1234deadbeef5678

    pass