|
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
20
|
20
|
'parse': parse
|
|
21
|
21
|
}
|
|
22
|
22
|
|
|
23
|
|
-},{"./encoders.js":3}],2:[function(require,module,exports){
|
|
|
23
|
+},{"./encoders.js":4}],2:[function(require,module,exports){
|
|
24
|
24
|
// put some stuff into memory
|
|
25
|
25
|
const memory = require('../memory/memory.js')
|
|
26
|
26
|
const utils = require('./utils.js')
|
|
|
@@ -32,17 +32,38 @@ const padAddress = (addr, len, ch) => (addr.length >= len) ?
|
|
32
|
32
|
const incrAddr = (addr, n) => padAddress((parseInt(addr, 2) + n).toString(2), 32, '0')
|
|
33
|
33
|
|
|
34
|
34
|
const baseAddr = '0xbfc00000'
|
|
35
|
|
-const loadBootCode = (code) => code.map((c, i) => memory.storeWord(incrAddr(utils.hex2bin(baseAddr, 32), i*4), utils.hex2bin(c, 32)))
|
|
|
35
|
+const loadBootCode = (code) => {
|
|
|
36
|
+ memory.clearMemory()
|
|
|
37
|
+ code.map((c, i) => memory.storeWord(incrAddr(utils.hex2bin(baseAddr, 32), i*4), utils.hex2bin(c, 32)))
|
|
|
38
|
+}
|
|
36
|
39
|
|
|
37
|
40
|
module.exports = {
|
|
38
|
41
|
'loadBootCode': loadBootCode
|
|
39
|
42
|
}
|
|
40
|
43
|
|
|
41
|
44
|
},{"../memory/memory.js":6,"./utils.js":5}],3:[function(require,module,exports){
|
|
|
45
|
+// This file should hold the DOM interaction code
|
|
|
46
|
+let hex = ''
|
|
|
47
|
+const assembler = require('./assembler.js')
|
|
|
48
|
+const bootloader = require('./bootload.js')
|
|
|
49
|
+
|
|
|
50
|
+const assembleButton = document.getElementById('assemble')
|
|
|
51
|
+const assembleButtonHandler = event => {
|
|
|
52
|
+ const code = document.getElementById('code')
|
|
|
53
|
+ const rawCode = code.value
|
|
|
54
|
+ hex = assembler.parse(assembler.lines(rawCode))
|
|
|
55
|
+ bootloader.loadBootCode(hex)
|
|
|
56
|
+ console.log(hex.join('\n'))
|
|
|
57
|
+}
|
|
|
58
|
+
|
|
|
59
|
+
|
|
|
60
|
+assembleButton.addEventListener('click', assembleButtonHandler)
|
|
|
61
|
+
|
|
|
62
|
+},{"./assembler.js":1,"./bootload.js":2}],4:[function(require,module,exports){
|
|
42
|
63
|
const utils = require('./utils.js')
|
|
43
|
64
|
|
|
44
|
65
|
const regmap = [
|
|
45
|
|
- 'zero', 'at', 'v0', 'v1', 'a0', 'a1', 'a2', 't0', 't1', 't2', 't3', 't4', 't5',
|
|
|
66
|
+ 'zero', 'at', 'v0', 'v1', 'a0', 'a1', 'a2', 'a3', 't0', 't1', 't2', 't3', 't4', 't5',
|
|
46
|
67
|
't6', 't7', 's0', 's1', 's2', 's3', 's4', 's5', 's6', 's7', 't8', 't9', 'k0',
|
|
47
|
68
|
'k1', 'gp', 'sp', 's8', 'ra' ]
|
|
48
|
69
|
|
|
|
@@ -82,25 +103,7 @@ const encoders = {
|
|
82
|
103
|
|
|
83
|
104
|
module.exports = encoders
|
|
84
|
105
|
|
|
85
|
|
-},{"./utils.js":5}],4:[function(require,module,exports){
|
|
86
|
|
-// This file should hold the DOM interaction code
|
|
87
|
|
-let hex = ''
|
|
88
|
|
-const assembler = require('./assembler.js')
|
|
89
|
|
-const bootloader = require('./bootload.js')
|
|
90
|
|
-
|
|
91
|
|
-const assembleButton = document.getElementById('assemble')
|
|
92
|
|
-const assembleButtonHandler = event => {
|
|
93
|
|
- const code = document.getElementById('code')
|
|
94
|
|
- const rawCode = code.value
|
|
95
|
|
- hex = assembler.parse(assembler.lines(rawCode))
|
|
96
|
|
- bootloader.loadBootCode(hex)
|
|
97
|
|
- console.log(hex.join('\n'))
|
|
98
|
|
-}
|
|
99
|
|
-
|
|
100
|
|
-
|
|
101
|
|
-assembleButton.addEventListener('click', assembleButtonHandler)
|
|
102
|
|
-
|
|
103
|
|
-},{"./assembler.js":1,"./bootload.js":2}],5:[function(require,module,exports){
|
|
|
106
|
+},{"./utils.js":5}],5:[function(require,module,exports){
|
|
104
|
107
|
const error = (error) => console.error(error)
|
|
105
|
108
|
|
|
106
|
109
|
const dec2binu = (dec, length) => {
|
|
|
@@ -155,7 +158,7 @@ module.exports = {
|
|
155
|
158
|
// will not be filling up the array and therefore will not be using much RAM, however if
|
|
156
|
159
|
// the full 4gb of memory are used, then it might prove problematic, and I will likely
|
|
157
|
160
|
// move to a server side memory model that persists most data to disk
|
|
158
|
|
-const mainMemory = {}
|
|
|
161
|
+let mainMemory = {}
|
|
159
|
162
|
|
|
160
|
163
|
// Pads a string with 0's until it is the desired length
|
|
161
|
164
|
const padAddress = (addr, len, ch) => (addr.length >= len) ?
|
|
|
@@ -188,7 +191,6 @@ const storeByte = (addr, data) => {
|
|
188
|
191
|
|
|
189
|
192
|
// Stores two bytes in memory array, with the lower bytes in the lower addresses
|
|
190
|
193
|
const storeHalfWord = (addr, data) => {
|
|
191
|
|
- console.log(addr)
|
|
192
|
194
|
if (data.length == 16) {
|
|
193
|
195
|
if (addr.slice(-1) === '0') {
|
|
194
|
196
|
storeByte(addr, data.slice(8))
|
|
|
@@ -214,7 +216,8 @@ module.exports = {
|
|
214
|
216
|
storeHalfWord, storeHalfWord,
|
|
215
|
217
|
loadByte: loadByte,
|
|
216
|
218
|
loadHalfWord: loadHalfWord,
|
|
217
|
|
- loadWord: loadWord
|
|
|
219
|
+ loadWord: loadWord,
|
|
|
220
|
+ clearMemory: () => mainMemory = {}
|
|
218
|
221
|
}
|
|
219
|
222
|
|
|
220
|
|
-},{}]},{},[4]);
|
|
|
223
|
+},{}]},{},[3]);
|