package de.czempin.nicnac16;

public class Processor {
	int mem[] = new int[65636];
	public int PC;
	public int AC;

	public int readMemory(int address) {
		return mem[address];
	}

	public void writeMemory(int address, int value) {
		mem[address] = value;
	}

	public void printState() {
		// registers
		final String formatted = String.format("PC: %h, AC: %h",PC,AC);
		System.out.println(formatted);
	}

}

@@ -148,16 +148,40 @@
 ress) %7B%0A
+%09%09printMemory(address);%0A
 %09%09return
@@ -194,25 +194,24 @@
 ddress%5D;%0A%09%7D%0A
-%0A
 %09public void
@@ -274,17 +274,441 @@
 value;%0A%09
-%7D
+%09printMemory(address);%0A%09%7D%0A%0A%09private void printMemory(int address) %7B%0A%09%09// align to 8 words%0A%09%09int start = (address / 8) * 8;%0A%09%09System.out.print(String.format(%22(%2504x): %22, start));%0A%09%09for (int i = start; i %3C start + 8; i++) %7B%0A%09%09%09String string = String.format(%22%2504x%22, mem%5Bi%5D);%0A%09%09%09System.out.print(string);%0A%09%09%09if (i == address) %7B%0A%09%09%09%09System.out.print(%22*%22);%0A%09%09%09%7D else %7B%0A%09%09%09%09System.out.print(%22 %22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09System.out.println();%0A%09%7D%0A
 %0A%0A%09publi
@@ -806,11 +806,13 @@
 %25h%22,
+ 
 PC,
+ 
 AC);

print out some context during memory access