msr_dr = (value >> MSR_DR) & 0x01;
     msr_ri = (value >> MSR_RI) & 0x01;
     msr_le = (value >> MSR_LE) & 0x01;
+    /* XXX: should enter PM state if msr_pow has been set */
 }
 
+#if defined (CONFIG_USER_ONLY)
 void do_interrupt (CPUState *env)
 {
-#if defined (CONFIG_USER_ONLY)
-    env->exception_index |= 0x100;
+    env->exception_index = -1;
+}
 #else
+void do_interrupt (CPUState *env)
+{
     uint32_t msr;
-    int excp = env->exception_index;
+    int excp;
 
+    excp = env->exception_index;
     msr = _load_msr(env);
 #if defined (DEBUG_EXCEPTIONS)
     if ((excp == EXCP_PROGRAM || excp == EXCP_DSI) && msr_pr == 1) 
     tmp_T0 = 0;
 #else
     T0 = 0;
-#endif
 #endif
     env->exception_index = -1;
 }
+#endif /* !CONFIG_USER_ONLY */
 
 
 typedef struct opcode_t {
     unsigned char opc1, opc2, opc3;
+#if HOST_LONG_BITS == 64 /* Explicitely align to 64 bits */
+    unsigned char pad[5];
+#else
+    unsigned char pad[1];
+#endif
     opc_handler_t handler;
 } opcode_t;
 
 #define EXTRACT_SHELPER(name, shift, nb)                                      \
 static inline int32_t name (uint32_t opcode)                                  \
 {                                                                             \
-    return s_ext16((opcode >> (shift)) & ((1 << (nb)) - 1));                  \
+    return (int16_t)((opcode >> (shift)) & ((1 << (nb)) - 1));                \
 }
 
 /* Opcode part 1 */
 #endif
 
 #define GEN_OPCODE(name, op1, op2, op3, invl, _typ)                           \
-OPCODES_SECTION static opcode_t opc_##name = {                                \
+OPCODES_SECTION opcode_t opc_##name = {                                       \
     .opc1 = op1,                                                              \
     .opc2 = op2,                                                              \
     .opc3 = op3,                                                              \
+    .pad  = { 0, },                                                           \
     .handler = {                                                              \
         .inval   = invl,                                                      \
         .type = _typ,                                                         \
 }
 
 #define GEN_OPCODE_MARK(name)                                                 \
-OPCODES_SECTION static opcode_t opc_##name = {                                \
+OPCODES_SECTION opcode_t opc_##name = {                                       \
     .opc1 = 0xFF,                                                             \
     .opc2 = 0xFF,                                                             \
     .opc3 = 0xFF,                                                             \
+    .pad  = { 0, },                                                           \
     .handler = {                                                              \
         .inval   = 0x00000000,                                                \
         .type = 0x00,                                                         \
     gen_op_load_gpr_T1(rB(ctx->opcode));                                      \
     gen_op_##name();                                                          \
     if (Rc(ctx->opcode) != 0)                                                 \
-        gen_op_set_Rc0_ov();                                                  \
+        gen_op_set_Rc0();                                                     \
     gen_op_store_T0_gpr(rD(ctx->opcode));                                     \
 }
 
     gen_op_load_gpr_T0(rA(ctx->opcode));                                      \
     gen_op_##name();                                                          \
     if (Rc(ctx->opcode) != 0)                                                 \
-        gen_op_set_Rc0_ov();                                                  \
+        gen_op_set_Rc0();                                                     \
     gen_op_store_T0_gpr(rD(ctx->opcode));                                     \
 }
 
         gen_op_dec_ctr();                                                     
     switch(type) {
     case BCOND_IM:
-        li = s_ext16(BD(ctx->opcode));
+        li = (int32_t)((int16_t)(BD(ctx->opcode)));
         if (AA(ctx->opcode) == 0) {
             target = ctx->nip + li - 4;
         } else {
     case DECR:
         gen_op_store_decr();
         break;
-#if 0
-    case HID0:
-        gen_op_store_hid0();
-        break;
-#endif
     default:
         gen_op_store_spr(sprn);
         break;
 
 static int create_ppc_proc (opc_handler_t **ppc_opcodes, unsigned long pvr)
 {
-    opcode_t *opc;
+    opcode_t *opc, *start, *end;
     int i, flags;
 
     fill_new_table(ppc_opcodes, 0x40);
         }
     }
     
-    for (opc = &opc_start + 1; opc != &opc_end; opc++) {
+    if (&opc_start < &opc_end) {
+       start = &opc_start;
+       end = &opc_end;
+    } else {
+       start = &opc_end;
+       end = &opc_start;
+    }
+    for (opc = start + 1; opc != end; opc++) {
         if ((opc->handler.type & flags) != 0)
             if (register_insn(ppc_opcodes, opc) < 0) {
                 printf("*** ERROR initializing PPC instruction "