(nw) z8 : added the DA instruction
This commit is contained in:
parent
94d215f4a1
commit
77b986a85d
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
- strobed I/O
|
- strobed I/O
|
||||||
- expose register file to disassembler
|
- expose register file to disassembler
|
||||||
- decimal adjust instruction
|
|
||||||
- timer Tin/Tout modes
|
- timer Tin/Tout modes
|
||||||
- serial
|
- serial
|
||||||
- instruction pipeline
|
- instruction pipeline
|
||||||
|
@ -308,6 +308,25 @@ INSTRUCTION( cp_IR1_IM ) { mode_IR1_IM(compare) }
|
|||||||
|
|
||||||
void z8_device::decimal_adjust(uint8_t dst)
|
void z8_device::decimal_adjust(uint8_t dst)
|
||||||
{
|
{
|
||||||
|
uint8_t data = register_read(dst);
|
||||||
|
uint16_t new_data = data;
|
||||||
|
if (flag(D))
|
||||||
|
{
|
||||||
|
if (flag(H) | ((data&0xf)>9)) new_data-=6;
|
||||||
|
if (flag(C) | (data>0x99)) new_data-=0x60;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (flag(H) | ((data&0xf)>9)) new_data+=6;
|
||||||
|
if (flag(C) | (data>0x99)) new_data+=0x60;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_flag_c(new_data & 0x100);
|
||||||
|
set_flag_s(new_data & 0x80);
|
||||||
|
new_data &= 0xff;
|
||||||
|
set_flag_z(new_data == 0);
|
||||||
|
// officially, v is undefined
|
||||||
|
register_write(dst, new_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTRUCTION( da_R1 ) { mode_R1(decimal_adjust) }
|
INSTRUCTION( da_R1 ) { mode_R1(decimal_adjust) }
|
||||||
|
Loading…
Reference in New Issue
Block a user