/**
 * Instances of this class are flash memories of PICs
 * <BR>You can read the source of this class <A HREF="./Flash.java.html"> here</A>.
 */
public class Flash {

	/**
	 * The size of the flash memory.
	 */
	public static final int FlashSize = 1024;

	/**
	 * Creates a flash containing the prog prog.
	 * @param prog Program to write to flash.
	 */
	public Flash(CompiledProgram prog) {
		FlashArray = new int[FlashSize];
		Reprogram(prog);
	}

	/**
	 * Creates a new not-yet-programmed flash.
	 */
	public Flash() {
		FlashArray = new int[FlashSize];
	}

	/**
	 * Returns instruction at address address.
	 * @param address Address to read instruction from.
	 */
	public int Read(int address) {
		return FlashArray[address];
	}

	/**
	 * Reprograms the flash memory.
	 * @param prog Program to write to flash.
	 */
	public void Reprogram(CompiledProgram prog) {
		int i;
		for(i = 0 ; i < FlashSize ; i++)
			FlashArray[i] = prog.Program()[i];
	}

	protected int FlashArray[];
}