2012-08-28  Kaushik Phatak  <kaushik.phatak@kpitcummins.com>
 
+       * cr16_sim.h: Add defines for TRAP handling.
        * interp.c (sim_complete_command): New stub function.
+       * simops.c: Breakpoint handling code.
 
 2012-06-17  Mike Frysinger  <vapier@gentoo.org>
 
 
    PSR is masked for zero bits. */
 
 extern creg_t move_to_cr (int cr, creg_t mask, creg_t val, int psw_hw_p);
+
+#ifndef SIGTRAP
+#define SIGTRAP 5
+#endif
+/* Special purpose trap  */
+#define TRAP_BREAKPOINT 8
 
       iaddr = imem_addr ((uint32)PC);
       if (iaddr == State.mem.fault)
         {
+#ifdef SIGBUS
           State.exception = SIGBUS;
+#else
+          State.exception = SIGSEGV;
+#endif
           break;
         }
  
 
 void
 OP_C_C ()
 {
+  uint32 tmp;
+  uint16 a;
   trace_input ("excp", OP_CONSTANT4, OP_VOID, OP_VOID);
   switch (OP[0])
     {
 #endif
            
          default:
-           cr16_callback->error (cr16_callback, "Unknown syscall %d", FUNC);
+           a = OP[0];
+           switch (a)
+           {
+             case TRAP_BREAKPOINT:
+               State.exception = SIGTRAP;
+               tmp = (PC);
+               JMP(tmp);
+               trace_output_void ();
+               break;
+             case SIGTRAP:  /* supervisor call ?  */
+               State.exception = SIG_CR16_EXIT;
+               trace_output_void ();
+               break;
+             default:
+               cr16_callback->error (cr16_callback, "Unknown syscall %d", FUNC);
+               break;
+           }
          }
-
        if ((uint16) result == (uint16) -1)
          RETERR (cr16_callback->get_errno(cr16_callback));
        else