1
0
mirror of https://github.com/mre/mos6502.git synced 2024-12-23 03:29:51 +00:00

Integrate IRQ.

This commit is contained in:
Andrew Keeton 2014-09-28 21:06:12 -04:00
parent f7cf02fb9e
commit 203bfa6244
2 changed files with 31 additions and 28 deletions

View File

@ -29,10 +29,13 @@ use address::Address;
use address::AddressDiff;
use registers::StackPointer;
pub static MEMORY_ADDRESS_BEGIN: Address = Address(0x0000);
pub static MEMORY_ADDRESS_END: Address = Address(0xffff);
pub static STACK_ADDRESS_BEGIN: Address = Address(0x0100);
pub static STACK_ADDRESS_END: Address = Address(0x01ff);
pub static MEMORY_ADDRESS_BEGIN: Address = Address(0x0000);
pub static MEMORY_ADDRESS_END: Address = Address(0xFFFF);
pub static STACK_ADDRESS_BEGIN: Address = Address(0x0100);
pub static STACK_ADDRESS_END: Address = Address(0x01FF);
pub static IRQ_INTERRUPT_VECTOR_LO: Address = Address(0xFFFE);
pub static IRQ_INTERRUPT_VECTOR_HI: Address = Address(0xFFFF);
// static MEMORY_SIZE: uint = MEMORY_ADDRESS_END - MEMORY_ADDRESS_BEGIN + 1;
pub struct Memory {

View File

@ -29,39 +29,39 @@ use memory::STACK_ADDRESS_END;
use util::{ BitFlag, Off, On };
pub struct Status {
pub carry: BitFlag,
pub zero: BitFlag,
pub interrupt: BitFlag,
pub decimal_mode: BitFlag,
pub brk: BitFlag,
pub unused: BitFlag,
pub overflow: BitFlag,
pub negative: BitFlag
pub carry: BitFlag,
pub zero: BitFlag,
pub disable_interrupts: BitFlag,
pub decimal_mode: BitFlag,
pub brk: BitFlag,
pub unused: BitFlag,
pub overflow: BitFlag,
pub negative: BitFlag
}
impl Status {
pub fn to_byte(&self) -> u8 {
self.carry.to_bit() << 0
| self.zero.to_bit() << 1
| self.interrupt.to_bit() << 2
| self.decimal_mode.to_bit() << 3
| self.brk.to_bit() << 4
| self.unused.to_bit() << 5
| self.overflow.to_bit() << 6
| self.negative.to_bit() << 7
self.carry.to_bit() << 0
| self.zero.to_bit() << 1
| self.disable_interrupts.to_bit() << 2
| self.decimal_mode.to_bit() << 3
| self.brk.to_bit() << 4
| self.unused.to_bit() << 5
| self.overflow.to_bit() << 6
| self.negative.to_bit() << 7
}
pub fn new() -> Status {
// TODO akeeton: Revisit these defaults.
Status {
carry: Off,
zero: Off,
interrupt: Off,
decimal_mode: Off,
brk: Off,
unused: On,
overflow: Off,
negative: Off
carry: Off,
zero: Off,
disable_interrupts: On,
decimal_mode: Off,
brk: Off,
unused: On,
overflow: Off,
negative: Off
}
}
}