From 1027b91f357eaaa4793b9d16673b0ab662b37c7e Mon Sep 17 00:00:00 2001 From: WlodekM Date: Wed, 2 Apr 2025 12:23:56 +0300 Subject: remove pc thing --- pc-thing/instructions_new/add.ts | 12 -------- pc-thing/instructions_new/and.ts | 11 ------- pc-thing/instructions_new/cmp.ts | 10 ------- pc-thing/instructions_new/cmr.ts | 11 ------- pc-thing/instructions_new/div.ts | 12 -------- pc-thing/instructions_new/halt.ts | 9 ------ pc-thing/instructions_new/jmp.ts | 9 ------ pc-thing/instructions_new/jmr.ts | 10 ------- pc-thing/instructions_new/jnz.ts | 10 ------- pc-thing/instructions_new/jz.ts | 10 ------- pc-thing/instructions_new/ld.ts | 11 ------- pc-thing/instructions_new/mod.ts | 12 -------- pc-thing/instructions_new/mov.ts | 9 ------ pc-thing/instructions_new/mul.ts | 12 -------- pc-thing/instructions_new/not.ts | 11 ------- pc-thing/instructions_new/or.ts | 12 -------- pc-thing/instructions_new/pop.ts | 12 -------- pc-thing/instructions_new/push.ts | 12 -------- pc-thing/instructions_new/ret.ts | 10 ------- pc-thing/instructions_new/shl.ts | 11 ------- pc-thing/instructions_new/shr.ts | 11 ------- pc-thing/instructions_new/str.ts | 10 ------- pc-thing/instructions_new/sub.ts | 12 -------- pc-thing/instructions_new/swp.ts | 15 ---------- pc-thing/instructions_new/sys.ts | 60 --------------------------------------- pc-thing/instructions_new/xor.ts | 12 -------- 26 files changed, 336 deletions(-) delete mode 100644 pc-thing/instructions_new/add.ts delete mode 100644 pc-thing/instructions_new/and.ts delete mode 100644 pc-thing/instructions_new/cmp.ts delete mode 100644 pc-thing/instructions_new/cmr.ts delete mode 100644 pc-thing/instructions_new/div.ts delete mode 100644 pc-thing/instructions_new/halt.ts delete mode 100644 pc-thing/instructions_new/jmp.ts delete mode 100644 pc-thing/instructions_new/jmr.ts delete mode 100644 pc-thing/instructions_new/jnz.ts delete mode 100644 pc-thing/instructions_new/jz.ts delete mode 100644 pc-thing/instructions_new/ld.ts delete mode 100644 pc-thing/instructions_new/mod.ts delete mode 100644 pc-thing/instructions_new/mov.ts delete mode 100644 pc-thing/instructions_new/mul.ts delete mode 100644 pc-thing/instructions_new/not.ts delete mode 100644 pc-thing/instructions_new/or.ts delete mode 100644 pc-thing/instructions_new/pop.ts delete mode 100644 pc-thing/instructions_new/push.ts delete mode 100644 pc-thing/instructions_new/ret.ts delete mode 100644 pc-thing/instructions_new/shl.ts delete mode 100644 pc-thing/instructions_new/shr.ts delete mode 100644 pc-thing/instructions_new/str.ts delete mode 100644 pc-thing/instructions_new/sub.ts delete mode 100644 pc-thing/instructions_new/swp.ts delete mode 100644 pc-thing/instructions_new/sys.ts delete mode 100644 pc-thing/instructions_new/xor.ts (limited to 'pc-thing/instructions_new') diff --git a/pc-thing/instructions_new/add.ts b/pc-thing/instructions_new/add.ts deleted file mode 100644 index 5d211d3..0000000 --- a/pc-thing/instructions_new/add.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] + this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] + this.registers[r3] - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/and.ts b/pc-thing/instructions_new/and.ts deleted file mode 100644 index 12db601..0000000 --- a/pc-thing/instructions_new/and.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.registers[r1] = this.registers[r2] & this.registers[r3]; - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/cmp.ts b/pc-thing/instructions_new/cmp.ts deleted file mode 100644 index f97322a..0000000 --- a/pc-thing/instructions_new/cmp.ts +++ /dev/null @@ -1,10 +0,0 @@ -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); - this.returnFlag = +(this.registers[r1] == this.registers[r2]); - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/cmr.ts b/pc-thing/instructions_new/cmr.ts deleted file mode 100644 index a83b46c..0000000 --- a/pc-thing/instructions_new/cmr.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.registers[r1] = +(this.registers[r2] == this.registers[r3]); - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/div.ts b/pc-thing/instructions_new/div.ts deleted file mode 100644 index c78cd93..0000000 --- a/pc-thing/instructions_new/div.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] / this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] / this.registers[r3] - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/halt.ts b/pc-thing/instructions_new/halt.ts deleted file mode 100644 index 4685f2b..0000000 --- a/pc-thing/instructions_new/halt.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC) { - // this.programPointer = 0xFFFF - 1 - this.halted = true - }, - args: 0 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/jmp.ts b/pc-thing/instructions_new/jmp.ts deleted file mode 100644 index f3bbc79..0000000 --- a/pc-thing/instructions_new/jmp.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1]: number[]) { - const r1 = this.lib.parseReg(reg1); - this.programPointer = this.registers[r1] - }, - args: 1 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/jmr.ts b/pc-thing/instructions_new/jmr.ts deleted file mode 100644 index f7b0c00..0000000 --- a/pc-thing/instructions_new/jmr.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1]: number[]) { - const r1 = this.lib.parseReg(reg1); - this.returnStack.push(this.programPointer); - this.programPointer = this.registers[r1]; - }, - args: 1 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/jnz.ts b/pc-thing/instructions_new/jnz.ts deleted file mode 100644 index d600f59..0000000 --- a/pc-thing/instructions_new/jnz.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1]: number[]) { - if (this.returnFlag == 0) return; - const r1 = this.lib.parseReg(reg1); - this.programPointer = this.registers[r1] - }, - args: 1 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/jz.ts b/pc-thing/instructions_new/jz.ts deleted file mode 100644 index 0d4f64c..0000000 --- a/pc-thing/instructions_new/jz.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1]: number[]) { - if (this.returnFlag != 0) return; - const r1 = this.lib.parseReg(reg1); - this.programPointer = this.registers[r1] - }, - args: 1 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/ld.ts b/pc-thing/instructions_new/ld.ts deleted file mode 100644 index 8d6c30d..0000000 --- a/pc-thing/instructions_new/ld.ts +++ /dev/null @@ -1,11 +0,0 @@ -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); - this.returnFlag = +(this.getMem(this.registers[r2]) != 0); - this.registers[r1] = this.getMem(this.registers[r2]) - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/mod.ts b/pc-thing/instructions_new/mod.ts deleted file mode 100644 index 8f1a343..0000000 --- a/pc-thing/instructions_new/mod.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] % this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] % this.registers[r3] - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/mov.ts b/pc-thing/instructions_new/mov.ts deleted file mode 100644 index a35806e..0000000 --- a/pc-thing/instructions_new/mov.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg, data]: number[]) { - const r = this.lib.parseReg(reg) - this.registers[r] = Number(data) ?? 0 - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/mul.ts b/pc-thing/instructions_new/mul.ts deleted file mode 100644 index bf3f12c..0000000 --- a/pc-thing/instructions_new/mul.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] * this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] * this.registers[r3] - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/not.ts b/pc-thing/instructions_new/not.ts deleted file mode 100644 index 241897a..0000000 --- a/pc-thing/instructions_new/not.ts +++ /dev/null @@ -1,11 +0,0 @@ -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); - this.returnFlag = +((~this.registers[r1]) != 0); - this.registers[r1] = ~this.registers[r2]; - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/or.ts b/pc-thing/instructions_new/or.ts deleted file mode 100644 index bd7cc7e..0000000 --- a/pc-thing/instructions_new/or.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] | this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] | this.registers[r3]; - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/pop.ts b/pc-thing/instructions_new/pop.ts deleted file mode 100644 index 83ece88..0000000 --- a/pc-thing/instructions_new/pop.ts +++ /dev/null @@ -1,12 +0,0 @@ -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 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/push.ts b/pc-thing/instructions_new/push.ts deleted file mode 100644 index b9dd718..0000000 --- a/pc-thing/instructions_new/push.ts +++ /dev/null @@ -1,12 +0,0 @@ -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 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/ret.ts b/pc-thing/instructions_new/ret.ts deleted file mode 100644 index 04b5cc3..0000000 --- a/pc-thing/instructions_new/ret.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC) { - const returnAddr = this.returnStack.pop(); - if (!returnAddr) throw 'return stack empty'; - this.programPointer = returnAddr; - }, - args: 1 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/shl.ts b/pc-thing/instructions_new/shl.ts deleted file mode 100644 index 16bb382..0000000 --- a/pc-thing/instructions_new/shl.ts +++ /dev/null @@ -1,11 +0,0 @@ -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); - this.returnFlag = +((this.registers[r1] << this.registers[r2]) != 0); - this.registers[r1] <<= this.registers[r2] - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/shr.ts b/pc-thing/instructions_new/shr.ts deleted file mode 100644 index 09bf005..0000000 --- a/pc-thing/instructions_new/shr.ts +++ /dev/null @@ -1,11 +0,0 @@ -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); - this.returnFlag = +((this.registers[r1] >> this.registers[r2]) != 0); - this.registers[r1] >>= this.registers[r2] - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/str.ts b/pc-thing/instructions_new/str.ts deleted file mode 100644 index aa4c2d5..0000000 --- a/pc-thing/instructions_new/str.ts +++ /dev/null @@ -1,10 +0,0 @@ -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); - this.setMem(this.registers[r1], this.registers[r2]); - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/sub.ts b/pc-thing/instructions_new/sub.ts deleted file mode 100644 index c7b4e94..0000000 --- a/pc-thing/instructions_new/sub.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] - this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] - this.registers[r3] - }, - args: 3 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/swp.ts b/pc-thing/instructions_new/swp.ts deleted file mode 100644 index 7d07aea..0000000 --- a/pc-thing/instructions_new/swp.ts +++ /dev/null @@ -1,15 +0,0 @@ -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); - [this.registers[r1], this.registers[r2]] = - [this.registers[r2], this.registers[r1]] - // const data1 = Number(this.registers[r1]) - // const data2 = Number(this.registers[r2]) - // this.registers[r1] = data2 - // this.registers[r2] = data1 - }, - args: 2 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/sys.ts b/pc-thing/instructions_new/sys.ts deleted file mode 100644 index fc27af9..0000000 --- a/pc-thing/instructions_new/sys.ts +++ /dev/null @@ -1,60 +0,0 @@ -// deno-lint-ignore-file no-case-declarations no-process-globals -import { PC } from "../pc.ts"; - -declare global { - const process: any; -} - -export default { - function(this: PC) { - if (typeof process == 'undefined') throw 'process global is undefined'; - switch (this.registers[0]) { - case 0: - switch (this.registers[1]) { - case 0: - const data = new Uint8Array(1024) - const len = Deno.stdin.readSync(data) ?? 0 - let i = 0; - while (i < len) { - this.mem[this.registers[2] + i] = data[i] - i++ - } - this.registers[0] = len - this.mem[this.registers[2] + i] = 0 - break; - - default: - throw 'unknown fd' - } - break; - case 1: - const writeBuff = []; - let i = this.registers[2]; - while (this.mem[i] != 0 && i <= this.mem.length) { - writeBuff.push(this.mem[i]); - i++ - } - switch (this.registers[1]) { - case 1: - process.stdout.write(writeBuff.map(a => String.fromCharCode(a)).join('')) - break; - - case 2: - process.stderr.write(writeBuff.map(a => String.fromCharCode(a)).join('')) - break; - - default: - throw 'unknown fd' - } - break; - - case 2: - Deno.stdin.setRaw(this.registers[1] ? true : false); - break; - - default: - throw 'unknown syscall id ' + this.registers[0] - } - }, - args: 0 -} \ No newline at end of file diff --git a/pc-thing/instructions_new/xor.ts b/pc-thing/instructions_new/xor.ts deleted file mode 100644 index 135e1cf..0000000 --- a/pc-thing/instructions_new/xor.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { PC } from "../pc.ts"; - -export default { - function(this: PC, [reg1, reg2, reg3]: number[]) { - const r1 = this.lib.parseReg(reg1); - const r2 = this.lib.parseReg(reg2); - const r3 = this.lib.parseReg(reg3); - this.returnFlag = +((this.registers[r2] ^ this.registers[r3]) != 0); - this.registers[r1] = this.registers[r2] ^ this.registers[r3]; - }, - args: 3 -} \ No newline at end of file -- cgit 1.4.1-2-gfad0