From 1f0ef40d7f7009c6e44b21570f44370eb45ab8d1 Mon Sep 17 00:00:00 2001 From: Steven Schronk Date: Sat, 2 Apr 2011 22:59:55 -0500 Subject: [PATCH] Memory change highlight now works in all cases. Problem occurred when memory at one address was modified more than once, the highlight would disappear. Highlight also never occurred in first memory location. --- TODO | 4 ---- turing_tarpit.html | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 7f3ad81..8cf8d81 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,9 @@ Need method to load/save code for later use. -Memory locations no longer flashing yellow when data is changed more than once. - Bottom line on memory table missing. When in run mode, a SEGFAULT will cause an endless loop. First column of Memory table wider than other columns. -Need better pointer character for data pointer in memory area. - Not displaying HALT message when in run mode. Caused by loop skipping comments. diff --git a/turing_tarpit.html b/turing_tarpit.html index 63630e7..5292702 100644 --- a/turing_tarpit.html +++ b/turing_tarpit.html @@ -93,6 +93,10 @@ function exe_nxt_inst() case '.': print_mem(); break; + case '[': + break; + case ']': + break; default: /* must be a comment :) */ } @@ -176,17 +180,15 @@ function ram_reset() for(i=0; i < 64; i++) { ram[i] = 0; } } -/* update background color of one memory address */ +/* update highlight of one memory address and release other highlight if needed */ function ram_highlight(address) { var disp_last_address = document.getElementById("ram_"+ram_last_address); - if(address%2==0) { /* will reset to original color of _stiped_ table */ - document.getElementById("ram_"+address).style.backgroundColor = "#ff0"; - } else { - document.getElementById("ram_"+address).style.backgroundColor = "#de0"; - } + /* highlight background of current address */ + document.getElementById("ram_"+address).style.backgroundColor = "#ff0"; - if(disp_last_address) { + /* remove highlight from last address modified */ + if(ram_last_address != address){ if(ram_last_address%2==0) { disp_last_address.style.backgroundColor = "#fff"; } else { @@ -232,7 +234,8 @@ function ram_init() disp_ram.innerHTML = table; } -/* modify the value at this address - reset RAM highlights for all addresses +/* + modify the value at this address - reset RAM highlights for all addresses 1 increment RAM by one 0 set RAM to 0 -1 decrement RAM by one @@ -287,13 +290,10 @@ function dat_point_modify(change) function dat_point_highlight() { var dat = document.getElementById("dat_pointer_disp"); - //alert(dat_pointer_last_address+"\t"+dat_pointer); if(dat_pointer_changed) { - //alert("diff"); dat.style.backgroundColor = "#ff0"; dat_pointer_changed = 0; } else { - //alert("same"); dat.style.backgroundColor = "#fff"; } @@ -313,7 +313,7 @@ function dat_point_highlight_clear() /* print ASCII representation of memory at data pointer */ function print_mem() { - var x = String.fromCharCode(ram[dat_pointer]); + var x = String.fromCharCode(63+ram[dat_pointer]); document.getElementById("output_disp").innerHTML += x; } -- 2.11.4.GIT