2017-01-16 18:35:28 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "bus.h"
|
2017-01-17 13:29:20 +00:00
|
|
|
#include "instruction.h"
|
|
|
|
#include "rk65c02.h"
|
2017-01-16 18:35:28 +00:00
|
|
|
|
|
|
|
static bool run = false;
|
|
|
|
|
|
|
|
void
|
|
|
|
rk6502_start(bus_t *b, uint16_t addr) {
|
|
|
|
instruction_t i;
|
2017-01-18 14:45:28 +00:00
|
|
|
reg_state_t r;
|
|
|
|
rk65c02emu_t e;
|
2017-01-16 18:35:28 +00:00
|
|
|
|
2017-01-18 14:45:28 +00:00
|
|
|
e.bus = b;
|
|
|
|
e.regs = &r;
|
|
|
|
e.regs->PC = addr;
|
2017-01-16 18:35:28 +00:00
|
|
|
|
|
|
|
run = true;
|
|
|
|
while (run) {
|
2017-01-18 14:45:28 +00:00
|
|
|
disassemble(e.bus, e.regs->PC);
|
|
|
|
i = instruction_fetch(e.bus, e.regs->PC);
|
2017-01-16 18:35:28 +00:00
|
|
|
|
|
|
|
//execute(i, r);
|
|
|
|
|
2017-01-17 13:29:20 +00:00
|
|
|
if (i.def.opcode == 0xDB) // STP
|
2017-01-16 18:35:28 +00:00
|
|
|
run = false;
|
|
|
|
|
2017-01-18 14:45:28 +00:00
|
|
|
e.regs->PC += i.def.size;
|
2017-01-16 18:35:28 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-16 22:54:24 +00:00
|
|
|
/*
|
2017-01-16 18:35:28 +00:00
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
bus_t b;
|
|
|
|
|
|
|
|
b = bus_init();
|
|
|
|
|
|
|
|
bus_write_1(&b, 0, OP_INX);
|
|
|
|
bus_write_1(&b, 1, OP_NOP);
|
|
|
|
bus_write_1(&b, 2, OP_LDY_IMM);
|
|
|
|
bus_write_1(&b, 3, 0x1);
|
|
|
|
bus_write_1(&b, 4, OP_TSB_ZP);
|
|
|
|
bus_write_1(&b, 5, 0x3);
|
|
|
|
bus_write_1(&b, 6, OP_JSR);
|
|
|
|
bus_write_1(&b, 7, 0x09);
|
|
|
|
bus_write_1(&b, 8, 0x0);
|
|
|
|
bus_write_1(&b, 9, OP_STP);
|
|
|
|
|
|
|
|
rk6502_start(&b, 0);
|
|
|
|
|
|
|
|
bus_finish(&b);
|
|
|
|
}
|
2017-01-16 22:54:24 +00:00
|
|
|
*/
|