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.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.ts')
| -rw-r--r-- | src/cpu/interrupt.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cpu/interrupt.ts b/src/cpu/interrupt.ts new file mode 100644 index 0000000..1c7d835 --- /dev/null +++ b/src/cpu/interrupt.ts @@ -0,0 +1,19 @@ +/** + * 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; + cpu.dataView.setUint16(93, sp - 2, true); + cpu.data[95] &= 0x7f; // clear global interrupt flag + cpu.cycles += 2; + cpu.pc = addr; +} |
