PiDP-8/I Software

Hex Artifact Content
Log In

Artifact c50057a86d8836f2cb64ce2603571209ba5c382b:


0000: 23 21 2f 75 73 72 2f 62 69 6e 2f 70 79 74 68 6f  #!/usr/bin/pytho
0010: 6e 0a 23 20 2d 2a 2d 20 63 6f 64 69 6e 67 3a 20  n.# -*- coding: 
0020: 75 74 66 2d 38 20 2d 2a 2d 0a 23 23 23 23 23 23  utf-8 -*-.######
0030: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0040: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0050: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0060: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0070: 23 23 0a 23 20 74 65 63 6f 2d 70 69 2d 64 65 6d  ##.# teco-pi-dem
0080: 6f 20 2d 20 53 74 61 72 74 73 20 74 68 65 20 73  o - Starts the s
0090: 69 6d 75 6c 61 74 6f 72 20 77 69 74 68 20 74 68  imulator with th
00a0: 65 20 4f 53 2f 38 2c 20 73 65 6e 64 73 20 6f 6e  e OS/8, sends on
00b0: 65 20 6f 66 20 74 68 65 0a 23 20 20 20 66 61 6d  e of the.#   fam
00c0: 6f 75 73 20 54 45 43 4f 20 22 63 61 6c 63 75 6c  ous TECO "calcul
00d0: 61 74 65 20 70 69 22 20 70 72 6f 67 72 61 6d 20  ate pi" program 
00e0: 74 6f 20 69 74 2c 20 61 6e 64 20 73 74 61 72 74  to it, and start
00f0: 73 20 69 74 20 72 75 6e 6e 69 6e 67 20 61 74 0a  s it running at.
0100: 23 20 20 20 61 20 76 65 72 79 20 73 6c 6f 77 20  #   a very slow 
0110: 72 61 74 65 20 6f 66 20 73 70 65 65 64 20 74 6f  rate of speed to
0120: 20 61 63 74 20 61 73 20 61 20 62 6c 69 6e 6b 65   act as a blinke
0130: 6e 6c 69 67 68 74 73 20 64 65 6d 6f 2e 0a 23 0a  nlights demo..#.
0140: 23 20 43 6f 70 79 72 69 67 68 74 20 c2 a9 20 32  # Copyright © 2
0150: 30 31 37 20 62 79 20 57 61 72 72 65 6e 20 59 6f  017 by Warren Yo
0160: 75 6e 67 2e 0a 23 0a 23 20 50 65 72 6d 69 73 73  ung..#.# Permiss
0170: 69 6f 6e 20 69 73 20 68 65 72 65 62 79 20 67 72  ion is hereby gr
0180: 61 6e 74 65 64 2c 20 66 72 65 65 20 6f 66 20 63  anted, free of c
0190: 68 61 72 67 65 2c 20 74 6f 20 61 6e 79 20 70 65  harge, to any pe
01a0: 72 73 6f 6e 20 6f 62 74 61 69 6e 69 6e 67 0a 23  rson obtaining.#
01b0: 20 61 20 63 6f 70 79 20 6f 66 20 74 68 69 73 20   a copy of this 
01c0: 73 6f 66 74 77 61 72 65 20 61 6e 64 20 61 73 73  software and ass
01d0: 6f 63 69 61 74 65 64 20 64 6f 63 75 6d 65 6e 74  ociated document
01e0: 61 74 69 6f 6e 20 66 69 6c 65 73 20 28 74 68 65  ation files (the
01f0: 0a 23 20 22 53 6f 66 74 77 61 72 65 22 29 2c 20  .# "Software"), 
0200: 74 6f 20 64 65 61 6c 20 69 6e 20 74 68 65 20 53  to deal in the S
0210: 6f 66 74 77 61 72 65 20 77 69 74 68 6f 75 74 20  oftware without 
0220: 72 65 73 74 72 69 63 74 69 6f 6e 2c 20 69 6e 63  restriction, inc
0230: 6c 75 64 69 6e 67 0a 23 20 77 69 74 68 6f 75 74  luding.# without
0240: 20 6c 69 6d 69 74 61 74 69 6f 6e 20 74 68 65 20   limitation the 
0250: 72 69 67 68 74 73 20 74 6f 20 75 73 65 2c 20 63  rights to use, c
0260: 6f 70 79 2c 20 6d 6f 64 69 66 79 2c 20 6d 65 72  opy, modify, mer
0270: 67 65 2c 20 70 75 62 6c 69 73 68 2c 0a 23 20 64  ge, publish,.# d
0280: 69 73 74 72 69 62 75 74 65 2c 20 73 75 62 6c 69  istribute, subli
0290: 63 65 6e 73 65 2c 20 61 6e 64 2f 6f 72 20 73 65  cense, and/or se
02a0: 6c 6c 20 63 6f 70 69 65 73 20 6f 66 20 74 68 65  ll copies of the
02b0: 20 53 6f 66 74 77 61 72 65 2c 20 61 6e 64 20 74   Software, and t
02c0: 6f 0a 23 20 70 65 72 6d 69 74 20 70 65 72 73 6f  o.# permit perso
02d0: 6e 73 20 74 6f 20 77 68 6f 6d 20 74 68 65 20 53  ns to whom the S
02e0: 6f 66 74 77 61 72 65 20 69 73 20 66 75 72 6e 69  oftware is furni
02f0: 73 68 65 64 20 74 6f 20 64 6f 20 73 6f 2c 20 73  shed to do so, s
0300: 75 62 6a 65 63 74 20 74 6f 0a 23 20 74 68 65 20  ubject to.# the 
0310: 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f 6e 64 69 74  following condit
0320: 69 6f 6e 73 3a 0a 23 0a 23 20 54 68 65 20 61 62  ions:.#.# The ab
0330: 6f 76 65 20 63 6f 70 79 72 69 67 68 74 20 6e 6f  ove copyright no
0340: 74 69 63 65 20 61 6e 64 20 74 68 69 73 20 70 65  tice and this pe
0350: 72 6d 69 73 73 69 6f 6e 20 6e 6f 74 69 63 65 20  rmission notice 
0360: 73 68 61 6c 6c 20 62 65 0a 23 20 69 6e 63 6c 75  shall be.# inclu
0370: 64 65 64 20 69 6e 20 61 6c 6c 20 63 6f 70 69 65  ded in all copie
0380: 73 20 6f 72 20 73 75 62 73 74 61 6e 74 69 61 6c  s or substantial
0390: 20 70 6f 72 74 69 6f 6e 73 20 6f 66 20 74 68 65   portions of the
03a0: 20 53 6f 66 74 77 61 72 65 2e 0a 23 0a 23 20 54   Software..#.# T
03b0: 48 45 20 53 4f 46 54 57 41 52 45 20 49 53 20 50  HE SOFTWARE IS P
03c0: 52 4f 56 49 44 45 44 20 22 41 53 20 49 53 22 2c  ROVIDED "AS IS",
03d0: 20 57 49 54 48 4f 55 54 20 57 41 52 52 41 4e 54   WITHOUT WARRANT
03e0: 59 20 4f 46 20 41 4e 59 20 4b 49 4e 44 2c 0a 23  Y OF ANY KIND,.#
03f0: 20 45 58 50 52 45 53 53 20 4f 52 20 49 4d 50 4c   EXPRESS OR IMPL
0400: 49 45 44 2c 20 49 4e 43 4c 55 44 49 4e 47 20 42  IED, INCLUDING B
0410: 55 54 20 4e 4f 54 20 4c 49 4d 49 54 45 44 20 54  UT NOT LIMITED T
0420: 4f 20 54 48 45 20 57 41 52 52 41 4e 54 49 45 53  O THE WARRANTIES
0430: 20 4f 46 0a 23 20 4d 45 52 43 48 41 4e 54 41 42   OF.# MERCHANTAB
0440: 49 4c 49 54 59 2c 20 46 49 54 4e 45 53 53 20 46  ILITY, FITNESS F
0450: 4f 52 20 41 20 50 41 52 54 49 43 55 4c 41 52 20  OR A PARTICULAR 
0460: 50 55 52 50 4f 53 45 20 41 4e 44 20 4e 4f 4e 49  PURPOSE AND NONI
0470: 4e 46 52 49 4e 47 45 4d 45 4e 54 2e 0a 23 20 49  NFRINGEMENT..# I
0480: 4e 20 4e 4f 20 45 56 45 4e 54 20 53 48 41 4c 4c  N NO EVENT SHALL
0490: 20 54 48 45 20 41 55 54 48 4f 52 53 20 4c 49 53   THE AUTHORS LIS
04a0: 54 45 44 20 41 42 4f 56 45 20 42 45 20 4c 49 41  TED ABOVE BE LIA
04b0: 42 4c 45 20 46 4f 52 20 41 4e 59 20 43 4c 41 49  BLE FOR ANY CLAI
04c0: 4d 2c 0a 23 20 44 41 4d 41 47 45 53 20 4f 52 20  M,.# DAMAGES OR 
04d0: 4f 54 48 45 52 20 4c 49 41 42 49 4c 49 54 59 2c  OTHER LIABILITY,
04e0: 20 57 48 45 54 48 45 52 20 49 4e 20 41 4e 20 41   WHETHER IN AN A
04f0: 43 54 49 4f 4e 20 4f 46 20 43 4f 4e 54 52 41 43  CTION OF CONTRAC
0500: 54 2c 20 54 4f 52 54 0a 23 20 4f 52 20 4f 54 48  T, TORT.# OR OTH
0510: 45 52 57 49 53 45 2c 20 41 52 49 53 49 4e 47 20  ERWISE, ARISING 
0520: 46 52 4f 4d 2c 20 4f 55 54 20 4f 46 20 4f 52 20  FROM, OUT OF OR 
0530: 49 4e 20 43 4f 4e 4e 45 43 54 49 4f 4e 20 57 49  IN CONNECTION WI
0540: 54 48 20 54 48 45 20 53 4f 46 54 57 41 52 45 0a  TH THE SOFTWARE.
0550: 23 20 4f 52 20 54 48 45 20 55 53 45 20 4f 52 20  # OR THE USE OR 
0560: 4f 54 48 45 52 20 44 45 41 4c 49 4e 47 53 20 49  OTHER DEALINGS I
0570: 4e 20 54 48 45 20 53 4f 46 54 57 41 52 45 2e 0a  N THE SOFTWARE..
0580: 23 0a 23 20 45 78 63 65 70 74 20 61 73 20 63 6f  #.# Except as co
0590: 6e 74 61 69 6e 65 64 20 69 6e 20 74 68 69 73 20  ntained in this 
05a0: 6e 6f 74 69 63 65 2c 20 74 68 65 20 6e 61 6d 65  notice, the name
05b0: 73 20 6f 66 20 74 68 65 20 61 75 74 68 6f 72 73  s of the authors
05c0: 20 61 62 6f 76 65 0a 23 20 73 68 61 6c 6c 20 6e   above.# shall n
05d0: 6f 74 20 62 65 20 75 73 65 64 20 69 6e 20 61 64  ot be used in ad
05e0: 76 65 72 74 69 73 69 6e 67 20 6f 72 20 6f 74 68  vertising or oth
05f0: 65 72 77 69 73 65 20 74 6f 20 70 72 6f 6d 6f 74  erwise to promot
0600: 65 20 74 68 65 20 73 61 6c 65 2c 0a 23 20 75 73  e the sale,.# us
0610: 65 20 6f 72 20 6f 74 68 65 72 20 64 65 61 6c 69  e or other deali
0620: 6e 67 73 20 69 6e 20 74 68 69 73 20 53 6f 66 74  ngs in this Soft
0630: 77 61 72 65 20 77 69 74 68 6f 75 74 20 70 72 69  ware without pri
0640: 6f 72 20 77 72 69 74 74 65 6e 0a 23 20 61 75 74  or written.# aut
0650: 68 6f 72 69 7a 61 74 69 6f 6e 20 66 72 6f 6d 20  horization from 
0660: 74 68 6f 73 65 20 61 75 74 68 6f 72 73 2e 0a 23  those authors..#
0670: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0680: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0690: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
06a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
06b0: 23 23 23 23 23 23 23 0a 0a 23 20 42 72 69 6e 67  #######..# Bring
06c0: 20 69 6e 20 6a 75 73 74 20 74 68 65 20 62 61 73   in just the bas
06d0: 69 63 73 20 73 6f 20 77 65 20 63 61 6e 20 62 72  ics so we can br
06e0: 69 6e 67 20 69 6e 20 6f 75 72 20 6c 6f 63 61 6c  ing in our local
06f0: 20 6d 6f 64 75 6c 65 73 0a 69 6d 70 6f 72 74 20   modules.import 
0700: 6f 73 0a 69 6d 70 6f 72 74 20 73 79 73 0a 73 79  os.import sys.sy
0710: 73 2e 70 61 74 68 2e 69 6e 73 65 72 74 20 28 30  s.path.insert (0
0720: 2c 20 6f 73 2e 70 61 74 68 2e 64 69 72 6e 61 6d  , os.path.dirnam
0730: 65 20 28 5f 5f 66 69 6c 65 5f 5f 29 20 2b 20 27  e (__file__) + '
0740: 2f 2e 2e 2f 6c 69 62 27 29 0a 73 79 73 2e 70 61  /../lib').sys.pa
0750: 74 68 2e 69 6e 73 65 72 74 20 28 30 2c 20 6f 73  th.insert (0, os
0760: 2e 67 65 74 63 77 64 20 28 29 20 2b 20 27 2f 6c  .getcwd () + '/l
0770: 69 62 27 29 0a 0a 23 20 4f 74 68 65 72 20 63 6f  ib')..# Other co
0780: 72 65 20 6d 6f 64 75 6c 65 73 20 77 65 20 6e 65  re modules we ne
0790: 65 64 0a 66 72 6f 6d 20 64 61 74 65 74 69 6d 65  ed.from datetime
07a0: 20 69 6d 70 6f 72 74 20 64 61 74 65 74 69 6d 65   import datetime
07b0: 0a 69 6d 70 6f 72 74 20 74 69 6d 65 0a 0a 23 20  .import time..# 
07c0: 4f 75 72 20 6c 6f 63 61 6c 20 6d 6f 64 75 6c 65  Our local module
07d0: 73 0a 66 72 6f 6d 20 70 69 64 70 38 69 20 69 6d  s.from pidp8i im
07e0: 70 6f 72 74 20 2a 0a 66 72 6f 6d 20 73 69 6d 68  port *.from simh
07f0: 20 20 20 69 6d 70 6f 72 74 20 2a 0a 0a 0a 23 23     import *...##
0800: 23 23 20 6d 61 69 6e 20 23 23 23 23 23 23 23 23  ## main ########
0810: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0820: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0830: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0840: 23 23 23 23 23 23 0a 0a 64 65 66 20 6d 61 69 6e  ######..def main
0850: 20 28 29 3a 0a 20 20 23 20 43 68 65 63 6b 20 66   ():.  # Check f
0860: 6f 72 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20  or command line 
0870: 66 6c 61 67 73 0a 20 20 62 65 6e 63 68 6d 61 72  flags.  benchmar
0880: 6b 20 3d 20 6c 65 6e 20 28 73 79 73 2e 61 72 67  k = len (sys.arg
0890: 76 29 20 3e 20 31 20 61 6e 64 20 73 79 73 2e 61  v) > 1 and sys.a
08a0: 72 67 76 5b 31 5d 20 3d 3d 20 27 2d 62 27 0a 0a  rgv[1] == '-b'..
08b0: 20 20 23 20 43 72 65 61 74 65 20 74 68 65 20 53    # Create the S
08c0: 49 4d 48 20 63 68 69 6c 64 20 69 6e 73 74 61 6e  IMH child instan
08d0: 63 65 20 61 6e 64 20 74 65 6c 6c 20 69 74 20 77  ce and tell it w
08e0: 68 65 72 65 20 74 6f 20 73 65 6e 64 20 6c 6f 67  here to send log
08f0: 20 6f 75 74 70 75 74 0a 20 20 74 72 79 3a 0a 20   output.  try:. 
0900: 20 20 20 73 20 3d 20 73 69 6d 68 20 28 64 69 72     s = simh (dir
0910: 73 2e 62 75 69 6c 64 29 0a 20 20 65 78 63 65 70  s.build).  excep
0920: 74 20 28 52 75 6e 74 69 6d 65 45 72 72 6f 72 29  t (RuntimeError)
0930: 20 61 73 20 65 3a 0a 20 20 20 20 70 72 69 6e 74   as e:.    print
0940: 20 22 43 6f 75 6c 64 20 6e 6f 74 20 73 74 61 72   "Could not star
0950: 74 20 73 69 6d 75 6c 61 74 6f 72 3a 20 22 20 2b  t simulator: " +
0960: 20 65 2e 6d 65 73 73 61 67 65 20 2b 20 27 21 27   e.message + '!'
0970: 0a 20 20 20 20 65 78 69 74 20 28 31 29 0a 20 20  .    exit (1).  
0980: 73 2e 73 65 74 5f 6c 6f 67 66 69 6c 65 20 28 6f  s.set_logfile (o
0990: 73 2e 66 64 6f 70 65 6e 20 28 73 79 73 2e 73 74  s.fdopen (sys.st
09a0: 64 6f 75 74 2e 66 69 6c 65 6e 6f 20 28 29 2c 20  dout.fileno (), 
09b0: 27 77 27 2c 20 30 29 29 0a 0a 20 20 23 20 46 69  'w', 0))..  # Fi
09c0: 6e 64 20 61 6e 64 20 62 6f 6f 74 20 74 68 65 20  nd and boot the 
09d0: 62 75 69 6c 74 20 4f 53 2f 38 20 62 69 6e 20 64  built OS/8 bin d
09e0: 69 73 6b 0a 20 20 72 6b 20 3d 20 6f 73 2e 70 61  isk.  rk = os.pa
09f0: 74 68 2e 6a 6f 69 6e 20 28 64 69 72 73 2e 6f 73  th.join (dirs.os
0a00: 38 6d 6f 2c 20 27 6f 73 38 76 33 64 2d 62 69 6e  8mo, 'os8v3d-bin
0a10: 2e 72 6b 30 35 27 29 0a 20 20 69 66 20 6e 6f 74  .rk05').  if not
0a20: 20 6f 73 2e 70 61 74 68 2e 69 73 66 69 6c 65 20   os.path.isfile 
0a30: 28 72 6b 29 3a 0a 20 20 20 20 70 72 69 6e 74 20  (rk):.    print 
0a40: 22 43 6f 75 6c 64 20 6e 6f 74 20 66 69 6e 64 20  "Could not find 
0a50: 22 20 2b 20 72 6b 20 2b 20 22 3b 20 4f 53 2f 38  " + rk + "; OS/8
0a60: 20 6d 65 64 69 61 20 6e 6f 74 20 79 65 74 20 62   media not yet b
0a70: 75 69 6c 74 3f 22 0a 20 20 20 20 65 78 69 74 20  uilt?".    exit 
0a80: 28 31 29 0a 20 20 70 72 69 6e 74 20 22 42 6f 6f  (1).  print "Boo
0a90: 74 69 6e 67 20 22 20 2b 20 72 6b 20 2b 20 22 2e  ting " + rk + ".
0aa0: 2e 2e 22 0a 20 20 73 2e 73 65 6e 64 5f 63 6d 64  ..".  s.send_cmd
0ab0: 20 28 22 61 74 74 20 72 6b 30 20 22 20 2b 20 72   ("att rk0 " + r
0ac0: 6b 29 0a 20 20 73 2e 73 65 6e 64 5f 63 6d 64 20  k).  s.send_cmd 
0ad0: 28 22 62 6f 6f 74 20 72 6b 30 22 29 0a 0a 20 20  ("boot rk0")..  
0ae0: 23 20 53 74 61 72 74 20 54 45 43 4f 38 20 69 6e  # Start TECO8 in
0af0: 20 74 68 65 20 73 69 6d 75 6c 61 74 6f 72 20 75   the simulator u
0b00: 6e 64 65 72 20 4f 53 2f 38 0a 20 20 73 2e 6f 73  nder OS/8.  s.os
0b10: 38 5f 73 65 6e 64 5f 63 6d 64 20 28 27 5c 5c 2e  8_send_cmd ('\\.
0b20: 27 2c 20 22 52 20 54 45 43 4f 22 29 0a 0a 20 20  ', "R TECO")..  
0b30: 23 20 54 68 65 20 6d 61 63 72 6f 20 63 6f 6d 65  # The macro come
0b40: 73 20 66 72 6f 6d 20 68 74 74 70 3a 2f 2f 77 77  s from http://ww
0b50: 77 2e 69 77 72 69 74 65 69 61 6d 2e 6e 6c 2f 48  w.iwriteiam.nl/H
0b60: 61 50 69 5f 54 45 43 4f 5f 6d 61 63 72 6f 2e 68  aPi_TECO_macro.h
0b70: 74 6d 6c 0a 20 20 23 0a 20 20 23 20 54 68 65 20  tml.  #.  # The 
0b80: 32 34 38 20 70 72 65 63 65 64 69 6e 67 20 22 55  248 preceding "U
0b90: 4e 22 20 69 6e 20 74 68 65 20 66 69 72 73 74 20  N" in the first 
0ba0: 6c 69 6e 65 20 6f 66 20 74 68 65 20 6d 61 63 72  line of the macr
0bb0: 6f 20 69 73 20 74 68 65 20 6e 75 6d 62 65 72 0a  o is the number.
0bc0: 20 20 23 20 6f 66 20 64 69 67 69 74 73 20 6f 66    # of digits of
0bd0: 20 70 69 20 74 6f 20 63 61 6c 63 75 6c 61 74 65   pi to calculate
0be0: 2e 20 20 54 68 61 74 20 76 61 6c 75 65 20 77 61  .  That value wa
0bf0: 73 20 72 65 61 63 68 65 64 20 62 79 20 65 78 70  s reached by exp
0c00: 65 72 69 6d 65 6e 74 0a 20 20 23 20 61 73 20 74  eriment.  # as t
0c10: 68 65 20 6c 61 72 67 65 73 74 20 76 61 6c 75 65  he largest value
0c20: 20 74 68 61 74 20 72 75 6e 73 20 77 69 74 68 6f   that runs witho
0c30: 75 74 20 63 72 61 73 68 69 6e 67 20 54 45 43 4f  ut crashing TECO
0c40: 20 77 69 74 68 20 61 0a 20 20 23 0a 20 20 23 20   with a.  #.  # 
0c50: 20 20 20 3f 4d 45 4d 20 20 53 54 4f 52 41 47 45     ?MEM  STORAGE
0c60: 20 43 41 50 41 43 49 54 59 20 45 58 43 45 45 44   CAPACITY EXCEED
0c70: 45 44 0a 20 20 23 0a 20 20 23 20 65 72 72 6f 72  ED.  #.  # error
0c80: 2e 20 20 59 6f 75 20 63 61 6e 20 73 65 65 20 74  .  You can see t
0c90: 68 61 74 20 62 79 20 69 6e 63 72 65 61 73 69 6e  hat by increasin
0ca0: 67 20 74 68 65 20 76 61 6c 75 65 20 62 65 6c 6f  g the value belo
0cb0: 77 2c 20 63 6f 6d 6d 65 6e 74 69 6e 67 0a 20 20  w, commenting.  
0cc0: 23 20 6f 75 74 20 74 68 65 20 74 68 72 6f 74 74  # out the thrott
0cd0: 6c 65 20 73 65 74 74 69 6e 67 20 62 65 6c 6f 77  le setting below
0ce0: 2c 20 61 6e 64 20 72 75 6e 6e 69 6e 67 20 74 68  , and running th
0cf0: 65 20 64 65 6d 6f 2e 20 20 4f 6e 20 61 20 50 69  e demo.  On a Pi
0d00: 20 33 2c 20 69 74 0a 20 20 23 20 73 68 6f 75 6c   3, it.  # shoul
0d10: 64 20 74 61 6b 65 20 61 20 62 69 74 20 6f 76 65  d take a bit ove
0d20: 72 20 61 6e 20 68 6f 75 72 20 74 6f 20 63 6f 6d  r an hour to com
0d30: 70 6c 65 74 65 2c 20 69 66 20 69 74 20 64 6f 65  plete, if it doe
0d40: 73 6e 27 74 20 65 72 72 6f 72 20 6f 75 74 2e 0a  sn't error out..
0d50: 20 20 23 0a 20 20 23 20 57 69 74 68 20 74 68 65    #.  # With the
0d60: 20 73 69 6d 75 6c 61 74 6f 72 20 74 68 72 6f 74   simulator throt
0d70: 74 6c 65 64 2c 20 67 65 6e 65 72 61 74 69 6e 67  tled, generating
0d80: 20 32 34 38 20 64 69 67 69 74 73 20 74 61 6b 65   248 digits take
0d90: 73 20 31 37 20 79 65 61 72 73 21 0a 20 20 23 0a  s 17 years!.  #.
0da0: 20 20 23 20 54 68 61 74 20 69 73 20 62 61 73 65    # That is base
0db0: 64 20 6f 6e 20 67 65 6e 65 72 61 74 69 6e 67 20  d on generating 
0dc0: 31 20 64 69 67 69 74 20 65 76 65 72 79 20 7e 31  1 digit every ~1
0dd0: 36 20 73 65 63 6f 6e 64 73 20 6f 6e 20 61 20 50  6 seconds on a P
0de0: 69 20 33 20 77 68 65 6e 0a 20 20 23 20 72 75 6e  i 3 when.  # run
0df0: 6e 69 6e 67 20 75 6e 74 68 72 6f 74 74 6c 65 64  ning unthrottled
0e00: 2c 20 72 6f 75 67 68 6c 79 20 38 20 4d 49 50 53  , roughly 8 MIPS
0e10: 2e 20 20 57 68 65 6e 20 74 68 72 6f 74 74 6c 65  .  When throttle
0e20: 64 20 74 6f 20 35 39 20 49 50 53 20 e2 80 94 20  d to 59 IPS — 
0e30: 6f 72 0a 20 20 23 20 31 37 6d 73 20 70 65 72 20  or.  # 17ms per 
0e40: 69 6e 73 74 72 75 63 74 69 6f 6e 2c 20 61 73 20  instruction, as 
0e50: 62 65 6c 6f 77 20 e2 80 94 20 79 6f 75 20 6d 75  below — you mu
0e60: 6c 74 69 70 6c 79 20 74 68 65 20 73 65 63 6f 6e  ltiply the secon
0e70: 64 73 20 62 79 20 74 68 65 0a 20 20 23 20 66 61  ds by the.  # fa
0e80: 63 74 6f 72 20 38 20 4d 49 50 53 20 2f 20 35 39  ctor 8 MIPS / 59
0e90: 20 49 50 53 20 3d 20 7e 31 33 36 30 30 30 2c 20   IPS = ~136000, 
0ea0: 67 69 76 69 6e 67 20 61 62 6f 75 74 20 32 2e 32  giving about 2.2
0eb0: 20 6d 69 6c 6c 69 6f 6e 20 73 65 63 6f 6e 64 73   million seconds
0ec0: 0a 20 20 23 20 70 65 72 20 64 69 67 69 74 2e 20  .  # per digit. 
0ed0: 20 4d 75 6c 74 69 70 6c 79 69 6e 67 20 74 68 61   Multiplying tha
0ee0: 74 20 62 79 20 32 34 38 20 67 69 76 65 73 20 7e  t by 248 gives ~
0ef0: 31 37 20 79 65 61 72 73 2e 0a 20 20 6d 61 63 72  17 years..  macr
0f00: 6f 20 3d 20 5b 0a 20 20 20 20 27 47 5a 30 4a 5c  o = [.    'GZ0J\
0f10: 55 4e 51 4e 22 45 20 32 34 38 55 4e 20 5c 27 20  UNQN"E 248UN \' 
0f20: 42 55 48 20 42 55 56 20 48 4b 27 2c 0a 20 20 20  BUH BUV HK',.   
0f30: 20 27 51 4e 3c 20 4a 20 42 55 51 20 51 4e 2a 31   'QN< J BUQ QN*1
0f40: 30 2f 33 55 49 27 2c 0a 20 20 20 20 27 51 49 3c  0/3UI',.    'QI<
0f50: 20 5c 2b 32 2a 31 30 2b 28 51 51 2a 51 49 29 55   \+2*10+(QQ*QI)U
0f60: 41 20 42 20 4c 20 4b 20 51 49 2a 32 2d 31 55 4a  A B L K QI*2-1UJ
0f70: 20 51 41 2f 51 4a 55 51 27 2c 0a 20 20 20 20 27   QA/QJUQ',.    '
0f80: 51 41 2d 28 51 51 2a 51 4a 29 2d 32 5c 20 31 30  QA-(QQ*QJ)-2\ 10
0f90: 40 49 2f 2f 20 2d 31 25 49 20 3e 27 2c 0a 20 20  @I// -1%I >',.  
0fa0: 20 20 27 51 51 2f 31 30 55 54 20 51 48 2b 51 54    'QQ/10UT QH+QT
0fb0: 2b 34 38 55 57 20 51 57 2d 35 38 22 45 20 34 38  +48UW QW-58"E 48
0fc0: 55 57 20 25 56 20 5c 27 20 51 56 22 4e 20 51 56  UW %V \' QV"N QV
0fd0: 5e 54 20 5c 27 20 51 57 55 56 20 51 51 2d 28 51  ^T \' QWUV QQ-(Q
0fe0: 54 2a 31 30 29 55 48 20 3e 27 2c 0a 20 20 20 20  T*10)UH >',.    
0ff0: 27 51 56 5e 54 20 40 5e 41 2f 27 2c 0a 20 20 20  'QV^T @^A/',.   
1000: 20 27 2f 48 4b 45 58 27 2c 0a 20 20 5d 0a 0a 20   '/HKEX',.  ].. 
1010: 20 23 20 46 69 72 73 74 20 61 6e 64 20 6c 61 73   # First and las
1020: 74 20 6c 69 6e 65 73 20 61 72 65 20 68 61 6e 64  t lines are hand
1030: 6c 65 64 20 73 70 65 63 69 61 6c 6c 79 2c 20 73  led specially, s
1040: 6f 20 73 6c 69 63 65 20 74 68 65 6d 20 6f 66 66  o slice them off
1050: 2e 0a 20 20 66 69 72 73 74 20 3d 20 6d 61 63 72  ..  first = macr
1060: 6f 2e 70 6f 70 20 28 30 29 0a 20 20 6c 61 73 74  o.pop (0).  last
1070: 20 20 3d 20 6d 61 63 72 6f 2e 70 6f 70 20 28 29    = macro.pop ()
1080: 0a 0a 20 20 23 20 53 65 6e 64 20 74 68 65 20 66  ..  # Send the f
1090: 69 72 73 74 20 6c 69 6e 65 20 6f 66 20 74 68 65  irst line of the
10a0: 20 6d 61 63 72 6f 3b 20 69 6d 70 6c 69 63 69 74   macro; implicit
10b0: 6c 79 20 61 77 61 69 74 73 20 31 73 74 20 54 45  ly awaits 1st TE
10c0: 43 4f 20 70 72 6f 6d 70 74 0a 20 20 73 2e 6f 73  CO prompt.  s.os
10d0: 38 5f 73 65 6e 64 5f 63 6d 64 20 28 27 5c 2a 27  8_send_cmd ('\*'
10e0: 2c 20 66 69 72 73 74 29 0a 0a 20 20 23 20 42 6c  , first)..  # Bl
10f0: 69 6e 64 6c 79 20 73 65 6e 64 20 63 6f 72 65 20  indly send core 
1100: 6c 69 6e 65 73 20 6f 66 20 74 68 65 20 6d 61 63  lines of the mac
1110: 72 6f 3b 20 54 45 43 4f 20 67 69 76 65 73 20 6e  ro; TECO gives n
1120: 6f 20 70 72 6f 6d 70 74 73 20 66 6f 72 20 27 65  o prompts for 'e
1130: 6d 2e 0a 20 20 66 6f 72 20 6c 69 6e 65 20 69 6e  m..  for line in
1140: 20 6d 61 63 72 6f 3a 20 0a 20 20 20 20 73 2e 6f   macro: .    s.o
1150: 73 38 5f 73 65 6e 64 5f 6c 69 6e 65 20 28 6c 69  s8_send_line (li
1160: 6e 65 29 0a 0a 20 20 23 20 53 65 6e 64 20 6c 61  ne)..  # Send la
1170: 73 74 20 6c 69 6e 65 20 6f 66 20 6d 61 63 72 6f  st line of macro
1180: 20 73 61 6e 73 20 43 52 2c 20 66 6f 6c 6c 6f 77   sans CR, follow
1190: 65 64 20 62 79 20 74 77 6f 20 45 73 63 20 63 68  ed by two Esc ch
11a0: 61 72 61 63 74 65 72 73 20 74 6f 0a 20 20 23 20  aracters to.  # 
11b0: 73 74 61 72 74 20 69 74 20 72 75 6e 6e 69 6e 67  start it running
11c0: 2e 0a 20 20 73 2e 6f 73 38 5f 73 65 6e 64 5f 73  ..  s.os8_send_s
11d0: 74 72 20 28 6c 61 73 74 29 20 20 20 20 20 23 20  tr (last)     # 
11e0: 6e 6f 74 20 6f 73 38 5f 73 65 6e 64 5f 6c 69 6e  not os8_send_lin
11f0: 65 21 0a 20 20 73 2e 6f 73 38 5f 73 65 6e 64 5f  e!.  s.os8_send_
1200: 63 74 72 6c 20 28 27 5b 27 29 0a 20 20 73 2e 6f  ctrl ('[').  s.o
1210: 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 28 27 5b  s8_send_ctrl ('[
1220: 27 29 0a 0a 20 20 69 66 20 62 65 6e 63 68 6d 61  ')..  if benchma
1230: 72 6b 3a 0a 20 20 20 20 23 20 52 75 6e 20 64 65  rk:.    # Run de
1240: 6d 6f 20 6c 6f 6e 67 20 65 6e 6f 75 67 68 20 74  mo long enough t
1250: 6f 20 67 65 74 20 61 20 67 6f 6f 64 20 73 65 6e  o get a good sen
1260: 73 65 20 6f 66 20 74 68 65 20 73 69 6d 75 6c 61  se of the simula
1270: 74 6f 72 27 73 0a 20 20 20 20 23 20 65 78 65 63  tor's.    # exec
1280: 75 74 69 6f 6e 20 72 61 74 65 20 77 68 69 6c 65  ution rate while
1290: 20 75 6e 74 68 72 6f 74 74 6c 65 64 20 6f 6e 20   unthrottled on 
12a0: 74 68 69 73 20 68 6f 73 74 20 68 61 72 64 77 61  this host hardwa
12b0: 72 65 2e 20 20 49 66 0a 20 20 20 20 23 20 79 6f  re.  If.    # yo
12c0: 75 20 64 6f 6e 27 74 20 72 75 6e 20 69 74 20 6c  u don't run it l
12d0: 6f 6e 67 20 65 6e 6f 75 67 68 2c 20 74 68 65 20  ong enough, the 
12e0: 49 50 53 20 76 61 6c 75 65 20 69 73 20 75 6e 74  IPS value is unt
12f0: 72 75 73 74 77 6f 72 74 68 79 2e 0a 20 20 20 20  rustworthy..    
1300: 74 72 79 3a 0a 20 20 20 20 20 20 73 2e 73 70 69  try:.      s.spi
1310: 6e 20 28 31 30 29 0a 20 20 20 20 65 78 63 65 70  n (10).    excep
1320: 74 20 70 65 78 70 65 63 74 2e 54 49 4d 45 4f 55  t pexpect.TIMEOU
1330: 54 3a 0a 20 20 20 20 20 20 23 20 46 69 6e 64 20  T:.      # Find 
1340: 6f 75 74 20 68 6f 77 20 6d 61 6e 79 20 49 50 53  out how many IPS
1350: 20 77 61 73 20 65 78 65 63 75 74 69 6e 67 0a 20   was executing. 
1360: 20 20 20 20 20 73 2e 6f 73 38 5f 73 65 6e 64 5f       s.os8_send_
1370: 63 74 72 6c 20 28 27 65 27 29 0a 20 20 20 20 20  ctrl ('e').     
1380: 20 73 2e 73 65 6e 64 5f 63 6d 64 20 28 27 73 68   s.send_cmd ('sh
1390: 6f 77 20 63 6c 6f 63 6b 73 27 29 0a 20 20 20 20  ow clocks').    
13a0: 20 20 6c 69 6e 65 20 3d 20 73 2e 72 65 61 64 5f    line = s.read_
13b0: 74 61 69 6c 20 28 27 45 78 65 63 75 74 69 6f 6e  tail ('Execution
13c0: 20 52 61 74 65 3a 27 29 0a 20 20 20 20 20 20 63   Rate:').      c
13d0: 75 72 72 5f 69 70 73 20 3d 20 69 6e 74 20 28 6c  urr_ips = int (l
13e0: 69 6e 65 2e 73 74 72 69 70 28 29 2e 72 65 70 6c  ine.strip().repl
13f0: 61 63 65 28 27 2c 27 2c 20 27 27 29 2e 73 70 6c  ace(',', '').spl
1400: 69 74 28 27 20 27 29 5b 30 5d 29 0a 20 20 20 20  it(' ')[0]).    
1410: 20 20 70 66 20 3d 20 6f 70 65 6e 20 28 27 6c 69    pf = open ('li
1420: 62 2f 70 69 64 70 38 69 2f 69 70 73 2e 70 79 27  b/pidp8i/ips.py'
1430: 2c 20 27 61 27 29 0a 20 20 20 20 20 20 70 66 2e  , 'a').      pf.
1440: 77 72 69 74 65 20 28 27 63 75 72 72 65 6e 74 20  write ('current 
1450: 3d 20 27 20 2b 20 73 74 72 20 28 63 75 72 72 5f  = ' + str (curr_
1460: 69 70 73 29 20 2b 20 27 20 20 20 20 23 20 27 20  ips) + '    # ' 
1470: 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20  + \.            
1480: 73 74 72 20 28 64 61 74 65 74 69 6d 65 2e 74 6f  str (datetime.to
1490: 64 61 79 20 28 29 29 20 2b 20 27 5c 6e 27 29 0a  day ()) + '\n').
14a0: 20 20 20 20 20 20 70 66 2e 63 6c 6f 73 65 20 28        pf.close (
14b0: 29 0a 20 20 20 20 20 20 73 2e 73 65 6e 64 5f 63  ).      s.send_c
14c0: 6d 64 20 28 27 71 75 69 74 27 29 0a 20 20 20 20  md ('quit').    
14d0: 20 20 70 64 70 5f 72 61 74 69 6f 20 3d 20 66 6c    pdp_ratio = fl
14e0: 6f 61 74 20 28 63 75 72 72 5f 69 70 73 29 20 2f  oat (curr_ips) /
14f0: 20 69 70 73 2e 70 64 70 38 69 0a 20 20 20 20 20   ips.pdp8i.     
1500: 20 72 70 69 5f 72 61 74 69 6f 20 3d 20 66 6c 6f   rpi_ratio = flo
1510: 61 74 20 28 63 75 72 72 5f 69 70 73 29 20 2f 20  at (curr_ips) / 
1520: 69 70 73 2e 72 61 73 70 62 65 72 72 79 5f 70 69  ips.raspberry_pi
1530: 5f 62 5f 70 6c 75 73 0a 20 20 20 20 20 20 70 72  _b_plus.      pr
1540: 69 6e 74 20 22 5c 6e 59 6f 75 72 20 73 79 73 74  int "\nYour syst
1550: 65 6d 20 69 73 20 22 20 2b 20 66 6f 72 6d 61 74  em is " + format
1560: 20 28 72 70 69 5f 72 61 74 69 6f 2c 20 27 2e 31   (rpi_ratio, '.1
1570: 66 27 29 20 2b 20 5c 0a 20 20 20 20 20 20 20 20  f') + \.        
1580: 20 20 22 20 74 69 6d 65 73 20 66 61 73 74 65 72    " times faster
1590: 20 74 68 61 6e 20 61 20 52 61 73 70 62 65 72 72   than a Raspberr
15a0: 79 20 50 69 20 4d 6f 64 65 6c 20 42 2b 22 0a 20  y Pi Model B+". 
15b0: 20 20 20 20 20 70 72 69 6e 74 20 22 6f 72 20 22       print "or "
15c0: 20 2b 20 66 6f 72 6d 61 74 20 28 70 64 70 5f 72   + format (pdp_r
15d0: 61 74 69 6f 2c 20 27 2e 31 66 27 29 20 2b 20 5c  atio, '.1f') + \
15e0: 0a 20 20 20 20 20 20 20 20 20 20 22 20 74 69 6d  .          " tim
15f0: 65 73 20 66 61 73 74 65 72 20 74 68 61 6e 20 61  es faster than a
1600: 20 50 44 50 2d 38 2f 49 2e 5c 6e 22 0a 20 20 65   PDP-8/I.\n".  e
1610: 6c 73 65 3a 0a 20 20 20 20 23 20 4e 6f 72 6d 61  lse:.    # Norma
1620: 6c 20 6d 6f 64 65 2e 20 20 50 6f 70 20 6f 75 74  l mode.  Pop out
1630: 20 74 6f 20 53 49 4d 48 20 61 6e 64 20 74 68 72   to SIMH and thr
1640: 6f 74 74 6c 65 20 69 74 20 64 6f 77 6e 20 74 6f  ottle it down to
1650: 20 61 20 72 61 74 65 0a 20 20 20 20 23 20 73 75   a rate.    # su
1660: 69 74 61 62 6c 65 20 66 6f 72 20 61 20 62 6c 69  itable for a bli
1670: 6e 6b 65 6e 6c 69 67 68 74 73 20 64 65 6d 6f 2e  nkenlights demo.
1680: 20 20 31 2f 31 37 20 6d 65 61 6e 73 20 53 49 4d    1/17 means SIM
1690: 48 20 72 75 6e 73 20 6f 6e 65 0a 20 20 20 20 23  H runs one.    #
16a0: 20 69 6e 73 74 72 75 63 74 69 6f 6e 20 74 68 65   instruction the
16b0: 6e 20 77 61 69 74 73 20 66 6f 72 20 31 37 6d 73  n waits for 17ms
16c0: 2c 20 79 69 65 6c 64 69 6e 67 20 7e 35 39 20 49  , yielding ~59 I
16d0: 50 53 2e 0a 20 20 20 20 74 69 6d 65 2e 73 6c 65  PS..    time.sle
16e0: 65 70 20 28 30 2e 30 32 29 20 20 20 23 20 46 49  ep (0.02)   # FI
16f0: 58 4d 45 3a 20 73 69 6d 75 6c 61 74 6f 72 20 63  XME: simulator c
1700: 68 6f 6b 65 73 20 6f 6e 20 27 63 6f 6e 74 27 20  hokes on 'cont' 
1710: 77 69 74 68 6f 75 74 20 74 68 69 73 0a 20 20 20  without this.   
1720: 20 73 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c   s.os8_send_ctrl
1730: 20 28 27 65 27 29 0a 20 20 20 20 73 2e 73 65 6e   ('e').    s.sen
1740: 64 5f 63 6d 64 20 28 27 73 65 74 20 74 68 72 6f  d_cmd ('set thro
1750: 74 74 6c 65 20 31 2f 31 37 27 29 0a 0a 20 20 20  ttle 1/17')..   
1760: 20 23 20 59 6f 75 20 63 61 6e 27 74 20 68 69 74   # You can't hit
1770: 20 43 74 72 6c 2d 45 20 77 68 69 6c 65 20 72 75   Ctrl-E while ru
1780: 6e 6e 69 6e 67 20 74 68 69 73 20 73 63 72 69 70  nning this scrip
1790: 74 20 69 6e 20 74 68 65 20 66 6f 72 65 67 72 6f  t in the foregro
17a0: 75 6e 64 0a 20 20 20 20 23 20 73 69 6e 63 65 20  und.    # since 
17b0: 70 65 78 70 65 63 74 20 74 61 6b 65 73 20 6f 76  pexpect takes ov
17c0: 65 72 20 73 74 64 69 6f 2e 20 20 54 68 65 72 65  er stdio.  There
17d0: 66 6f 72 65 2c 20 69 66 20 79 6f 75 20 77 61 6e  fore, if you wan
17e0: 74 20 74 6f 20 62 65 20 61 62 6c 65 0a 20 20 20  t to be able.   
17f0: 20 23 20 74 6f 20 73 65 6e 64 20 63 6f 6d 6d 61   # to send comma
1800: 6e 64 73 20 74 6f 20 74 68 65 20 73 69 6d 75 6c  nds to the simul
1810: 61 74 6f 72 20 77 68 69 6c 65 20 74 68 65 20 64  ator while the d
1820: 65 6d 6f 20 69 73 20 72 75 6e 6e 69 6e 67 2c 0a  emo is running,.
1830: 20 20 20 20 23 20 75 6e 63 6f 6d 6d 65 6e 74 20      # uncomment 
1840: 74 68 65 20 6c 69 6e 65 20 62 65 6c 6f 77 2c 20  the line below, 
1850: 77 68 69 63 68 20 77 69 6c 6c 20 6c 65 74 20 79  which will let y
1860: 6f 75 20 73 65 6e 64 20 63 6f 6d 6d 61 6e 64 73  ou send commands
1870: 20 74 6f 20 74 68 65 0a 20 20 20 20 23 20 73 69   to the.    # si
1880: 6d 75 6c 61 74 6f 72 20 76 69 61 20 74 65 6c 6e  mulator via teln
1890: 65 74 2e 20 20 46 72 6f 6d 20 61 6e 6f 74 68 65  et.  From anothe
18a0: 72 20 74 65 72 6d 69 6e 61 6c 20 6f 72 20 53 53  r terminal or SS
18b0: 48 20 73 65 73 73 69 6f 6e 3a 0a 20 20 20 20 23  H session:.    #
18c0: 0a 20 20 20 20 23 20 20 20 20 20 24 20 74 65 6c  .    #     $ tel
18d0: 6e 65 74 20 6c 6f 63 61 6c 68 6f 73 74 20 33 31  net localhost 31
18e0: 34 31 0a 20 20 20 20 23 0a 20 20 20 20 23 20 6f  41.    #.    # o
18f0: 72 20 66 72 6f 6d 20 61 20 72 65 6d 6f 74 65 20  r from a remote 
1900: 6d 61 63 68 69 6e 65 3a 0a 20 20 20 20 23 0a 20  machine:.    #. 
1910: 20 20 20 23 20 20 20 20 20 24 20 74 65 6c 6e 65     #     $ telne
1920: 74 20 31 39 32 2e 31 36 38 2e 31 2e 32 20 33 31  t 192.168.1.2 31
1930: 34 31 0a 20 20 20 20 23 0a 20 20 20 20 23 20 49  41.    #.    # I
1940: 74 27 73 20 64 69 73 61 62 6c 65 64 20 62 79 20  t's disabled by 
1950: 64 65 66 61 75 6c 74 20 62 65 63 61 75 73 65 20  default because 
1960: 53 49 4d 48 20 63 61 6e 27 74 20 62 65 20 6d 61  SIMH can't be ma
1970: 64 65 20 74 6f 20 6c 69 73 74 65 6e 20 6f 6e 6c  de to listen onl
1980: 79 0a 20 20 20 20 23 20 6f 6e 20 6c 6f 63 61 6c  y.    # on local
1990: 68 6f 73 74 2c 20 73 6f 20 64 6f 69 6e 67 20 74  host, so doing t
19a0: 68 69 73 20 6d 61 79 20 62 65 20 61 20 73 65 63  his may be a sec
19b0: 75 72 69 74 79 20 72 69 73 6b 2e 20 20 53 49 4d  urity risk.  SIM
19c0: 48 20 64 69 73 61 62 6c 65 73 0a 20 20 20 20 23  H disables.    #
19d0: 20 6f 62 76 69 6f 75 73 6c 79 2d 75 6e 73 61 66   obviously-unsaf
19e0: 65 20 63 6f 6d 6d 61 6e 64 73 20 6c 69 6b 65 20  e commands like 
19f0: 21 20 6f 6e 20 74 68 65 20 72 65 6d 6f 74 65 20  ! on the remote 
1a00: 63 6f 6e 73 6f 6c 65 2c 20 62 75 74 20 69 74 20  console, but it 
1a10: 69 73 0a 20 20 20 20 23 20 70 6f 73 73 69 62 6c  is.    # possibl
1a20: 65 20 73 6f 6d 65 20 6d 69 73 63 68 69 65 66 20  e some mischief 
1a30: 6d 61 79 20 62 65 20 70 6f 73 73 69 62 6c 65 20  may be possible 
1a40: 76 69 61 20 74 68 69 73 20 70 61 74 68 20 61 6e  via this path an
1a50: 79 77 61 79 2e 20 20 49 74 0a 20 20 20 20 23 20  yway.  It.    # 
1a60: 63 6f 75 6c 64 20 62 65 20 75 73 65 64 20 74 6f  could be used to
1a70: 20 65 78 66 69 6c 74 72 61 74 65 20 61 20 73 65   exfiltrate a se
1a80: 6e 73 69 74 69 76 65 20 66 69 6c 65 20 76 69 61  nsitive file via
1a90: 20 41 54 54 41 43 48 2c 20 66 6f 72 20 6f 6e 65   ATTACH, for one
1aa0: 0a 20 20 20 20 23 20 74 68 69 6e 67 2e 20 20 46  .    # thing.  F
1ab0: 6f 72 20 61 6e 6f 74 68 65 72 2c 20 69 74 27 73  or another, it's
1ac0: 20 61 20 70 6f 74 65 6e 74 69 61 6c 20 44 6f 53   a potential DoS
1ad0: 20 76 65 63 74 6f 72 2e 0a 20 20 20 20 23 73 2e   vector..    #s.
1ae0: 73 65 6e 64 5f 63 6d 64 20 28 27 73 65 74 20 72  send_cmd ('set r
1af0: 65 6d 6f 74 65 20 74 65 6c 6e 65 74 3d 33 31 34  emote telnet=314
1b00: 31 27 29 0a 0a 20 20 20 20 23 20 4c 65 74 20 69  1')..    # Let i
1b10: 74 20 72 75 6e 2e 20 20 4e 65 76 65 72 20 65 78  t run.  Never ex
1b20: 69 74 73 2e 0a 20 20 20 20 73 2e 73 65 6e 64 5f  its..    s.send_
1b30: 63 6d 64 20 28 27 63 6f 6e 74 27 29 0a 20 20 20  cmd ('cont').   
1b40: 20 73 2e 73 70 69 6e 20 28 29 0a 0a 0a 69 66 20   s.spin ()...if 
1b50: 5f 5f 6e 61 6d 65 5f 5f 20 3d 3d 20 22 5f 5f 6d  __name__ == "__m
1b60: 61 69 6e 5f 5f 22 3a 0a 20 20 20 20 6d 61 69 6e  ain__":.    main
1b70: 28 29 0a                                         ().