From 88674b7a66cfb831d1c50f1970828944246d3259 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Thu, 21 Nov 2019 10:59:01 +0200 Subject: feat: implement avrInterrupt() used to invoke hardware interrupt --- src/interrupt.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/interrupt.spec.ts (limited to 'src/interrupt.spec.ts') diff --git a/src/interrupt.spec.ts b/src/interrupt.spec.ts new file mode 100644 index 0000000..06979ed --- /dev/null +++ b/src/interrupt.spec.ts @@ -0,0 +1,18 @@ +import { CPU } from './cpu'; +import { avrInterrupt } from './interrupt'; + +describe('avrInterrupt', () => { + it('should execute interrupt handler', () => { + const cpu = new CPU(new Uint16Array(0x8000)); + cpu.pc = 0x520; + cpu.data[93] = 0x80; // SP <- 0x80 + cpu.data[95] = 0b10000001; // SREG <- I------C + avrInterrupt(cpu, 5); + expect(cpu.cycles).toEqual(2); + expect(cpu.pc).toEqual(5); + expect(cpu.data[93]).toEqual(0x7e); // SP + expect(cpu.data[0x80]).toEqual(0x20); // Return addr low + expect(cpu.data[0x7f]).toEqual(0x5); // Return addr high + expect(cpu.data[95]).toEqual(0b00000001); // SREG: -------C + }); +}); -- cgit v1.2.3