blob: 1bfa035c9c602750c054e73bfb3c15a6f2a6d2b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/**
* AVR-8 Interrupt Handling
* Part of AVR8js
* Reference: http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf
*
* Copyright (C) 2019, Uri Shaked
*/
import { ICPU } from './cpu';
export function avrInterrupt(cpu: ICPU, addr: number) {
const sp = cpu.dataView.getUint16(93, true);
cpu.data[sp] = cpu.pc & 0xff;
cpu.data[sp - 1] = (cpu.pc >> 8) & 0xff;
if (cpu.pc22Bits) {
cpu.data[sp - 2] = (cpu.pc >> 16) & 0xff;
}
cpu.dataView.setUint16(93, sp - (cpu.pc22Bits ? 3 : 2), true);
cpu.data[95] &= 0x7f; // clear global interrupt flag
cpu.cycles += 2;
cpu.pc = addr;
}
|