Browse Source

Sol Part 63.1: A Memory-Sipping 5 Leaks per Instruction!

dsl/ now contains some bugfixes by cmr--thanks!
Graham Northup 3 years ago
parent
commit
28fc1cad1e
Signed by: Graham Northup <grissess@nexusg.org> GPG Key ID: 5D000E6F539376FB
2 changed files with 6 additions and 5 deletions
  1. 1
    1
      dsl
  2. 5
    4
      programs/chip8.sol

+ 1
- 1
dsl

@@ -1 +1 @@
1
-Subproject commit aff43d13d92bc83038bf675afbcaf5304be5acf5
1
+Subproject commit 676992dfb6c6577be509dbd9726a8798a31c2929

+ 5
- 4
programs/chip8.sol View File

@@ -160,7 +160,7 @@ func new_state()
160 160
 		disp = new_disp(),
161 161
 		sys = new_sys(),
162 162
 		jumped = false,
163
-		trace = false,
163
+		trace = {},
164 164
 		jump = func(self, ip)
165 165
 			self.reg.IP = ip
166 166
 			self.jumped = true
@@ -308,7 +308,7 @@ insns = {
308 308
 	[13] = func insn13(state, ins)
309 309
 		x = state.reg.V[ins.nib[1]]
310 310
 		y = state.reg.V[ins.nib[2]]
311
-		n = ins.nib[2]
311
+		n = ins.nib[3]
312 312
 		i = state.reg.I
313 313
 		c = 0
314 314
 		for idx in range(n) do
@@ -319,6 +319,7 @@ insns = {
319 319
 			y += 1
320 320
 		end
321 321
 		state.reg.V[15] = c
322
+		if None != state.trace.draw then state:log(disas(state, ins) + '  ;; Drew sprite at ' + tostring(state.reg.I) + ' - ' + tostring(i) + ' to x=' + tostring(x) + ', y=' + tostring(state.reg.V[ins.nib[2]]) + '-' + y + ' in ' + tostring(n) + ' steps, changed=' + tostring(c)) end
322 323
 	end,
323 324
 	[14] = func insn14(state, ins)
324 325
 		if ins.byte.low == 158 then
@@ -509,7 +510,7 @@ disas = {
509 510
 		return bad_disas(state, ins)
510 511
 	end,
511 512
 	__call = func(self, state, ins)
512
-		return self[ins.nib[0]](state, ins)
513
+		return (for n in ins.nib do continue hex2chr_t[n] end):reduce(lambda(x, y) x + y end, '') + ': ' + (self[ins.nib[0]](state, ins))
513 514
 	end,
514 515
 }
515 516
 
@@ -533,7 +534,7 @@ func step_cpu(state, force)
533 534
 			end
534 535
 		end
535 536
 	end
536
-	if state.trace then state:log((for n in ins.nib do continue hex2chr_t[n] end):reduce(lambda(x, y) x + y end, '') + ': ' + disas(state, ins) + '  ;; ' + descr_state(state)) end
537
+	if None != state.trace.all then state:log(disas(state, ins) + '  ;; ' + descr_state(state)) end
537 538
 	insns[ins.nib[0]](state, ins)
538 539
 	if !(state.jumped) then
539 540
 		state.reg.IP += 2

Loading…
Cancel
Save