aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/instruction.ts
diff options
context:
space:
mode:
authorUri Shaked2020-04-09 00:21:02 +0300
committerUri Shaked2020-04-09 00:21:02 +0300
commite662916313092382b18676d594bdbb25b5d31682 (patch)
tree52af769af1af4bf78318c19d7330071de0666159 /src/cpu/instruction.ts
parentfeat(instruction): implement ELPM #31 (diff)
downloadavr8js-e662916313092382b18676d594bdbb25b5d31682.tar.gz
avr8js-e662916313092382b18676d594bdbb25b5d31682.tar.bz2
avr8js-e662916313092382b18676d594bdbb25b5d31682.zip
feat(instruction): implement EICALL, EIJMP #31
Diffstat (limited to '')
-rw-r--r--src/cpu/instruction.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cpu/instruction.ts b/src/cpu/instruction.ts
index e786bf4..07f1576 100644
--- a/src/cpu/instruction.ts
+++ b/src/cpu/instruction.ts
@@ -209,6 +209,21 @@ export function avrInstruction(cpu: ICPU) {
sreg |= 128 === value ? 8 : 0;
sreg |= ((sreg >> 2) & 1) ^ ((sreg >> 3) & 1) ? 0x10 : 0;
cpu.data[95] = sreg;
+ } else if (opcode === 0x9519) {
+ /* EICALL, 1001 0101 0001 1001 */
+ const retAddr = cpu.pc + 1;
+ const sp = cpu.dataView.getUint16(93, true);
+ const eind = cpu.data[0x3c];
+ cpu.data[sp] = retAddr & 255;
+ cpu.data[sp - 1] = (retAddr >> 8) & 255;
+ cpu.dataView.setUint16(93, sp - 2, true);
+ cpu.pc = ((eind << 16) | cpu.dataView.getUint16(30, true)) - 1;
+ cpu.cycles += 3;
+ } else if (opcode === 0x9419) {
+ /* EIJMP, 1001 0100 0001 1001 */
+ const eind = cpu.data[0x3c];
+ cpu.pc = ((eind << 16) | cpu.dataView.getUint16(30, true)) - 1;
+ cpu.cycles++;
} else if (opcode === 0x95d8) {
/* ELPM, 1001 0101 1101 1000 */
const rampz = cpu.data[0x3b];