diff --git a/pymlac/MainCPU.py b/pymlac/MainCPU.py index 8919dbc..8a1cb02 100644 --- a/pymlac/MainCPU.py +++ b/pymlac/MainCPU.py @@ -10,6 +10,10 @@ import sys from Globals import * import Trace +import log +log = log.Log('test.log', log.Log.DEBUG) + + trace = Trace.Trace(TRACE_FILENAME) class MainCPU(object): @@ -229,7 +233,8 @@ class MainCPU(object): eff_address = self.memory.eff_address(address, indirect) self.memory.put(self.AC, eff_address, False) tracestr = trace.itrace(self.dot, 'DAC', indirect, address) - print('DAC: storing %06o at address %06o' % (self.AC, eff_address)) + log('DAC: %s' % tracestr) + log('DAC: storing %06o at address %06o' % (self.AC, eff_address)) return (3, tracestr) if indirect else (2, tracestr) def i_XAM(self, indirect, address, instruction): diff --git a/pymlac/Memory.py b/pymlac/Memory.py index 96d966c..9d31d6b 100644 --- a/pymlac/Memory.py +++ b/pymlac/Memory.py @@ -10,6 +10,10 @@ import struct from Globals import * import Trace +import log +log = log.Log('test.log', log.Log.DEBUG) + + class Memory(object): diff --git a/pymlac/TtyIn.py b/pymlac/TtyIn.py index 48ecc62..dbdb774 100644 --- a/pymlac/TtyIn.py +++ b/pymlac/TtyIn.py @@ -7,7 +7,7 @@ Emulate the Input TTY device (TTYIN). from Globals import * import log -log = log.Log('test_TTYIN.log', log.Log.DEBUG) +log = log.Log('test.log', log.Log.DEBUG) class TtyIn(object): @@ -27,7 +27,7 @@ class TtyIn(object): self.filename = None self.open_file = None - self.value = 0 + self.value = 0xff self.atEOF = True self.cycle_count = 0 self.status = self.DEVICE_NOT_READY @@ -49,10 +49,13 @@ class TtyIn(object): # EOF on input file self.atEOF = True self.cycle_count = 0 - self.value = 0 log('TTYIN: EOF set on device (file %s)' % self.fname) - self.value = ord(self.value) - self.offset = -1 + else: + self.value = ord(self.value) + self.offset = 0 + + log('TTYIN: Mounting file %s, .value=%03o, .offset=%04o' + % (self.filename, self.value, self.offset)) def dismount(self): """Dismount the file on the TTYIN device.""" @@ -66,7 +69,7 @@ class TtyIn(object): self.value = 0 self.atEOF = True self.status = self.DEVICE_NOT_READY - self.offset = None + self.offset = 0 def read(self): """Return the current device value.""" @@ -86,7 +89,7 @@ class TtyIn(object): def clear(self): """Clear the device 'ready' status.""" - log("TTYIN: Clearing device 'ready' status") + log("TTYIN: Clearing device 'ready' status, offset=%04o" % self.offset) self.status = self.DEVICE_NOT_READY @@ -101,15 +104,15 @@ class TtyIn(object): self.cycle_count += self.DEVICE_READY_CYCLES self.status = self.DEVICE_READY self.value = self.open_file.read(1) + self.offset += 1 if len(self.value) < 1: # EOF on input file self.atEOF = True - self.value = chr(0) + self.value = chr(0xff) self.cycle_count = 0 self.status = self.DEVICE_NOT_READY log('TTYIN: EOF set on device (file %s)' % self.filename) - else: - log('TTYIN: .cycle_count expired, new character is %s (%03o)' - % (self.value, ord(self.value[0]))) self.value = ord(self.value) - self.offset += 1 + + log('TTYIN: .cycle_count expired, new character is %03o, .offset=%04o' + % (self.value, self.offset)) diff --git a/pymlac/pymlac b/pymlac/pymlac index 1fbec2c..dc26319 100755 --- a/pymlac/pymlac +++ b/pymlac/pymlac @@ -46,6 +46,9 @@ import TtyIn import TtyOut import Trace +import log +log = log.Log('test.log', log.Log.DEBUG) + trace = Trace.Trace(TRACE_FILENAME) @@ -85,8 +88,9 @@ def start_running(cpu, memory, ptrptp, ttyin): (cycles, tracestr) = cpu.execute_one_instruction() if tracestr: endstr = trace.itraceend(False) - trace.comment('%s\t%s' % (tracestr, endstr)) - trace.flush() + log('%s\t%s' % (tracestr, endstr)) +# trace.comment('%s\t%s' % (tracestr, endstr)) +# trace.flush() ptrptp.ptr_tick(cycles) ptrptp.ptp_tick(cycles) ttyin.tick(cycles) @@ -202,7 +206,7 @@ def main(): for rng in r.split(':'): be = rng.split(',') if len(be) != 2: - usage("'-r' ranges must have form 'begin,end'") + usage("'-t' ranges must have form 'begin,end'") sys.exit(10) (begin, end) = be begin = str2int(begin)