-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdpFunc.js
More file actions
71 lines (60 loc) · 1.36 KB
/
pdpFunc.js
File metadata and controls
71 lines (60 loc) · 1.36 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const ProgramCounter = require('./fnc/ProgramCounter.js')
const PDP = require('./fnc/PDP.js')
const start = (begining = false) => {
if(begining){
PDP.PDP.isOn = true
PDP.PDP.isStop = false
}
return PDP.PDP.start()
}
const loadAdd = (swch) => {
let value = 0
let mul = 1
for(let index = 17 ; index >= 6 ; index--){
value += swch[index] * mul
mul *= 2
}
ProgramCounter.load(value)
}
const deposit = (swch) => {
const address = ProgramCounter.get()
PDP.PDP.setAR(address)
let value = 0
let mul = 1
for(let index = 17 ; index >= 2 ; index--){
value += swch[index] * mul
mul *= 2
}
PDP.PDP.setDR(value)
PDP.PDP.setMem(address , value)
ProgramCounter.increment()
}
const examinate = () => {
const address = ProgramCounter.get()
PDP.PDP.setAR(address)
const memValue = PDP.PDP.getMem(address)
PDP.PDP.setDR(memValue)
ProgramCounter.increment()
}
const continueSw = () => {
PDP.PDP.isStop = false
PDP.PDP.start()
}
const stop = () => {
PDP.PDP.isStop = true
}
const singStep = () => {}
const singInst = () => {
if(PDP.PDP.singInst) PDP.PDP.singInst = false
else PDP.PDP.singInst = true
}
module.exports = {
start,
loadAdd,
deposit,
examinate,
continueSw,
stop,
singStep,
singInst,
}