diff options
| author | Uri Shaked | 2019-11-20 18:39:23 +0200 |
|---|---|---|
| committer | Uri Shaked | 2019-11-20 18:39:23 +0200 |
| commit | 38d30d7de805fd25dd1fd130007868c53041a3de (patch) | |
| tree | 154b168a2d03895c52dcc6bd85bb6c7be5d8feec /src/instruction.ts | |
| parent | chore: rimraf dist before build (diff) | |
| download | avr8js-38d30d7de805fd25dd1fd130007868c53041a3de.tar.gz avr8js-38d30d7de805fd25dd1fd130007868c53041a3de.tar.bz2 avr8js-38d30d7de805fd25dd1fd130007868c53041a3de.zip | |
feat: LAC, LAS, LAT, LDS instructions + tests
Diffstat (limited to '')
| -rw-r--r-- | src/instruction.ts | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/instruction.ts b/src/instruction.ts index dbb23e7..fe64f10 100644 --- a/src/instruction.ts +++ b/src/instruction.ts @@ -258,17 +258,28 @@ export function avrInstruction(cpu: ICPU) { /* LAC, 1001 001r rrrr 0110 */ if ((opcode & 0xfe0f) === 0x9206) { - /* not implemented */ + const r = (opcode & 0x1f0) >> 4; + const clear = cpu.data[r]; + const value = cpu.readData(cpu.dataView.getUint16(30, true)); + cpu.writeData(cpu.dataView.getUint16(30, true), value & (255 - clear)); + cpu.data[r] = value; } /* LAS, 1001 001r rrrr 0101 */ if ((opcode & 0xfe0f) === 0x9205) { - /* not implemented */ + const r = (opcode & 0x1f0) >> 4; + const set = cpu.data[r]; + const value = cpu.readData(cpu.dataView.getUint16(30, true)); + cpu.writeData(cpu.dataView.getUint16(30, true), value | set); + cpu.data[r] = value; } /* LAT, 1001 001r rrrr 0111 */ if ((opcode & 0xfe0f) === 0x9207) { - /* not implemented */ + const r = cpu.data[(opcode & 0x1f0) >> 4]; + const R = cpu.readData(cpu.dataView.getUint16(30, true)); + cpu.writeData(cpu.dataView.getUint16(30, true), r ^ R); + cpu.data[(opcode & 0x1f0) >> 4] = R; } /* LDI, 1110 KKKK dddd KKKK */ @@ -278,7 +289,10 @@ export function avrInstruction(cpu: ICPU) { /* LDS, 1001 000d dddd 0000 kkkk kkkk kkkk kkkk */ if ((opcode & 0xfe0f) === 0x9000) { - /* not implemented */ + const value = cpu.readData(cpu.progMem[cpu.pc + 1]); + cpu.data[(opcode & 0x1f0) >> 4] = value; + cpu.pc++; + cpu.cycles++; } /* LDX, 1001 000d dddd 1100 */ |
