diff options
| author | lironh | 2020-03-21 09:52:53 +0200 |
|---|---|---|
| committer | lironh | 2020-03-22 21:08:30 +0200 |
| commit | 8934a7566a038a74464d3d8df9d04fd875e5b1d7 (patch) | |
| tree | e131c263938081e6c89f39f141f3f20f6da8f851 /src/cpu/interrupt.spec.ts | |
| parent | Merge pull request #19 from gfeun/main-execute-loop-optimization (diff) | |
| download | avr8js-8934a7566a038a74464d3d8df9d04fd875e5b1d7.tar.gz avr8js-8934a7566a038a74464d3d8df9d04fd875e5b1d7.tar.bz2 avr8js-8934a7566a038a74464d3d8df9d04fd875e5b1d7.zip | |
refactor: added peripherals and cpu feature folders
Diffstat (limited to 'src/cpu/interrupt.spec.ts')
| -rw-r--r-- | src/cpu/interrupt.spec.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cpu/interrupt.spec.ts b/src/cpu/interrupt.spec.ts new file mode 100644 index 0000000..cc54e3c --- /dev/null +++ b/src/cpu/interrupt.spec.ts @@ -0,0 +1,19 @@ +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[94] = 0; + 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 + }); +}); |
