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

Still debugging blockpunch.test bug

This commit is contained in:
Ross Wilson
2016-03-15 18:17:17 +10:00
parent b894ccfc79
commit 8e9349b419
3 changed files with 35 additions and 11 deletions

View File

@@ -53,7 +53,8 @@ class PtrPtp(object):
def reset(self):
"""Reset device to a known state."""
# general device
log("Resetting the PTR/PTP device")
self.device_use = None
self.device_motor_on = False
self.device_open_file = None
@@ -79,7 +80,9 @@ class PtrPtp(object):
if self.device_use == self.InUsePTP:
raise RuntimeError("ptr_mount: Can't mount PTR file, being used as PTP")
log("Mounting '%s' onto PTR" % fname)
if self.device_open_file:
log('ptr_mount: closing %s' % str(self.device_open_file))
self.device_open_file.close()
self.device_use = self.InUsePTR
self.device_motor_on = False
@@ -90,15 +93,18 @@ class PtrPtp(object):
self.ptr_at_eof = False
self.ptr_value = None
log("Mounting '%s' onto PTR, .device_filename=%s, .device_open_file=%s"
% (fname, self.device_filename, str(self.device_open_file)))
def ptr_dismount(self):
"""Dismount a papertape file."""
if self.device_use == self.InUsePTP:
raise RuntimeError("ptr_dismount: Can't dismount PTR file, being used as PTP")
log("Dismounting '%s' onto PTR" % self.device_filename)
log("Dismounting '%s' from PTR" % self.device_filename)
if self.device_filename:
if self.device_open_file:
self.device_open_file.close()
self.reset()
@@ -109,13 +115,14 @@ class PtrPtp(object):
if self.device_use == self.InUsePTP:
raise RuntimeError("start: Can't start PTR motor, being used as PTP")
log("Starting PTR")
self.device_use = self.InUsePTR
self.device_motor_on = True
self.device_ready = False
self.device_cycle_count = self.PtrReadyCycles
log("Starting PTR, .device_motor_on=%s, .device_ready=%s, .device_cycle_count=%d"
% (str(self.device_motor_on), str(self.device_ready), self.device_cycle_count))
def stop(self):
"""Stop reader motor."""
@@ -150,11 +157,15 @@ class PtrPtp(object):
cycles number of cycles passed since last tick
"""
log('ptr_tick: cycles=%d, .device_cycle_count=%d, .device_filename=%s, .device_open_file=%s'
% (cycles, self.device_cycle_count, self.device_filename, str(self.device_open_file)))
if self.device_use != self.InUsePTR:
return
# if end of tape or motor off, do nothing, state remains unchanged
if self.ptr_at_eof or not self.device_motor_on:
log('ptr_tick: EOT or motor off')
return
self.device_cycle_count -= cycles
@@ -163,16 +174,22 @@ class PtrPtp(object):
if self.device_ready:
self.device_ready = False
self.device_cycle_count += self.PtrNotReadyCycles
log('ptr_tick: device going not ready')
else:
self.device_ready = True
self.device_cycle_count += self.PtrReadyCycles
log('ptr_tick: reading from file %s' % str(self.device_open_file))
self.ptr_value = self.device_open_file.read(1)
log('ptr_tick: .ptr_value=%s' % str(self.ptr_value))
if len(self.ptr_value) < 1:
# EOF on input file, pretend end of tape
self.ptr_at_eof = True
self.ptr_value = self.PtrEOF
log('ptr_tick: device went EOT')
else:
self.ptr_value = ord(self.ptr_value)
log('ptr_tick: device going ready, value=%03o' % self.ptr_value)
log('ptr_tick: --------------------------')
###############
# Interface routines for punch

View File

@@ -5,7 +5,11 @@ bootrom ptr; mount ptr dumpmem_test.ptp; setreg pc 040; rununtil 0 # load the te
setreg pc 03660; rununtil 0 # punch leader
setreg pc 03640; rununtil 0 # punch block loader
setreg pc 03660; rununtil 0 # punch leader
setreg ds 040; rununtil 0 # feed in start address 0100
setreg ds 077; rununtil 0 # and end address 0110
setreg ds 0100; rununtil 0 # feed in start address 0100
setreg ds 0110; rununtil 0 # and end address 0110
setreg pc 03670; rununtil 0 # punch memory and end leader
# now see if we can run the punched memory
bootrom ptr; mount ptr xyzzy.ptp; trace 040,045:050,077; setreg pc 040; rununtil 0 # load the blockpunch output PTP
setreg pc 0100; trace 0100,0110; rununtil 0 # run it with trace

View File

@@ -774,13 +774,16 @@ class TestCPU(object):
if not line:
continue # skip blank lines
if line[0] == '#': # a comment
continue
if '#' in line:
index = line.find('#')
line = line[:index]
# remove trailing spaces
line = line.rstrip()
if not line:
continue # skip blank lines
if line[0] in ('\t', ' '): # continuation
if test:
if not test.endswith(';'):