         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

           then error "operands overflew 8 elements"
           else pokeArray (plusPtr p {#offsetof cs_xcore->operands#}) o

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

{#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
