summary refs log tree commit diff
path: root/pc-thing/instructions/swp.ts
blob: 48ee9b6f416b9dd1b232359d0f1d190536b59c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { PC } from "../pc.ts";

export default {
    function(this: PC, [reg1, reg2]: number[]) {
        const r1 = this.lib.parseReg(reg1)
        const r2 = this.lib.parseReg(reg2)
        const data1 = Number(this.registers[r1])
        const data2 = Number(this.registers[r2])
        this.registers[r1] = data2
        this.registers[r2] = data1
    },
    args: 2
}