mirror of
https://github.com/holub/mame
synced 2025-06-29 07:34:45 +03:00
e132xs: Provide new helper functions for extracting signed 16-bit halves
* eminline.h: Remove mul_16x16 function
This commit is contained in:
parent
957cfaa53d
commit
edaa86db88
@ -337,6 +337,10 @@ private:
|
|||||||
|
|
||||||
uint32_t get_global_register(uint8_t code);
|
uint32_t get_global_register(uint8_t code);
|
||||||
|
|
||||||
|
// words interpreted as pairs of signed half-words (HS)
|
||||||
|
static int get_lhs(uint32_t val) { return int16_t(val & 0xffff); }
|
||||||
|
static int get_rhs(uint32_t val) { return int16_t(val >> 16); }
|
||||||
|
|
||||||
uint32_t get_emu_code_addr(uint8_t num);
|
uint32_t get_emu_code_addr(uint8_t num);
|
||||||
int32_t get_instruction_length(uint16_t op);
|
int32_t get_instruction_length(uint16_t op);
|
||||||
|
|
||||||
|
@ -2264,27 +2264,27 @@ void hyperstone_device::hyperstone_extend()
|
|||||||
|
|
||||||
// signed half-word multiply/add, single word product sum
|
// signed half-word multiply/add, single word product sum
|
||||||
case EHMAC:
|
case EHMAC:
|
||||||
m_core->global_regs[15] = (int32_t)m_core->global_regs[15] + mul_16x16(vald >> 16, vals >> 16) + mul_16x16(vald & 0xffff, vals & 0xffff);
|
m_core->global_regs[15] = m_core->global_regs[15] + get_lhs(vald) * get_lhs(vals) + get_rhs(vald) * get_rhs(vals);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// signed half-word multiply/add, double word product sum
|
// signed half-word multiply/add, double word product sum
|
||||||
case EHMACD:
|
case EHMACD:
|
||||||
{
|
{
|
||||||
int64_t result = get_double_word<GLOBAL>(14, 15) + (int64_t)mul_16x16(vald >> 16, vals >> 16) + (int64_t)mul_16x16(vald & 0xffff, vals & 0xffff);
|
int64_t result = get_double_word<GLOBAL>(14, 15) + int64_t(get_lhs(vald) * get_lhs(vals)) + int64_t(get_rhs(vald) * get_rhs(vals));
|
||||||
set_double_word<GLOBAL>(14, 15, result);
|
set_double_word<GLOBAL>(14, 15, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// half-word complex multiply
|
// half-word complex multiply
|
||||||
case EHCMULD:
|
case EHCMULD:
|
||||||
m_core->global_regs[14] = mul_16x16(vald >> 16, vals >> 16 ) - mul_16x16(vald & 0xffff, vals & 0xffff);
|
m_core->global_regs[14] = get_lhs(vald) * get_lhs(vals) - get_rhs(vald) * get_rhs(vals);
|
||||||
m_core->global_regs[15] = mul_16x16(vald >> 16, vals & 0xffff) + mul_16x16(vald & 0xffff, vals >> 16 );
|
m_core->global_regs[15] = get_lhs(vald) * get_rhs(vals) + get_rhs(vald) * get_lhs(vals);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// half-word complex multiply/add
|
// half-word complex multiply/add
|
||||||
case EHCMACD:
|
case EHCMACD:
|
||||||
m_core->global_regs[14] += mul_16x16(vald >> 16, vals >> 16 ) - mul_16x16(vald & 0xffff, vals & 0xffff);
|
m_core->global_regs[14] += get_lhs(vald) * get_lhs(vals) - get_rhs(vald) * get_rhs(vals);
|
||||||
m_core->global_regs[15] += mul_16x16(vald >> 16, vals & 0xffff) + mul_16x16(vald & 0xffff, vals >> 16 );
|
m_core->global_regs[15] += get_lhs(vald) * get_rhs(vals) + get_rhs(vald) * get_lhs(vals);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// half-word (complex) add/subtract
|
// half-word (complex) add/subtract
|
||||||
|
@ -50,19 +50,6 @@
|
|||||||
INLINE MATH FUNCTIONS
|
INLINE MATH FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/*-------------------------------------------------
|
|
||||||
mul_16x16 - perform a signed 16 bit x 16 bit
|
|
||||||
multiply and return the full 32 bit result
|
|
||||||
-------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef mul_16x16
|
|
||||||
constexpr int32_t mul_16x16(int16_t a, int16_t b)
|
|
||||||
{
|
|
||||||
return int32_t(a) * int32_t(b);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
mul_32x32 - perform a signed 32 bit x 32 bit
|
mul_32x32 - perform a signed 32 bit x 32 bit
|
||||||
multiply and return the full 64 bit result
|
multiply and return the full 64 bit result
|
||||||
|
Loading…
Reference in New Issue
Block a user