-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
45 lines (36 loc) · 777 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const fs = require('fs');
const buff = fs.readFileSync('buff.txt').toString();
const instrs = [
'dey',
'*',
'dey',
'dey',
'dey'
];
const instrs1 = [
'sta',
'sta',
'sta',
'sta',
'lda',
'sta'
];
const extractInstruction = row =>
row.trim().split(' ')[0];
let it = 0;
const rows = buff.split('\n');
for (let i = 0; i < rows.length; i++) {
let j = 0;
for (; j < instrs.length; j++) {
const instr = extractInstruction(rows[i + j]);
if (instrs[j] !== '*' && instr !== instrs[j]) {
break;
}
}
if (j === instrs.length) {
for (let j = i - 2 * instrs.length; j < i + instrs.length; j++) {
console.log(rows[j]);
}
console.log('\n\n');
}
}