diff options
| author | Uri Shaked | 2020-04-09 00:21:02 +0300 |
|---|---|---|
| committer | Uri Shaked | 2020-04-09 00:21:02 +0300 |
| commit | e662916313092382b18676d594bdbb25b5d31682 (patch) | |
| tree | 52af769af1af4bf78318c19d7330071de0666159 /src/cpu/instruction.ts | |
| parent | feat(instruction): implement ELPM #31 (diff) | |
| download | avr8js-e662916313092382b18676d594bdbb25b5d31682.tar.gz avr8js-e662916313092382b18676d594bdbb25b5d31682.tar.bz2 avr8js-e662916313092382b18676d594bdbb25b5d31682.zip | |
feat(instruction): implement EICALL, EIJMP #31
Diffstat (limited to 'src/cpu/instruction.ts')
| -rw-r--r-- | src/cpu/instruction.ts | 15 |
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]; |
