aboutsummaryrefslogtreecommitdiff
path: root/isa/rv32si/ma_addr.S
blob: 13ac778b059700110af58c7f44437a54379059a2 (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
# See LICENSE for license details.

#*****************************************************************************
# ma_addr.S
#-----------------------------------------------------------------------------
#
# Test misaligned ld/st trap.
#

#include "riscv_test.h"
#include "test_macros.h"

RVTEST_RV32S
RVTEST_CODE_BEGIN

  la s0, stvec_load

  la t0, stvec_load
  csrw stvec, t0

  li TESTNUM, 2
  lw x0, 1(s0)
  j fail

  li TESTNUM, 3
  lw x0, 2(s0)
  j fail

  li TESTNUM, 4
  lw x0, 3(s0)
  j fail

  li TESTNUM, 5
  lh x0, 1(s0)
  j fail

  li TESTNUM, 6
  lhu x0, 1(s0)
  j fail

  la t0, stvec_store
  csrw stvec, t0

  li TESTNUM, 7
  sw x0, 1(s0)
  j fail

  li TESTNUM, 8
  sw x0, 2(s0)
  j fail

  li TESTNUM, 9
  sw x0, 3(s0)
  j fail

  li TESTNUM, 10
  sh x0, 1(s0)
  j fail

  j pass

  TEST_PASSFAIL

stvec_load:
  li t1, CAUSE_MISALIGNED_LOAD
  csrr t0, scause
  bne t0, t1, fail
  csrr t0, sepc
  addi t0, t0, 8
  csrw sepc, t0
  sret

stvec_store:
  li t1, CAUSE_MISALIGNED_STORE
  csrr t0, scause
  bne t0, t1, fail
  csrr t0, sepc
  addi t0, t0, 8
  csrw sepc, t0
  sret

RVTEST_CODE_END

  .data
RVTEST_DATA_BEGIN

  TEST_DATA

RVTEST_DATA_END