diff options
| author | Uri Shaked | 2021-09-07 00:42:42 +0300 |
|---|---|---|
| committer | Uri Shaked | 2021-09-07 00:42:42 +0300 |
| commit | 5bc85ec07ac00013de4681cb5d268e4567709be0 (patch) | |
| tree | 7f0dace897c49e1352f974e844c40a8130537b95 /src/cpu/instruction.ts | |
| parent | 0.17.0 (diff) | |
| download | avr8js-5bc85ec07ac00013de4681cb5d268e4567709be0.tar.gz avr8js-5bc85ec07ac00013de4681cb5d268e4567709be0.tar.bz2 avr8js-5bc85ec07ac00013de4681cb5d268e4567709be0.zip | |
fix(gpio): CBI/SBI handling in writes to PIN register #103
fix #103
Diffstat (limited to '')
| -rw-r--r-- | src/cpu/instruction.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cpu/instruction.ts b/src/cpu/instruction.ts index bd9d2a2..c3cdb92 100644 --- a/src/cpu/instruction.ts +++ b/src/cpu/instruction.ts @@ -149,7 +149,8 @@ export function avrInstruction(cpu: ICPU) { const A = opcode & 0xf8; const b = opcode & 7; const R = cpu.readData((A >> 3) + 32); - cpu.writeData((A >> 3) + 32, R & ~(1 << b)); + const mask = 1 << b; + cpu.writeData((A >> 3) + 32, R & ~mask, mask); } else if ((opcode & 0xfe0f) === 0x9400) { /* COM, 1001 010d dddd 0000 */ const d = (opcode & 0x1f0) >> 4; @@ -603,7 +604,8 @@ export function avrInstruction(cpu: ICPU) { } else if ((opcode & 0xff00) === 0x9a00) { /* SBI, 1001 1010 AAAA Abbb */ const target = ((opcode & 0xf8) >> 3) + 32; - cpu.writeData(target, cpu.readData(target) | (1 << (opcode & 7))); + const mask = 1 << (opcode & 7); + cpu.writeData(target, cpu.readData(target) | mask, mask); cpu.cycles++; } else if ((opcode & 0xff00) === 0x9900) { /* SBIC, 1001 1001 AAAA Abbb */ |
