diff options
| author | Uri Shaked | 2020-09-02 15:37:34 +0300 |
|---|---|---|
| committer | Uri Shaked | 2020-09-02 15:37:34 +0300 |
| commit | 09f2385282b0c98a3fdc4b89091d0c62b61725f5 (patch) | |
| tree | c5e25b45fc7aad682cb0d8fcbe8af712767b8500 /src/cpu/interrupt.spec.ts | |
| parent | fix(instruction): EICALL is broken (diff) | |
| download | avr8js-09f2385282b0c98a3fdc4b89091d0c62b61725f5.tar.gz avr8js-09f2385282b0c98a3fdc4b89091d0c62b61725f5.tar.bz2 avr8js-09f2385282b0c98a3fdc4b89091d0c62b61725f5.zip | |
fix(interrupt): broken on ATmega2560
close #58
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 index cc54e3c..c64724d 100644 --- a/src/cpu/interrupt.spec.ts +++ b/src/cpu/interrupt.spec.ts @@ -16,4 +16,23 @@ describe('avrInterrupt', () => { expect(cpu.data[0x7f]).toEqual(0x5); // Return addr high expect(cpu.data[95]).toEqual(0b00000001); // SREG: -------C }); + + it('should push a 3-byte return address when running in 22-bit PC mode (issue #58)', () => { + const cpu = new CPU(new Uint16Array(0x80000)); + expect(cpu.pc22Bits).toEqual(true); + + cpu.pc = 0x10520; + 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(0x7d); // SP should decrement by 3 + expect(cpu.data[0x80]).toEqual(0x20); // Return addr low + expect(cpu.data[0x7f]).toEqual(0x05); // Return addr high + expect(cpu.data[0x7e]).toEqual(0x1); // Return addr extended + expect(cpu.data[95]).toEqual(0b00000001); // SREG: -------C + }); }); |
