added load_file to RAM

This commit is contained in:
James Tauber 2011-08-13 09:41:45 -04:00
parent bc0406f211
commit 4c333ec125

View File

@ -249,6 +249,11 @@ class RAM:
for offset, datum in enumerate(data):
self.__mem[address - self.start + offset] = datum
def load_file(self, address, filename):
with open(filename) as f:
for offset, datum in enumerate(f.read()):
self.__mem[address - self.start + offset] = ord(datum)
def read_byte(self, address):
assert self.start <= address <= self.end
return self.__mem[address - self.start]