1
0
mirror of https://github.com/rzzzwilson/pymlac.git synced 2025-06-10 09:32:41 +00:00

Further testing

This commit is contained in:
Ross Wilson
2016-03-04 16:40:17 +07:00
parent f6ddcf0772
commit f9cfa17e60
4 changed files with 32 additions and 16 deletions

View File

@@ -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):

View File

@@ -10,6 +10,10 @@ import struct
from Globals import *
import Trace
import log
log = log.Log('test.log', log.Log.DEBUG)
class Memory(object):

View File

@@ -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))

View File

@@ -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)