trap.cgs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # m32r testcase for trap #$uimm4
  2. # mach(): m32r m32rx
  3. # sim: --environment virtual
  4. .include "testutils.inc"
  5. start
  6. .global trap
  7. trap:
  8. ; Test 1: bbpsw = 0, bpsw = 1, psw = 0
  9. ; bbsm = 0, bie = 0, bbcond = 0
  10. mvi_h_gr r4, 0
  11. mvtc r4, cr8
  12. ; bsm = 1, bie = 1, bcond = 1, sm = 0, ie = 0, cond = 0
  13. mvi_h_gr r4, 0xc100
  14. mvtc r4, cr0
  15. ; bbpc = 0
  16. mvaddr_h_gr r4, 0
  17. mvtc r4, bbpc
  18. ; bpc = 42
  19. mvaddr_h_gr r4, 42
  20. mvtc r4, bpc
  21. ; Copy trap2_handler to trap area of memory.
  22. ld24 r0,#0x48 ; address of trap 2 handler
  23. ld24 r1,#trap2_handler
  24. ld r2,@r1
  25. st r2,@r0
  26. ; Set up return address.
  27. ld24 r5,#trap2_ret1
  28. trap_insn1:
  29. trap #2
  30. fail
  31. trap2_ret1:
  32. ; test bbsm = 1, bbie = 1, bbcond = 1
  33. mvfc r4, cr8
  34. test_h_gr r4, 0xc1
  35. ; test bsm = 0, bie = 0, bcond = 0, sm = 0, ie = 0, cond = 0
  36. mvfc r4, cr0
  37. test_h_gr r4, 0
  38. ; test bbpc = 42
  39. mvfc r4, bbpc
  40. test_h_gr r4, 42
  41. ; test bpc = proper return address
  42. mvfc r4, bpc
  43. test_h_gr r4, trap_insn1 + 4
  44. ; Test 2: bbpsw = 1, bpsw = 0, psw = 1
  45. ; bbsm = 1, bie = 1, bbcond = 1
  46. mvi_h_gr r4, 0xc1
  47. mvtc r4, cr8
  48. ; bsm = 0, bie = 0, bcond = 0, sm = 1, ie = 1, cond = 1
  49. mvi_h_gr r4, 0xc1
  50. mvtc r4, cr0
  51. ; bbpc = 42
  52. mvaddr_h_gr r4, 42
  53. mvtc r4, bbpc
  54. ; bpc = 0
  55. mvaddr_h_gr r4, 0
  56. mvtc r4, bpc
  57. ; Set up return address.
  58. ld24 r5,#trap2_ret2
  59. trap_insn2:
  60. trap #2
  61. fail
  62. trap2_ret2:
  63. ; test bbsm = 0, bbie = 0, bbcond = 0
  64. mvfc r4, cr8
  65. test_h_gr r4, 0
  66. ; test bsm = 1, bie = 1, bcond = 1, sm = 1, ie = 0, cond = 0
  67. mvfc r4, cr0
  68. test_h_gr r4, 0xc180
  69. ; test bbpc = 0
  70. mvfc r4, bbpc
  71. test_h_gr r4, 0
  72. ; test bpc = proper return address
  73. mvfc r4, bpc
  74. test_h_gr r4, trap_insn2 + 4
  75. pass
  76. .data
  77. ; Don't use rte as it will undo the effects of trap we're testing.
  78. .p2align 2
  79. trap2_handler:
  80. jmp r5
  81. nop