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.spec.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.spec.ts')
| -rw-r--r-- | src/cpu/instruction.spec.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cpu/instruction.spec.ts b/src/cpu/instruction.spec.ts index 0d0d566..4f6e045 100644 --- a/src/cpu/instruction.spec.ts +++ b/src/cpu/instruction.spec.ts @@ -179,6 +179,29 @@ describe('avrInstruction', () => { expect(cpu.cycles).toEqual(3); }); + it('should execute `EICALL` instruction', () => { + cpu = new CPU(new Uint16Array(0x20000)); + loadProgram('EICALL'); + cpu.data[94] = 0; + cpu.data[93] = 0x80; + cpu.data[0x3c] = 1; // EIND <- 1 + cpu.dataView.setUint16(30, 0x1234, true); // Z <- 0x1234 + avrInstruction(cpu); + expect(cpu.pc).toEqual(0x11234); + expect(cpu.cycles).toEqual(4); + expect(cpu.data[0x80]).toEqual(1); // Return address + }); + + it('should execute `EIJMP` instruction', () => { + cpu = new CPU(new Uint16Array(0x20000)); + loadProgram('EIJMP'); + cpu.data[0x3c] = 1; // EIND <- 1 + cpu.dataView.setUint16(30, 0x1040, true); // Z <- 0x1040 + avrInstruction(cpu); + expect(cpu.pc).toEqual(0x11040); + expect(cpu.cycles).toEqual(2); + }); + it('should execute `ELPM` instruction', () => { cpu = new CPU(new Uint16Array(0x20000)); loadProgram('ELPM'); |
