aboutsummaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorUri Shaked2021-09-10 21:16:34 +0300
committerUri Shaked2021-09-10 21:16:34 +0300
commit96a6dba4371a2e319a47335b2bf366b695b6c17a (patch)
tree1664c852cc86826a9fd6795a6512c6d8fa92a686 /benchmark
parentfeat(adc): ADC peripheral #13 (diff)
downloadavr8js-96a6dba4371a2e319a47335b2bf366b695b6c17a.tar.gz
avr8js-96a6dba4371a2e319a47335b2bf366b695b6c17a.tar.bz2
avr8js-96a6dba4371a2e319a47335b2bf366b695b6c17a.zip
refactor: remove the ICPU interface
Removing the interface simplifies the code
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/convert-instructions.ts6
-rw-r--r--benchmark/index.ts4
2 files changed, 5 insertions, 5 deletions
diff --git a/benchmark/convert-instructions.ts b/benchmark/convert-instructions.ts
index edde3cc..6ae0c24 100644
--- a/benchmark/convert-instructions.ts
+++ b/benchmark/convert-instructions.ts
@@ -8,7 +8,7 @@ let fnBody = '';
let currentInstruction = '';
let pattern = '';
let output = `
-import { ICPU } from '../src/cpu/cpu';
+import { CPU } from '../src/cpu/cpu';
function isTwoWordInstruction(opcode: number) {
return (
@@ -36,7 +36,7 @@ for (const line of input.split('\n')) {
patternToFn.push([pattern.trim(), fnName]);
} else if (line.startsWith(' }')) {
output += `
- export function ${fnName}(cpu: ICPU, opcode: number) {
+ export function ${fnName}(cpu: CPU, opcode: number) {
/*${pattern}*/
${fnBody}
cpu.cycles++;
@@ -62,7 +62,7 @@ for (const [fnPattern, fn] of patternToFn) {
output += ']';
output += `\n
-export function executeInstruction(idx: number, cpu: ICPU, opcode: number) {
+export function executeInstruction(idx: number, cpu: CPU, opcode: number) {
switch (idx) {
${executeInstructionCases}
default: instNOP(cpu, opcode);
diff --git a/benchmark/index.ts b/benchmark/index.ts
index e290352..a1ee7e7 100644
--- a/benchmark/index.ts
+++ b/benchmark/index.ts
@@ -1,4 +1,4 @@
-import { CPU, ICPU } from '../src/cpu/cpu';
+import { CPU } from '../src/cpu/cpu';
import { avrInstruction } from '../src/cpu/instruction';
import { createBenchmark } from './benchmark';
import { permutations } from './permutations';
@@ -21,7 +21,7 @@ function avrInstructionUintArray(cpu: CPU) {
}
/* Approach 2: use instMap */
-const instructionMap: { [key: number]: (cpu: ICPU, opcode: number) => void } = {};
+const instructionMap: { [key: number]: (cpu: CPU, opcode: number) => void } = {};
for (const { pattern, fn } of instructions) {
for (const opcode of permutations(pattern.replace(/ /g, '').substr(0, 16))) {
if (!instructionMap[opcode]) {
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.