minor cleanup; init mem with $95

This commit is contained in:
Christopher Mosher 2013-11-26 01:21:17 -05:00
parent 2aab7240d2
commit f8d5955b6e
3 changed files with 14 additions and 7 deletions

View File

@ -8,4 +8,5 @@ v6502.o: v6502.cpp cpu.h addressbus.h
cpu.o: cpu.cpp cpu.h addressbus.h nodes.h
clean:
rm *.o
-rm *.o
-rm v6502

View File

@ -9,7 +9,7 @@ public:
AddressBus() {
for (int i = 0; i < 0x10000; ++i) {
memory[i] = 0;
memory[i] = 0x95;
}
}
~AddressBus() {}

View File

@ -37,6 +37,11 @@
int main(int argc, char *argv[]) {
AddressBus mem;
CPU cpu(mem);
/* Load some test program into memory */
mem.write(0x0200, 0xEA); // NOP
mem.write(0x0201, 0xEA); // NOP
mem.write(0x0202, 0xA9); // LDA #$5A
@ -45,27 +50,28 @@ int main(int argc, char *argv[]) {
mem.write(0x0205, 0x88); //
mem.write(0x0206, 0xA9); // LDA #$23
mem.write(0x0207, 0x23); //
mem.write(0x0208, 0xD0); // BNE 0
mem.write(0x0209, 0xF8); //
mem.write(0x0208, 0xD0); // BNE $0200
mem.write(0x0209, 0xF6); //
mem.write(0xFFFC, 0x02); // RESET --> $0202
mem.write(0xFFFD, 0x02);
CPU cpu(mem);
/* Now let's just run some things to play with it. */
/* turn on the CPU */
std::cout << "begin power-up..." << std::endl;
cpu.powerOn();
/* run it a bit, before resetting */
std::cout << "some power-up pre-reset cycles..." << std::endl;
for (int i(0); i < 10; ++i) {
cpu.tick();
}
/* reset the CPU, and let it run for a little while, then exit */
std::cout << "RESET..." << std::endl;
cpu.reset();
for (int i(0); i < 40; ++i) {
for (int i(0); i < 50; ++i) {
cpu.tick();
}