Shouldn't it literally just be

Code
void sm510_base_device::op_lb()
{
	// LB x: load BM/BL with 4-bit immediate value (partial)
	m_bm = (m_bm & 0x04) | (m_param & 0x03);
	
	m_bl = ((m_param >> 3) ^ (m_param >> 2)) & 0x01;
	m_bl = (m_bl << 1) | m_bl;
	m_bl <<= 2;
	m_bl |= (m_param >> 2) & 0x03);
}

void sm511_device::op_lb()
{
	// LB xy: load BL with y, BM with x; 2-bit immediate value each
	// B_M1 <= I_2 in 1990 Sharp Microcontroller Data Book p.170 is a typo I think
	m_bm = (m_bm & 0x04) | (m_param & 0x03);
	m_bl = (m_bl & 0x0C) | ((m_param >> 2) & 0x03);
}

Did you try this naïve implementation already and saw that it failed, or what seems to be the issue? I think p170 in the data book must be a typo when it assigns B_M2 <= I2 instead of B_M2 <= I1...

EDIT: I think op_incb and op_decb also need attention. They currently skip the next instruction when they overflow. However, I think what the datasheet means is that B_L cannot overflow using these ops.

INCB 64 Skip if B_L=F_H; B_L <= B_L + 1

I read that as:

Code
if (m_bl != 0xF)
    m_bl = (m_bl + 1) & 0xF;

cYa,

Tauwasser

Last edited by Tauwasser; 07/10/15 08:53 PM.