summary refs log tree commit diff
path: root/pc-thing/instructions_new/pop.ts
blob: 83ece8803ba17c940e0c2799cf47323814af0a82 (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) == 0) throw 'stack underflow';
        const r1 = this.lib.parseReg(reg1);
        this.registers[r1] = this.getMem(this.getMem(0x7001) + 1);
        this.setMem(0x7001, this.getMem(0x7001) - 1)
    },
    args: 1
}