         let bP = plusPtr p 4
             setType = {#set cs_xcore_op->type#} p . fromIntegral . fromEnum
         case op of
-          Reg r -> poke bP r >> setType XcoreOpReg
+          Reg r -> do poke bP (fromIntegral $ fromEnum r :: Int32)
+                      setType XcoreOpReg
           Imm i -> poke bP i >> setType XcoreOpImm
           Mem m -> poke bP m >> setType XcoreOpMem
           _ -> setType XcoreOpInvalid


-- | instruction operand
data CsXCoreOp
    = Reg Word32 -- ^ register value for 'XcoreOpReg' operands
    | Imm Int32 -- ^ immediate value for 'XcoreOpImm' operands
    | Mem XCoreOpMemStruct -- ^ base/index/disp/direct value for 'XcoreOpMem'
                           -- operands

{#enum xcore_op_type as XCoreOpType {underscoreToCase}
    deriving (Show, Eq, Bounded)#}

-- | XCore registers
{#enum xcore_reg as XCoreReg {underscoreToCase}
    deriving (Show, Eq, Bounded)#}

-- | memory access operands
-- associated with 'XcoreOpMem' operand type
data XCoreOpMemStruct = XCoreOpMemStruct
