From c97f4664570579c4e7d5e9e8da041922b2105c71 Mon Sep 17 00:00:00 2001 From: Bob Supnik Date: Thu, 30 Mar 2017 07:12:57 -0700 Subject: [PATCH] PDP8: Annotate fall through paths in switch statements The code is a bit difficult to understand, but it represents the 'normal' path for processing a DECtape word. The code always flows all the way to the break. For start of block, there's extra code to check for a timing error; but then the first word is processed (case 0). For a normal word, a 3-cycle data break is done - increment word count and current address, check for word count overflow, put the word in the buffer; but then check for end of block (case DTO_WCO). If the word count has already overflowed, just check for end of block. So yes, the end of case 0 should be labeled 'fall through' as well. FNC_WRIT has the same structure and needs the same comment. --- PDP8/pdp8_dt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PDP8/pdp8_dt.c b/PDP8/pdp8_dt.c index fb7d7bed..7685fa74 100644 --- a/PDP8/pdp8_dt.c +++ b/PDP8/pdp8_dt.c @@ -798,11 +798,12 @@ switch (fnc) { /* at speed, check fnc * return SCPE_OK; } if (DEBUG_PRI (dt_dev, LOG_RW) || - (DEBUG_PRI (dt_dev, LOG_BL) && (blk == dt_logblk))) + (DEBUG_PRI (dt_dev, LOG_BL) && (blk == dt_logblk))) fprintf (sim_deb, ">>DT%d: reading block %d %s%s\n", unum, blk, (dir? "backward": "forward"), ((dtsa & DTA_MODE)? " continuous": " ")); - dt_substate = 0; /* fall through */ + dt_substate = 0; + /* fall through */ case 0: /* normal read */ M[DT_WC] = (M[DT_WC] + 1) & 07777; /* incr WC, CA */ M[DT_CA] = (M[DT_CA] + 1) & 07777; @@ -815,6 +816,7 @@ switch (fnc) { /* at speed, check fnc * M[ma] = dat; if (M[DT_WC] == 0) /* wc ovf? */ dt_substate = DTO_WCO; + /* fall through */ case DTO_WCO: /* wc ovf, not sob */ if (wrd != (dir? 0: DTU_BSIZE (uptr) - 1)) /* not last? */ sim_activate (uptr, DT_WSIZE * dt_ltime); @@ -861,10 +863,12 @@ switch (fnc) { /* at speed, check fnc * fprintf (sim_deb, ">>DT%d: writing block %d %s%s\n", unum, blk, (dir? "backward": "forward"), ((dtsa & DTA_MODE)? " continuous": " ")); - dt_substate = 0; /* fall through */ + dt_substate = 0; + /* fall through */ case 0: /* normal write */ M[DT_WC] = (M[DT_WC] + 1) & 07777; /* incr WC, CA */ M[DT_CA] = (M[DT_CA] + 1) & 07777; + /* fall through */ case DTO_WCO: /* wc ovflo */ ma = DTB_GETMEX (dtsb) | M[DT_CA]; /* get mem addr */ ba = (blk * DTU_BSIZE (uptr)) + wrd; /* buffer ptr */