twoapple-reboot/src/d6502/nmosbase.d

72 lines
2.2 KiB
D
Raw Normal View History

2012-03-14 00:43:29 +00:00
/+
+ d6502/nmosbase.d
+
+ Copyright: 2007 Gerald Stocker
+
2012-03-15 06:21:12 +00:00
+ This file is part of twoapple-reboot.
2012-03-14 00:43:29 +00:00
+
2012-03-15 06:21:12 +00:00
+ twoapple-reboot is free software; you can redistribute it and/or modify
2012-03-14 00:43:29 +00:00
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
2012-03-15 06:21:12 +00:00
+ twoapple-reboot is distributed in the hope that it will be useful,
2012-03-14 00:43:29 +00:00
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
2012-03-15 06:21:12 +00:00
+ along with twoapple-reboot; if not, write to the Free Software
2012-03-14 00:43:29 +00:00
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+/
2012-03-14 12:24:35 +00:00
module d6502.nmosbase;
2012-03-14 00:43:29 +00:00
import d6502.cpu;
class NmosBase(bool strict, bool cumulative) : Cpu!(strict, cumulative)
2012-03-14 00:43:29 +00:00
{
enum _isNMOS = true;
2012-03-14 00:43:29 +00:00
this()
{
super();
spuriousAddress = &badAddress;
}
static string RMW(string action)
{
return "poke(primaryAddress, (readVal = read(primaryAddress)));\n" ~
2012-04-08 21:01:38 +00:00
"write(primaryAddress, flag.zero_ = flag.negative_ = " ~
2012-03-14 00:43:29 +00:00
action ~ "(readVal));\n";
}
mixin(Opcode(mixin(Type2Address(
"ASL", "Write", [0x06, 0x0E, 0x16, 0x1E])),
RMW("shiftLeft")));
mixin(Opcode(mixin(Type2Address(
"LSR", "Write", [0x46, 0x4E, 0x56, 0x5E])),
RMW("shiftRight")));
mixin(Opcode(mixin(Type2Address(
"ROL", "Write", [0x26, 0x2E, 0x36, 0x3E])),
RMW("rotateLeft")));
mixin(Opcode(mixin(Type2Address(
"ROR", "Write", [0x66, 0x6E, 0x76, 0x7E])),
RMW("rotateRight")));
mixin(Opcode(mixin(Type2Address(
"INC", "Write", [0xE6, 0xEE, 0xF6, 0xFE])),
RMW("increment")));
mixin(Opcode(mixin(Type2Address(
"DEC", "Write", [0xC6, 0xCE, 0xD6, 0xDE])),
RMW("decrement")));
/* JMP ($$$$) */
override void opcode6C()
{
ushort vector = readWordOperand();
programCounter = readWord(vector,
(vector & 0xFF00) | cast(ubyte)(vector + 1));
static if (cumulative) tick(totalCycles);
2012-03-14 00:43:29 +00:00
}
}