mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-27 04:31:26 +00:00
Get the MC6809 processor compiling. Still untested.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
6b33d2b5a5
commit
294c71c228
101
MC6809/MC6809.cs
101
MC6809/MC6809.cs
@ -1339,7 +1339,6 @@
|
|||||||
var specifier2 = Chip.LowNibble(data);
|
var specifier2 = Chip.LowNibble(data);
|
||||||
|
|
||||||
var type8 = (specifier1 & (int)Bits.Bit3) == 0; // 8 bit exchange?
|
var type8 = (specifier1 & (int)Bits.Bit3) == 0; // 8 bit exchange?
|
||||||
|
|
||||||
if (type8)
|
if (type8)
|
||||||
{
|
{
|
||||||
ref var register1 = ref this.ReferenceTransfer8(specifier1);
|
ref var register1 = ref this.ReferenceTransfer8(specifier1);
|
||||||
@ -1356,11 +1355,11 @@
|
|||||||
|
|
||||||
private byte INC(byte operand)
|
private byte INC(byte operand)
|
||||||
{
|
{
|
||||||
const register16_t addition = operand + 1;
|
var addition = new Register16(operand + 1);
|
||||||
const auto result = addition.low;
|
var result = addition.Low;
|
||||||
adjustNZ(result);
|
this.AdjustNZ(result);
|
||||||
adjustOverflow(operand, 1, addition);
|
this.AdjustOverflow(operand, 1, addition);
|
||||||
adjustHalfCarry(operand, 1, result);
|
this.AdjustHalfCarry(operand, 1, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1370,26 +1369,26 @@
|
|||||||
|
|
||||||
private byte LSR(byte operand)
|
private byte LSR(byte operand)
|
||||||
{
|
{
|
||||||
setFlag(CC(), CF, operand & Bit0);
|
SetFlag(this.CC, StatusBits.CF, operand & (byte)Bits.Bit0);
|
||||||
adjustNZ(operand >>= 1);
|
this.AdjustNZ(operand >>= 1);
|
||||||
return operand;
|
return operand;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Register16 MUL(byte first, byte second)
|
private Register16 MUL(byte first, byte second)
|
||||||
{
|
{
|
||||||
const register16_t result = first * second;
|
var result = new Register16(first * second);
|
||||||
adjustZero(result);
|
this.AdjustZero(result);
|
||||||
setFlag(CC(), CF, result.low & Bit7);
|
SetFlag(this.CC, StatusBits.CF, result.Low & (byte)Bits.Bit7);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte NEG(byte operand)
|
private byte NEG(byte operand)
|
||||||
{
|
{
|
||||||
setFlag(CC(), VF, operand == Bit7);
|
SetFlag(this.CC, StatusBits.VF, operand == (byte)Bits.Bit7);
|
||||||
const register16_t result = 0 - operand;
|
var result = new Register16(0 - operand);
|
||||||
operand = result.low;
|
operand = result.Low;
|
||||||
adjustNZ(operand);
|
this.AdjustNZ(operand);
|
||||||
adjustCarry(result);
|
this.AdjustCarry(result);
|
||||||
return operand;
|
return operand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1501,20 +1500,20 @@
|
|||||||
|
|
||||||
private byte ROL(byte operand)
|
private byte ROL(byte operand)
|
||||||
{
|
{
|
||||||
const auto carryIn = carry();
|
var carryIn = this.Carry;
|
||||||
setFlag(CC(), CF, operand & Bit7);
|
SetFlag(this.CC, StatusBits.CF, operand & (byte)Bits.Bit7);
|
||||||
setFlag(CC(), VF, ((operand & Bit7) >> 7) ^ ((operand & Bit6) >> 6));
|
SetFlag(this.CC, StatusBits.VF, ((operand & (byte)Bits.Bit7) >> 7) ^ ((operand & (byte)Bits.Bit6) >> 6));
|
||||||
const uint8_t result = (operand << 1) | carryIn;
|
var result = (byte)((operand << 1) | carryIn);
|
||||||
adjustNZ(result);
|
this.AdjustNZ(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte ROR(byte operand)
|
private byte ROR(byte operand)
|
||||||
{
|
{
|
||||||
const auto carryIn = carry();
|
var carryIn = this.Carry;
|
||||||
setFlag(CC(), CF, operand & Bit0);
|
SetFlag(this.CC, StatusBits.CF, operand & (byte)Bits.Bit0);
|
||||||
const uint8_t result = (operand >> 1) | (carryIn << 7);
|
var result = (byte)((operand >> 1) | (carryIn << 7));
|
||||||
adjustNZ(result);
|
this.AdjustNZ(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1526,56 +1525,62 @@
|
|||||||
|
|
||||||
private byte SUB(byte operand, byte data, byte carry = 0)
|
private byte SUB(byte operand, byte data, byte carry = 0)
|
||||||
{
|
{
|
||||||
const register16_t subtraction = operand - data - carry;
|
var subtraction = new Register16(operand - data - carry);
|
||||||
adjustSubtraction(operand, data, subtraction);
|
this.AdjustSubtraction(operand, data, subtraction);
|
||||||
return subtraction.low;
|
return subtraction.Low;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Register16 SUB(Register16 operand, Register16 data)
|
private Register16 SUB(Register16 operand, Register16 data)
|
||||||
{
|
{
|
||||||
const uint32_t subtraction = operand.word - data.word;
|
var subtraction = (uint)(operand.Word - data.Word);
|
||||||
adjustSubtraction(operand, data, subtraction);
|
this.AdjustSubtraction(operand, data, subtraction);
|
||||||
return subtraction & Mask16;
|
return new Register16(subtraction & (uint)Mask.Mask16);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte SEX(byte from)
|
private byte SEX(byte from)
|
||||||
{
|
{
|
||||||
adjustNZ(from);
|
this.AdjustNZ(from);
|
||||||
return from & Bit7 ? Mask8 : 0;
|
return (from & (byte)Bits.Bit7) != 0 ? (byte)Mask.Mask8 : (byte)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SWI()
|
private void SWI()
|
||||||
{
|
{
|
||||||
saveEntireRegisterState();
|
this.SaveEntireRegisterState();
|
||||||
setFlag(CC(), IF); // Disable IRQ
|
SetFlag(this.CC, StatusBits.IF); // Disable IRQ
|
||||||
setFlag(CC(), FF); // Disable FIRQ
|
SetFlag(this.CC, StatusBits.FF); // Disable FIRQ
|
||||||
jump(getWordPaged(0xff, SWIvector));
|
this.Jump(this.GetWordPaged(0xff, SWIvector));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SWI2()
|
private void SWI2()
|
||||||
{
|
{
|
||||||
saveEntireRegisterState();
|
this.SaveEntireRegisterState();
|
||||||
jump(getWordPaged(0xff, SWI2vector));
|
this.Jump(this.GetWordPaged(0xff, SWI2vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SWI3()
|
private void SWI3()
|
||||||
{
|
{
|
||||||
saveEntireRegisterState();
|
this.SaveEntireRegisterState();
|
||||||
jump(getWordPaged(0xff, SWI3vector));
|
this.Jump(this.GetWordPaged(0xff, SWI3vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TFR(byte data)
|
private void TFR(byte data)
|
||||||
{
|
{
|
||||||
const auto reg1 = highNibble(data);
|
var specifier1 = Chip.HighNibble(data);
|
||||||
const auto reg2 = lowNibble(data);
|
var specifier2 = Chip.LowNibble(data);
|
||||||
|
|
||||||
const bool type8 = !!(reg1 & Bit3); // 8 bit transfer?
|
|
||||||
ASSUME(type8 == !!(reg2 & Bit3)); // Regardless, the register transfer must be equivalent
|
|
||||||
|
|
||||||
|
var type8 = (specifier1 & (int)Bits.Bit3) == 0; // 8 bit transfer?
|
||||||
if (type8)
|
if (type8)
|
||||||
referenceTransfer8(reg2) = referenceTransfer8(reg1);
|
{
|
||||||
|
ref var register1 = ref this.ReferenceTransfer8(specifier1);
|
||||||
|
ref var register2 = ref this.ReferenceTransfer8(specifier2);
|
||||||
|
register2 = register1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
referenceTransfer16(reg2) = referenceTransfer16(reg1);
|
{
|
||||||
|
var register1 = this.ReferenceTransfer16(specifier1);
|
||||||
|
var register2 = this.ReferenceTransfer16(specifier2);
|
||||||
|
register2 = register1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TST(byte data) => this.CMP(data, 0);
|
private void TST(byte data) => this.CMP(data, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user