[Simh] some patches for the H316 simulator (v3.5-2)

Theo Engel theo.engel at hetnet.nl
Thu Mar 30 16:23:13 EST 2006


While playing with the H316 simulator (version 3.5-2) I solved a few problems 
which might be worthwhile to include in the distribution. Below you will find 
my code changes (from diff). I am running H316 under Linux. 
Short description of the problems/changes:

1) Running the simulator, executing a HLT (for example because of an STOP 
statement in a Fortran program) causes only the 1st character of a two 
character ST message to be printed. Printing of the 2nd character, which is 
in the event queue, is prevented because, due to the HLT, the event queue is 
not processed anymore. The change adds event queue processing as part of the 
HLT instruction processing so that the event queue is empty when going back 
to the monitor .(module h316_cpu.c)
2)  LLL 32 and LRL 32 do not work as expected (do not clear A and B).
ut = ut >> t1; does not clear ut in case t1 is 32, but keeps ut unchanged.
The change inserts a few lines to handle the shift for t1 == 32 as a special 
case. (module h316_cpu.c)
3) In the lineprinter module, the truncation of trailing blanks of a line to 
print is not working because the counter takes the wrong direction
(module h316_lp.c)
4) In the tty-papertape reader routine, the LF handling is wrong because the 
LF_PEND flag is not reset after outputting an LF (module h316_stddev.c)
5) In the tty-papertape punch routine, the puncher is not stopped correctly 
because the RUNNING flag is not reset correctly after the delay.(module 
h316_stddev.c)

With these changes the simulator is running well with the standard devices: 
tty1,2,3 the ptr and the ptp, running the assembler (DAP16) , the linker and 
the fortran system which software I copied from Philipp Hachtmann and Adrian 
Wise websites.
Thanks for the provision of the simulation software, and with kind regards,
Theo Engel








-------------- next part --------------
*** simhv35-2org/H316/h316_cpu.c        Thu Sep 22 16:01:00 2005
--- simhv35-2t/H316/h316_cpu.c  Fri Mar 17 15:15:36 2006
*************** t_stat cpu_show_dma (FILE *st, UNIT *upt
*** 278,285 ****
--- 278,288 ----
  t_stat cpu_set_nchan (UNIT *uptr, int32 val, char *cptr, void *desc);
  t_stat cpu_show_nchan (FILE *st, UNIT *uptr, int32 val, void *desc);

+
  extern t_stat fprint_sym (FILE *of, t_addr addr, t_value *val,
      UNIT *uptr, int32 sw);
+ extern t_stat sim_process_event (void);        /*####ADDED####*/
+

  /* CPU data structures

*************** switch (I_GETOP (MB)) {
*** 659,664 ****
--- 662,668 ----

      case 000:
          if ((MB & 1) == 0) {                            /* HLT */
+                       sim_process_event ();   /*#####ADDED#######*/
              reason = STOP_HALT;
              break;
              }
*************** switch (I_GETOP (MB)) {
*** 728,733 ****
--- 732,745 ----
          017     =       short arith rotate left, C = overflow
  */

+ /* ############################## ADDED ############################### */
+ /* LLL 32 and LRL 32 do not work as expected (do not clear A and B)
+    In the code below these instructions make that a ut = ut << 32 or
+    ut = ut >> 32 is executed. A separate test program shows that that
+    code does not make ut = 0 but just left ut unchanged (compiler error???)
+    So therefor a few lines of extra code to handle the shift 32 cases */
+ /* #################################################################### */
+
      case 020:
          C = 0;                                          /* clear C */
          sc = 0;                                         /* clear sc */
*************** switch (I_GETOP (MB)) {
*** 739,745 ****
--- 751,762 ----
              else {
                  ut = GETDBL_U (AR, BR);                 /* get A'B */
                  C = (ut >> (t1 - 1)) & 1;               /* C = last out */
+                               if(t1 == 32) {                          /* #####ADDED##### */
+                                          ut = 0;                          /* #####ADDED##### */
+                                       }                                   /* #####ADDED##### */
+                               else {                                  /* #####ADDED##### */
                                       ut = ut >> t1;                   /* log right */
+                                       }                                   /* #####ADDED##### */
                        }
              PUTDBL_U (ut);                              /* store A,B */
              break;
*************** switch (I_GETOP (MB)) {
*** 803,809 ****
--- 820,832 ----
              else {
                  ut = GETDBL_U (AR, BR);                 /* get A'B */
                  C = (ut >> (32 - t1)) & 1;              /* C = last out */
+                               if(t1 == 32) {                          /* #####ADDED##### */
+                                         ut = 0;                           /* #####ADDED##### */
+                                       }                                   /* #####ADDED##### */
+                               else {                                  /* #####ADDED##### */
                        ut = ut << t1;                    /* log left */
+                                       }                                   /* #####ADDED##### */
+
                  }
              PUTDBL_U (ut);                              /* store A,B */
              break;

diff -EbBap simhv35-2org/H316/h316_lp.c simhv35-2t/H316/h316_lp.c
*** simhv35-2org/H316/h316_lp.c Fri Aug 26 21:48:00 2005
--- simhv35-2t/H316/h316_lp.c   Sun Feb 26 23:31:12 2006
*************** if (lpt_svcst & LPT_SVCSH) {
*** 298,304 ****
      }
  if (lpt_svcst & LPT_SVCPA) {                            /* paper advance */
      SET_INT (INT_LPT);                                  /* interrupt */
!     for (i = LPT_WIDTH - 1; i >= 0; i++)  {
          if (lpt_buf[i] != ' ') break;
          }
      lpt_buf[i + 1] = 0;
--- 298,304 ----
      }
  if (lpt_svcst & LPT_SVCPA) {                            /* paper advance */
      SET_INT (INT_LPT);                                  /* interrupt */
!     for (i = LPT_WIDTH - 1; i >= 0; i--)  {             /* ####################### ++ changed into -- ##############*/
          if (lpt_buf[i] != ' ') break;
          }
      lpt_buf[i + 1] = 0;
diff -EbBap simhv35-2org/H316/h316_stddev.c simhv35-2t/H316/h316_stddev.c
*** simhv35-2org/H316/h316_stddev.c     Tue Nov 22 22:09:00 2005
--- simhv35-2t/H316/h316_stddev.c       Thu Feb 16 11:56:31 2006
*************** else if ((ruptr->flags & UNIT_ATT) &&
*** 608,614 ****
      (ruptr->STA & RUNNING)) {                           /* and running? */
      if (ruptr->STA & LF_PEND) {                         /* lf pending? */
          c = 0212;                                       /* char is lf */
!         ruptr->STA &= LF_PEND;                          /* clear flag */
          }
      else {                                              /* normal read */
          if ((c = getc (ruptr->fileref)) == EOF) {       /* read byte */
--- 608,614 ----
      (ruptr->STA & RUNNING)) {                           /* and running? */
      if (ruptr->STA & LF_PEND) {                         /* lf pending? */
          c = 0212;                                       /* char is lf */
!         ruptr->STA &= ~LF_PEND;                          /* clear flag */
          }
      else {                                              /* normal read */
          if ((c = getc (ruptr->fileref)) == EOF) {       /* read byte */
*************** if (ttp_tape_rcvd != 0) {
*** 665,671 ****
  else if (c7b == TAPE) ttp_tape_rcvd = 2;                /* char = TAPE? */
  if (ttp_xoff_rcvd != 0) {                               /* prev = XOFF? */
      ttp_xoff_rcvd--;                                    /* decrement state */
!     if (ttp_xoff_rcvd == 0) puptr->STA &= RUNNING;      /* stop after delay */
      }
  else if (c7b == XOFF) ttp_xoff_rcvd = 2;                /* char = XOFF? */
  if ((c7b == XON) && (ruptr->flags & UNIT_ATT)) {        /* char = XON? */
--- 665,671 ----
  else if (c7b == TAPE) ttp_tape_rcvd = 2;                /* char = TAPE? */
  if (ttp_xoff_rcvd != 0) {                               /* prev = XOFF? */
      ttp_xoff_rcvd--;                                    /* decrement state */
!     if (ttp_xoff_rcvd == 0) puptr->STA &= ~RUNNING;      /* stop after delay */
      }
  else if (c7b == XOFF) ttp_xoff_rcvd = 2;                /* char = XOFF? */
  if ((c7b == XON) && (ruptr->flags & UNIT_ATT)) {        /* char = XON? */



More information about the Simh mailing list