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

export default {
    function(this: PC, [reg1]: number[]) {
        if (!this.getMem(0x7000)) throw 'no stack pointer';
        if (this.getMem(0x7001) == 256) throw 'stack overflow';
        const r1 = this.lib.parseReg(reg1);
        this.setMem(this.getMem(0x7000) + this.getMem(0x7001), this.registers[r1])
        this.setMem(0x7001, this.getMem(0x7001) + 1)
    },
    args: 1
}