# HG changeset patch # User nkeynes # Date 1195547494 0 # Node ID 9764673fd4a537ad380f107fe5228b3b455e3478 # Parent 43653e748030c50fa81fec47bf36b5833bed0aeb Fix TRAPA (translator) and add test case --- a/src/sh4/sh4x86.c Mon Nov 19 08:51:03 2007 +0000 +++ b/src/sh4/sh4x86.c Tue Nov 20 08:31:34 2007 +0000 @@ -2832,9 +2832,10 @@ if( sh4_x86.in_delay_slot ) { SLOTILLEGAL(); } else { + load_imm32( R_ECX, pc+2 ); + store_spreg( R_ECX, REG_OFFSET(pc) ); load_imm32( R_EAX, imm ); call_func1( sh4_raise_trap, R_EAX ); - ADD_imm8s_r32( 4, R_ESP ); sh4_x86.tstate = TSTATE_NONE; exit_block_pcset(pc); sh4_x86.branch_taken = TRUE; --- a/src/sh4/sh4x86.in Mon Nov 19 08:51:03 2007 +0000 +++ b/src/sh4/sh4x86.in Tue Nov 20 08:31:34 2007 +0000 @@ -1795,9 +1795,10 @@ if( sh4_x86.in_delay_slot ) { SLOTILLEGAL(); } else { + load_imm32( R_ECX, pc+2 ); + store_spreg( R_ECX, REG_OFFSET(pc) ); load_imm32( R_EAX, imm ); call_func1( sh4_raise_trap, R_EAX ); - ADD_imm8s_r32( 4, R_ESP ); sh4_x86.tstate = TSTATE_NONE; exit_block_pcset(pc); sh4_x86.branch_taken = TRUE; --- a/test/Makefile.in Mon Nov 19 08:51:03 2007 +0000 +++ b/test/Makefile.in Tue Nov 20 08:31:34 2007 +0000 @@ -77,7 +77,7 @@ sh4/div0.so sh4/div1.so sh4/float.so sh4/fmov.so sh4/ftrc.so \ sh4/mac.s \ sh4/rot.so sh4/shl.so sh4/shld.so sh4/sub.so sh4/subc.so \ - sh4/tas.so sh4/xtrct.so \ + sh4/trapa.so sh4/tas.so sh4/xtrct.so \ sh4/excslot.so sh4/undef.so $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS) $(SH4OBJCOPY) testsh4 testsh4.bin --- a/test/sh4/testsh4.c Mon Nov 19 08:51:03 2007 +0000 +++ b/test/sh4/testsh4.c Tue Nov 20 08:31:34 2007 +0000 @@ -67,6 +67,7 @@ test_shld(); test_sub(); test_subc(); + test_trapa(); test_tas(); test_xtrct(); fprintf( stdout, "--> %d/%d instruction tests passed (%d%%)\n\n", --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sh4/trapa.s Tue Nov 20 08:31:34 2007 +0000 @@ -0,0 +1,36 @@ +.section .text +.include "sh4/inc.s" + +.global _test_trapa +_test_trapa: + start_test + +test_trapa_1: + add #1, r12 + expect_exc 0x00000160 + trapa #42 + +test_trapa_1_pc: + assert_exc_caught test_trapa_str_k test_trapa_1_pc + + mov.l test_trapa_tra, r1 + mov.l @r1, r2 + mov #42, r0 + shll r0 + shll r0 + cmp/eq r0, r2 + bt test_trapa_end + fail test_trapa_str_k + bra test_trapa_end + nop + +test_trapa_tra: + .long 0xFF000020 + +test_trapa_end: + end_test test_trapa_str_k + +test_trapa_str_k: + .long test_trapa_str +test_trapa_str: + .string "TRAPA"