return to main page

Auto Coder Examples

A programmer's tool kit of examples -
This is how you can do what.

Here is an on-line pdf of IBM's 1401 Reference Manual A24-1403-5 with a good description of the commands,
and a link to Ron Mak's 1401 Software Development, a GREAT software development package.


Dan McInnis's DAP (Demonstration Assurance Program) as of August 4, 2007

It has been tested except for tape, which wasn't running at that time.

I have also " improved" it by introducing sense switch control over the various functions (DAP-E). This has not been tested on the 1401. It does run in SIMH. I started testing it last Volunteer Saturday but had some """Keypunch""" errors and had to quit. Maybe will get time to try again this Saturday.

Both programs were complled in ROPE but had to be run in SIMH command mode since they need a data card to follow the last object card.

Cheers

Dan

Source code


               JOB  1401 Demonstration Assurance Program (DAP)                                
     *         CTL  6611
     ***************************************************************************
     *
     *     
     *     Provide a program to assure all components of the
     *     1401 System are operational. To be used by demonstrators
     *     before running demonstrations for Museum visitors. 
     *
     *     Program written in Autocoder
     *     Programmer:  Dan McInnis  
     *     Date:        April 16, 2007 
     *     
     ****************************************************************************
     *
               ORG  333
     *
     *
     *     Clear card reader storage and set word mark at location 1
     *
     BEGIN     CS   080
               SW   001
     *     Clear print storage           
     START     CS   332
               CS
               H                            *halt check printer,punch,tape
     * Read data card and test validity 
               CC   A                       *skip paper to channel 1 
               R                            *read data card
               B    RDERR,?                 *read error
     CLOOP     C    012,CDDATA              *compare 12 chars in card area
               BU   RDERR                   *branch if unequal -  read error 
               SW   *-14                    *set word mark for add
               A    @12@,*-19               *add 12 to card area address
               C    *-26,@084@              *compare address last full area
               BE   ENDRD                   *if last go to next compare
               CW   *-37                    *clear word mark from address
               B    CLOOP                   *go back to compare again
     ENDRD     SW   073                     *last area set word mark
               C    80,CDDATA-4             *compare 8 characters 
               BU   RDERR                   *branch if unequal- read error
               CW   073                     *clear word markread area
               MCW  080,280                 *move card data print area
               CC   K                       *double space
               W                            *print data
               CC   K                       *double space
               MCW  080,280                 *
               W                            *print data
               MCW  080,180                 *move data to punch area
               P                            *punch card 
               B    PCERR,!                 *punch error 
     TAPE      LCA  GRPMRK,081              *group mark to 81
               CS   299                     *clear print area
               LCA  GRPMRK,281              *group mark to 281
               RWD  1                       *rewind tape 1
               WT   1,001                   *write card area to tape 1
               BER  TPERR                   *if tape transmission error
               WT   1,001                   *write second record
               BER  TPERR                   *tape error
               BSP  1                       *backspace over last record
               BER  TPERR                   *tape error
               RT   1,201                   *read in first record
               BER  TPERR                   *tape error
               SW   001                     *SW READ AREA
               SW   201                     *SW PRINT AREA
               C    212,CDDATA              *compare first 12 chars
               BU   TPER1                   *tape error
               CC   J                       *double space 
               W                            *print tape data
               RWD  1                       *rewind tape
               CS   299                     *clear print area
               CC   A                       *skip paper to beginning
     END       H    START                   *restart program
     *  START OF ERROR HALT LOCATIONS 
     TPER1     H                            *DEBUG HALT INST
               MCW  @TAPE COMPARE ERROR@,260 *DEBUG INSTRUCTION
               W
               H    END
     PCERR     H    END
     RDERR     H    END
     PTERR     H    END
     TPERR     H    END
     *  START OF LITERAL LOCATION
     CDDATA    DCW  @0123456789SK@          *data 
     GRPMRK    DCW  @"@                     *group mark   
               END  BEGIN

 

Listing


 CLEAR STORAGE 1     ,008015,019026,030,034041,045,053,0570571026                                                 1
 CLEAR STORAGE 2     L068112,102106,113/101099/I99,027A070028)027B0010270B0261,001/001113I0                       2
 BOOTSTRAP           ,008015,022029,036040,047054,061068,072/061039              ,0010011040                      3
0                          1401 DEMONSTRATION ASSURANCE PROGRAM (DAP)                                     PAGE    1
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  101                JOB   1401 DEMONSTRATION ASSURANCE PROGRAM (DAP)
  102         *         CTL  6611
  103         ***************************************************************************
  104         *
  105         *
  106         *     PROVIDE A PROGRAM TO ASSURE ALL COMPONENTS OF THE
  107         *     1401 SYSTEM ARE OPERATIONAL. TO BE USED BY DEMONSTRATORS
  108         *     BEFORE RUNNING DEMONSTRATIONS FOR MUSEUM VISITORS.
  109         *
  110         *     PROGRAM WRITTEN IN AUTOCODER
  111         *     PROGRAMMER:  DAN MCINNIS
  112         *     DATE:        APRIL 16, 2007
  113         *
  114         ***************************************************************************
  115         *
  116                ORG   333                                                                0333
  117         *
  118         *
  119         *     CLEAR CARD READER STORAGE AND SET WORD MARK AT LOCATION 1
  120         *
  121         BEGIN  CS    080                                                      4  0333  / 080                4
  122                SW    001                                                      4  0337  , 001                4
  123         *     CLEAR PRINT STORAGE
  124         START  CS    332                                                      4  0341  / 332                4
  125                CS                                                             1  0345  /                    4
  126                H                             *HALT CHECK PRINTER,PUNCH,TA     1  0346  .                    4
  127         * READ DATA CARD AND TEST VALIDITY
  128                CC    A                       *SKIP PAPER TO CHANNEL 1         2  0347  F A                  4
  129                R                             *READ DATA CARD                  1  0349  1                    4
  130                B     RDERR,?                 *READ ERROR                      5  0350  B 578 ?              5
  131         CLOOP  C     012,CDDATA              *COMPARE 12 CHARS IN CARD AR     7  0355  C 012 601            5
  132                BU    RDERR                   *BRANCH IF UNEQUAL -  READ E     5  0362  B 578 /              5
  133                SW    *-14                    *SET WORD MARK FOR ADD           4  0367  , 356                5
  134                A     @12@,*-19               *ADD 12 TO CARD AREA ADDRESS     7  0371  A 604 358            5
  135                C     *-26,@084@              *COMPARE ADDRESS LAST FULL A     7  0378  C 358 607            5
  136                BE    ENDRD                   *IF LAST GO TO NEXT COMPARE      5  0385  B 398 S              6
  137                CW    *-37                    *CLEAR WORD MARK FROM ADDRES     4  0390  ) 356                6
  138                B     CLOOP                   *GO BACK TO COMPARE AGAIN        4  0394  B 355                6
  139         ENDRD  SW    073                     *LAST AREA SET WORD MARK         4  0398  , 073                6
  140                C     80,CDDATA-4             *COMPARE 8 CHARACTERS            7  0402  C 080 597            6
  141                BU    RDERR                   *BRANCH IF UNEQUAL- READ ERR     5  0409  B 578 /              6
  142                CW    073                     *CLEAR WORD MARKREAD AREA        4  0414  ) 073                6
  143                MCW   080,280                 *MOVE CARD DATA PRINT AREA       7  0418  M 080 280            7
  144                CC    K                       *DOUBLE SPACE                    2  0425  F K                  7
  145                W                             *PRINT DATA                      1  0427  2                    7
  146                CC    K                       *DOUBLE SPACE                    2  0428  F K                  7
  147                MCW   080,280                 *                                7  0430  M 080 280            7
1                          1401 DEMONSTRATION ASSURANCE PROGRAM (DAP)                                     PAGE    2
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  148                W                             *PRINT DATA                      1  0437  2                    7
  149                MCW   080,180                 *MOVE DATA TO PUNCH AREA         7  0438  M 080 180            7
  150                P                             *PUNCH CARD                      1  0445  4                    8
  151                B     PCERR,!                 *PUNCH ERROR                     5  0446  B 574 !              8
  152         TAPE   LCA   GRPMRK,081              *GROUP MARK TO 81                7  0451  L 602 081            8
  153                CS    299                     *CLEAR PRINT AREA                4  0458  / 299                8
  154                LCA   GRPMRK,281              *GROUP MARK TO 281               7  0462  L 602 281            8
  155                RWD   1                       *REWIND TAPE 1                   5  0469  U %U1 R              8
  156                WT    1,001                   *WRITE CARD AREA TO TAPE 1       8  0474  M %U1 001 W          8
  157                BER   TPERR                   *IF TAPE TRANSMISSION ERROR      5  0482  B 586 L              9
  158                WT    1,001                   *WRITE SECOND RECORD             8  0487  M %U1 001 W          9
  159                BER   TPERR                   *TAPE ERROR                      5  0495  B 586 L              9
  160                BSP   1                       *BACKSPACE OVER LAST RECORD      5  0500  U %U1 B              9
  161                BER   TPERR                   *TAPE ERROR                      5  0505  B 586 L              9
  162                RT    1,201                   *READ IN FIRST RECORD            8  0510  M %U1 201 R          9
  163                BER   TPERR                   *TAPE ERROR                      5  0518  B 586 L             10
  164                SW    001                     *SW READ AREA                    4  0523  , 001               10
  165                SW    201                     *SW PRINT AREA                   4  0527  , 201               10
  166                C     212,CDDATA              *COMPARE FIRST 12 CHARS          7  0531  C 212 601           10
  167                BU    TPER1                   *TAPE ERROR                      5  0538  B 561 /             10
  168                CC    J                       *DOUBLE SPACE                    2  0543  F J                 10
  169                W                             *PRINT TAPE DATA                 1  0545  2                   10
  170                RWD   1                       *REWIND TAPE                     5  0546  U %U1 R             11
  171                CS    299                     *CLEAR PRINT AREA                4  0551  / 299               11
  172                CC    A                       *SKIP PAPER TO BEGINNING         2  0555  F A                 11
  173         END    H     START                   *RESTART PROGRAM                 4  0557  . 341               11
  174         *  START OF ERROR HALT LOCATIONS
  175         TPER1  H                             *DEBUG HALT INST                 1  0561  .                   11
  176                MCW   @TAPE COMPARE ERROR@,260 *DEBUG INSTRUCTION              7  0562  M 625 260           11
  177                W                                                              1  0569  2                   11
  178                H     END                                                      4  0570  . 557               12
  179         PCERR  H     END                                                      4  0574  . 557               12
  180         RDERR  H     END                                                      4  0578  . 557               12
  181         PTERR  H     END                                                      4  0582  . 557               12
  182         TPERR  H     END                                                      4  0586  . 557               12
  183         *  START OF LITERAL LOCATION
  184         CDDATA DCW   @0123456789SK@          *DATA                           12  0601                      12
  185         GRPMRK DCW   @"@                     *GROUP MARK                      1  0602              GMARK   12
                     DCW   @12@                                                     2  0604              LIT     13
                     DCW   @084@                                                    3  0607              LIT     13
                     DCW   @TAPE COMPARE ERROR@                                    18  0625              LIT     13
  186                END   BEGIN                                                             / 333 080
1                          1401 DEMONSTRATION ASSURANCE PROGRAM (DAP)                                     PAGE    3
0SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  

 BEGIN     333    CDDATA    601    CLOOP     355    END       557    ENDRD     398    GRPMRK    602    PCERR     574   
 PTERR     582    RDERR     578    START     341    TAPE      451    TPER1     561    TPERR     586   

 

Object deck



,008015,019026,030,034041,045,053,0570571026                           0001     
L068112,102106,113/101099/I99,027A070028)027B0010270B0261,001/001113I0 0002     
,008015,022029,036040,047054,061068,072/061039              ,00100110400003     
/080,001/332/.FA1                      L017349,337341,345346,34734910400004     
B578?C012601B578/,356A604358C358607    L035384,355362,367371,37804010400005     
B398S)356B355,073C080597B578/)073      L033417,390394,398402,40941410400006     
M080280FK2FKM0802802M080180            L027444,425427,428430,43743810400007     
4B574!L602081/299L602281U%U1RM%U1001W  L037481,446451,458462,46947410400008     
B586LM%U1001WB586LU%U1BB586LM%U1201R   L036517,487495,500505,51004010400009     
B586L,001,201C212601B561/FJ2           L028545,523527,531538,54354510400010     
U%U1R/299FA.341.M6252602               L024569,551555,557561,56256910400011     
.557.557.557.557.5570123456789SK"      L033602,574578,582586,59060210400012     
12084TAPE COMPARE ERROR                L023625,605608,040040,04004010400013     
                                       /333080                         0014  
0123456789SK0123456789SK0123456789SK0123456789SK0123456789SK0123456789SK01234567

 


from Stan Paddock

          ***************************************************************************
     *     SSSSS = CARD SEQUENCE NUMBER          ********** = LABEL
     *     OPER- = OPERATION                     OPERATION--- = OPERATION
SSSSS**********OPER-OPERANDS----------------------------------------------------     **********|****|***********************************************************
               JOB  FIRST PROGRAM
               CTL  6611  *6=16,000C;6=16,000T;1=OBJDECK;,1=MODADD     
     READ      EQU  001                 *DEFINE FRIST CHARACTER OF READ BUFFER
     PUNCH     EQU  101                 *DEFINE FIRST CHARACTER OF PUNCH BUFFER
     PRINT     EQU  201                 *DEFINE FIRST CHARACTER OF PRINT BUFFER
               ORG  87
     X1        DCW  000                 *INDEX REGISTER 1
               DCW  11                  *IDENTIFING FILLER
     X2        DCW  000                 *INDEX REGISTER 2
               DCW  22                  *IDENTIFING FILLER
     X3        DCW  000                 *INDEX REGISTER 3
               DCW  33                  *IDENTIFING FILLER
     *
               ORG  340                 *ORG JUST AFTER PRINT BUFFER
     *
     IDENT     DCW  @IBM 1401 PROGRAM FIRST 2/19/2008@  *ID THE PROGRAM DECK
     *
     *
     START     H                        *HALT TO ALLOW PATCHING IF REQUIRED
     *
     *                                  *CLEAR READ BUFFER AND SET WM
               CS   080                 *CLEAR 080 TO 000
               SW   001                 *SET A WORD MARK AT THE BEGINNING
     *
     *                                  *CLEAR PUNCH BUFFER AND SET WM
               CS   180                 *CLEAR 180 TO 101
               SW   101                 *SET A WORD MARK AT THE BEGINNING
     *
     *                                  *CLEAR PRINT BUFFER AND SET WM
               CS   332                 *CLEAR 332 TO 300
               CS                       *CLEAR 299 TO 200            
               SW   201                 *SET A WORD MARK AT THE BEGINNING                 
     *                                  
     *********************************************************************
     *         UP TO THIS POINT IS BOILER PLATE AND CAN BE USED AS THE
     *         START OF ANY PROGRAM.
     *********************************************************************
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL READ ONE CARD FROM THE CARD READER 
     *         AND PLACE IT IN MEMORY LOCATIONS 001 THROUGH 080
     *********************************************************************
     *
               B    P10
     P1        R                        *READ A CARD
               H    P2                  *HALT SO YOU CAN EXAMINE 001-080
     *                                  *THEN GO TO P2
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL MOVE THE CARD DATA FROM THE READ BUFFER
     *         TO THE PUNCH BUFFER AND PUNCH THE CARD.
     *         THIS WILL BE FOLLOWED BY A BLANK CARD TO GET THE PUCHED CARD
     *         OUT OF THE PUNCH.
     *********************************************************************
     *
     P2        MCW  READ&79,PUNCH&79    *MOVE THE DATA (& = +)
               P                        *PUNCH
     *                                  *CLEAR PUNCH BUFFER AND SET WM
               CS   180                 *CLEAR 180 TO 101
               SW   101                 *SET A WORD MARK AT THE BEGINNING
               P                        *PUNCH A BLANK CARD
               H    P3                  *HALT THEN GO TO P3
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL MOVE THE CARD DATA FROM THE READ BUFFER
     *         TO THE PRINT BUFFER AND PRINT THE CARD DATA.
     *         THIS WILL BE FOLLOWED BY A FOUR BLANK LINES TO GET THE PRINTED
     *         DATA UP TO BE SEEN.
     *********************************************************************
     *
     P3        MCW  READ&79,PRINT&79    *MOVE THE DATA (& = +)
               W                        *WRITE THE PRINT LINE
     *                                  *CLEAR PUNCH BUFFER AND SET WM
               CS   280                 *CLEAR 280 TO 201
               SW   201                 *SET A WORD MARK AT THE BEGINNING
               W                        *WRITE THE PRINT LINE         
               W                        *WRITE THE PRINT LINE
               W                        *WRITE THE PRINT LINE
               W                        *WRITE THE PRINT LINE
               H    P4                  *HALT THEN GO TO P4
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL:
     *            1.  INCREMENT A COUNTER
     *            2.  MOVE THE COUNTER TO THE PRINT LINE SUPRESSING ZEROS
     *            3.  lOOP 20 TIMES
     *            4.  PRINT 4 BLANK LINES
     *********************************************************************
     *
     MYCNTR    DCW  0000                *A GENERIC 4 DIGIT FILED STARTING AT 0
     LOOPC     DCW  000                 *A GENERIC 3 DIGIT COUNTER STARTING AT 0
     MYTXT     DCW  @THIS IS LINE NUMBER @  *FILLER TEXT
     *
     P4        MCW  MYTXT,PRINT&22      *MOVE IN THE FILLER TEXT
     P41       A    &1,MYCNTR           *ADD NUMERICAL LITERIAL TO COUNTER
               MCS  MYCNTR,PRINT&25     *MOVE AND SUPPRESS ZERO
               W                        *WRITE A PRINT LINE
               A    &1,LOOPC            *ADD NUMERICAL LITERIAL TO LOOP COUNTER
               B    P42,LOOPC-1,2       *IF YOU HAVE 20, CUT OUT
               B    P41                 *LETS GO BACK AND DO IT AGAIN
     *
     *                                  *PRINT FOUR BLANK LINES
     P42       CS   280                 *CLEAR 280 TO 201
               SW   201                 *SET A WORD MARK AT THE BEGINNING
               W                        *WRITE THE PRINT LINE         
               W                        *WRITE THE PRINT LINE
               W                        *WRITE THE PRINT LINE
               W                        *WRITE THE PRINT LINE
               H    P5                  *HALT THEN GO TO P5 
     *
     *********************************************************************
     *         THE IBM 1401 ALLOWS THE DEFINITION OF A NUMERIC FIELD TO BE
     *         ANY SIZE THAT WILL FIT IN MEMORY. THE HARDWARE PERFORMS 
     *         INTEGER ARITHMATIC. fOR MONEY, THE UNITS ARE PENNEYS.
     *         MYMONEY    DCW    12345  IS 123.45. THE REAL PLACEMENT OF 
     *         THE DECIMAL IS DONE BY THE PROGRAMMER.
     *         WHEN MATH IS PERFORMED, THE ZONE BITS IN THE UNITS POSITION
     *         MAY BE SET ACCORDING TO THE SIGN OF THE FIELD. iF YOU KNOW 
     *         THE FIELD IS POSITIVE AND YOU WANT TO SEE THE VALUE IM MEMORY,
     *         YOU CAN USE THE FOLLING TRICK:
     *                    MZ   MYMONEY-1,MYMONEY
     *         THE SECOND TO LAST CHARACTER IN MYMONEY NEVER HAS ZONE BITS.
     *         BY MOVING THE BLANK ZONE BITS TO THE LAST CHARACTER, 
     *         YOU CLEAR THE SIGN ZONE BITS FOR THE FIELD. 
     *         
     *********************************************************************
     *
     ITEM1     DCW  &1235               *FOR THIS CASE, THIS IS $12.35
     ITEM2     DCW  &050                *FOR THIS CASE, THIS IS $.50
     ACCUM     DCW  000000              *FOR THIS CASE, THIS IS $0,000.00
     *
     P5        H
               A    ITEM1,ACCUM         *ADD IN THE PROFIT
               S    ITEM2,ACCUM         *SUBTRACT THE LOSS
     *
     *         THESE NUMBERS CAN BE SHOWN AS
     *
               MCW  @ITEM1 = @,PRINT&10 *MOVE IN TEXT
               MCW  ITEM1,PRINT&20      *MOVE IN VALUE
               MCW  @ITEM2 = @,PRINT&30 *MOVE IN TEXT
               MCW  ITEM2,PRINT&40      *MOVE IN VALUE
               MCW  @DIFFER = @,PRINT&50 *MOVE IN TEXT
               MCW  ACCUM,PRINT&60      *MOVE IN VALUE
               W                        *PRINT THE LINE
               CS   299                 *CLEAR THE PRINT LINE
     *
     *         THESE NUMBERS CAN BE SHOWN AS USING MOVE AND SUPPRESS ZERO
     *
               MCW  @ITEM1 = @,PRINT&10 *MOVE IN TEXT
               MCS  ITEM1,PRINT&20     *MOVE IN VALUE
               MCW  @ITEM2 = @,PRINT&30 *MOVE IN TEXT
               MCS  ITEM2,PRINT&40      *MOVE IN VALUE
               MCW  @DIFFER = @,PRINT&50 *MOVE IN TEXT
               MCS  ACCUM,PRINT&60      *MOVE IN VALUE
               W                        *PRINT THE LINE
               CS   299                 *CLEAR THE PRINT LINE
     *
     *         THESE NUMBERS CAN BE SHOWN AS USING MOVE AND EDIT
     *         MCE IS DIFFICULT TO UNDERSTAND
     *         YOU HAVE TO MOVE THE FORMAT FIELD WITH A WORD MARK
     *         TO THE PRINT BUFFER AND THEN MOVE THE NUMERIC VALUE
     *         ON TOP OF IT. TAKES A LOT OF PLAYING WITH IT TO
     *         FULLY UNDERSTAND HOW IT WORKS
     *
     P53       MCW  @ITEM1 = @,PRINT&10 *MOVE IN TEXT
               LCA  @$ 0.00@,PRINT&20   *MOVE IN EDIT MASK
               MCE  ITEM1,PRINT&20      *MOVE IN VALUE
     *
               MCW  @ITEM2 = @,PRINT&30 *MOVE IN TEXT
               LCA  @$0.00@,PRINT&40    *MOVE IN EDIT MASK
               MCE  ITEM2,PRINT&40      *MOVE IN VALUE
     *
               MCW  @DIFFER = @,PRINT&50 *MOVE IN TEXT
               LCA  @$  ,  0.00@,PRINT&60 *MOVE IN EDIT MASK
               MCE  ACCUM,PRINT&60      *MOVE IN VALUE
     *
               W                        *PRINT THE LINE
               CS   299                 *CLEAR THE PRINT LINE
               H    P6
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL:
     *            1.  TEST SENSE SWITCHES B THROUGH G
     *            2.  SENSE SWITCH A IS NOT TESTED HERE BECAUSE IT IS ASSOCIATED
     *                WITH END-OF-CARDS ON THE 1402
     *            3.  IF ANY OF THESE SWITCHES ARE ON, THEY WILL BE
     *                IDENTIFIED ON THE PRINTER
     *            4.  AS LONG AS ANY SWITCHS ARE ON, THIS CODE WILL REPEATE
     *********************************************************************
     *
     ONTEST    DCW  0                   *TEST INDICATOR
     SWMSG     DCW  @SENSE SWITCH X IS ON@
     SWPOS     EQU  216                 *PRINT POSITION FOR SENSE SWITCH
     P6        H                        *START OF P6 CODE
               MCW  @0@,ONTEST          *INITIALIZE ONTEST
               CS   332                 *CLEAR PRINT STORAGE
               CS                       *CLEAR PRINT STORAGE
               SW   201                 *SET A WM AT THE START
               MCW  SWMSG,222          *SET UP THE MESSAGE
               B    P6B,B               *BRANCH TO P6B IF SENSE SW B IS ON
               B    P6BX                *IF NOT, CHECK THE NEXT
     P6B       MCW  @B@,SWPOS             *IDENTIFY WHICH SENSE SWITCH
               W                        *PRINT IT OUT
               MCW  @1@,ONTEST          *SAY WE FOUND ONE
     P6BX      NOP                      *JUST FOR CLARITY
               B    P6C,C               *BRANCH TO P6B IF SENSE SW B IS ON
               B    P6CX                *IF NOT, CHECK THE NEXT
     P6C       MCW  @C@,SWPOS            *IDENTIFY WHICH SENSE SWITCH
               W                        *PRINT IT OUT
               MCW  @1@,ONTEST          *SAY WE FOUND ONE
     P6CX      NOP                      *JUST FOR CLARITY
               B    P6D,D               *BRANCH TO P6B IF SENSE SW B IS ON
               B    P6DX                *IF NOT, CHECK THE NEXT
     P6D       MCW  @D@,SWPOS           *IDENTIFY WHICH SENSE SWITCH
               W                        *PRINT IT OUT
               MCW  @1@,ONTEST          *SAY WE FOUND ONE
     P6DX      NOP                      *JUST FOR CLARITY
               B    P6E,E               *BRANCH TO P6B IF SENSE SW B IS ON
               B    P6EX                *IF NOT, CHECK THE NEXT
     P6E       MCW  @E@,SWPOS           *IDENTIFY WHICH SENSE SWITCH
               W                        *PRINT IT OUT
               MCW  @1@,ONTEST          *SAY WE FOUND ONE
     P6EX      NOP                      *JUST FOR CLARITY
               B    P6F,F               *BRANCH TO P6B IF SENSE SW B IS ON
               B    P6FX                *IF NOT, CHECK THE NEXT
     P6F       MCW  @F@,SWPOS           *IDENTIFY WHICH SENSE SWITCH
               W                        *PRINT IT OUT
               MCW  @1@,ONTEST          *SAY WE FOUND ONE
     P6FX      NOP                      *JUST FOR CLARITY
               B    P6G,G               *BRANCH TO P6B IF SENSE SW B IS ON
               B    P6GX                *IF NOT, CHECK THE NEXT
     P6G       MCW  @G@,SWPOS           *IDENTIFY WHICH SENSE SWITCH
               W                        *PRINT IT OUT
               MCW  @1@,ONTEST          *SAY WE FOUND ONE
     P6GX      NOP                      *JUST FOR CLARITY
               CS   332                 *CLEAR PRINT STORAGE
               CS                       *CLEAR PRINT STORAGE
               SW   201                 *SET A WM AT THE START
               W                        *PRINT A BLANK LINE
               BCE  P6,ONTEST,1         *START OVER IF THERE WAS ONE
               B    P7                  *ON TO THE NEXT STEP
     *
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL:
     *            1.  USE INDEX REGISTERS x1 AND x2 TO MOVE DATA TO THE PRINT BUFFER
     *            2.  X1 WILL MOVE THE DATA TOWARD THE RIGHT
     *            3.  X2 WILL MOVE THE DATA TO THE LEFT BY ADDING
     *                16000-THE AMOUNT OF THE MOVE TO X2
     *            4.  THIS CODE USES THE INDEX REGISTERS BUT ALSO THE
     *                MODIFY ADDRESS INSTRUCTION
     *            5.  THE MODIFY ADDRESS WORKS VERY WELL AS LONG AS YOU USE
     *                DSA VALUES AS THE ARGUMENTS
     *********************************************************************
     *
     STEPR     DSA  3                   *ADD 3 TO INDEX
     STEPL     DSA  15997               *ROLL OVER -3
     LPCNT     DCW  88                  *COUNT LOOPS
     CHM       DCW  @COMPUTER HISTORY MUSEUM@  *FILLER FOR PRINT TEST
     *
     P7        H                        *STARTING PLACE
               ZA   @04@,LPCNT          *SET THE LOOP COUNTER TO FOUR
     *                                  *SO LPTCNT-1 = 4 AFTER 36 LOOPS
               MCW  @022@,X1            *SET THE LEFT OFFSET
               MCW  @131@,X2            *SET THE RIGHT OFFSET
     P7B       CS   332                 *CLEAR PRINT BUFFER
               CS                       *THE REST
               SW   201                 *SET A WM
               MCW  CHM,PRINT&X1        *PUT THE LEFT IN
               MCW  CHM,PRINT&77        *MIDDLE
               MCW  CHM,PRINT&X2        *PUT IN THE RIGHT
               W                        *PRINT IT
               A    @01@,LPCNT          *COUNT THE LINES
               B    P7X,LPCNT-1,4       *LOOK FOR 4X
     *
               MA   STEPR,X1            *INCREMENT X1 BY 3
               MA   STEPL,X2            *ADD 16000 -3 TO X2
               B    P7B                 *DO THAT AGAIN
     P7X       CC   1                   *GO TO HEAD OF FORM
               B    P8                  *GO BACK TO NEXT
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL:
     *            1.  MULTIPLY M1 TIMES M2
     *            2.  M2 CAN BE USED AS IS
     *            3.  M2 IS MOVED TO THE UPPER PART OF BH AND BL
     *            4.  THE SIZE OF BH AND BL MUST BE EQUAL TO m1 PLUS M2 PLUS 1
     *            5.  THE ANSWER WILL BE IN BL AFTER THE MULTIPLY
     *            6.  NOTE THE USE OF DCW FOLLOWED BY CD SO THAT BH IS THE
     *                ONLY FIELD OF THE TWO WITH A WM
     *********************************************************************
     *
     M1        DCW  @12@                 *MUPLIPLIER
     M2        DCW  @345@                *MULTIPLICAN
     *
     BH        DCW  @000@                
     BL        DC   @0000@               *WHERE THE ANSWER APPEARS
     *
     *                         1111111111222222222333333333344
     * PRINT PLUS    01234567890123456789012345678901234567890
     MULTXT    DCW  @ THE VALUE OF XX TIMES YYY IS ZZZZZZZ@
     *
     *
     *
     P8        H
               CS   PRINT&132             *CLEAR STORAGE
               CS                         *CLEAR STORAGE
               SW   PRINT                 *SET A HIGH ORDER WORDMARK
     *
               MCW  MULTXT,PRINT&36       *MOVE ALL OF THE TEXT TO THE PRINT BUFFER
               ZA   @0@,BL                *CLEAR BL AND BH TO ZERO
               ZA   M2,BH                 *LOAD MULTIPLIER M2 TO HIGH B
               M    M1,BL                 *MULTIPLY
               MCS  M1,PRINT&15           *MOVE M1 TO PRINT
               MCS  M2,PRINT&25           *MOVE M2 TO PRINT
               MCS  BL,PRINT&36           *MOVE ANSWER TO PRINT
               W                          *PRINT
               CS   PRINT&132             *CLEAR PRINT BUFFER
               CS                         *CLEAR PRINT BUFFER
               SW   PRINT                 *SET WORD MARK
               W                          *PRINT BLANKS
               H    P9                    *GO TO NEXT TRICK
               NOP                        *NEED A WM HERE
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL:
     *            1.  CLEAR THE PRINT BUFFER BY SUBROUTING CALL
     *            2.  MOVE TEST TEXT TO PRINT BUFFER VIA X1
     *            3.  PRINT CND CLEAR THE PRINT BUFFER BY SUBROUTINE CALL
     *            4.  CHECK TO SEE IF WE DID THIS 10 TIMES
     *            5.  IF NOT, DO IT AGAIN
     *********************************************************************
     *           
     P9TXT     DCW  @ TEST @               *TEST TEXT TO BE PRINTED
     P9LOP     DCW  @00@                   *LOOP COUNTER
     MASIX     DSA  6                      *X1 MODIFIER
     *
     P9        B    CLRBUF                 *CALL THE CLEAR BUFFER SUBROUTINE
               MCW  @000@,X1               *INITIALIZE X1
     *
     P91       MCW  P9TXT,PRINT&X1         *MOVE IN TEXT
               B    PRTCLR                 *CALL PRINT AND CLEAR SUBROUTINE
               A    @1@,P9LOP              *COUNT THE LOOPS
               BCE  P9EX,P9LOP-1,1         *HAVE WE PRINTED 10?
               MA   MASIX,X1               *ADD 6 TO X1
               B    P91                    *LETS DO IT AGAIN
     P9EX      B    P10                    *WE ARE DONE
     *
     PRTCLR    SBR  GOBACK&3               *STORE RETURN ADDRESS
               W                           *PRINT THE LINE
               B    CLRB2                  *GET TO THE CLEAR
     CLRBUF    SBR  GOBACK&3               *IF ENTERED HERE, STORE RETURN
     CLRB2     CS   332                    *CLEAR PRINT BUFFER
               CS                          *AND THE REST OF IT
               SW   201                    *SET THE WORD MARK
     GOBACK    B    000                    *HERE IS WHERE WE GO BACK
               NOP    
     *                                  
     *
     *********************************************************************
     *         THE FOLLOWING CODE WILL:
     *            1.  DIVIDE THE NUMBER OF MILES TRAVLED
     *                BY THE NUMBER OF GALLONS USED
     *                TO GIVE THE MILES PER GALLON
     *            3.  PRINT THE REVELENT INFORMATION
     *          THE DIFFICULT PART TO GRASP IS THE BL-6 IN THE DIVIDE INSTRUCTION.
     *          THE SIZE OF BH PLUS BL IS THE SIZE OF MILES PLUS THE SIZE OF
     *          MILES PLUS 1.
     *          THE BL-6 IS 6 BECAUSE THE SIZE OF BH IS 6. NOT SURE WHY BUT IT WORKS.  4.  CHECK TO SEE IF WE DID THIS 10 TIMES
     *          
     *********************************************************************
     *                    
     *                                  *(DIVIDEN)
     MILES     DCW  001312              *HOW MANY MILES DID YOU DRIVE?
     *                                  *(DIVISOR)
     GALLON    DCW  13                  *HOW MANY GALLONS DID YOU USE?
     *
     BHD       DCW  000000              *WHERE THE QUOTIENT WILL APPEAR
     BLD       DC   000                 *WHERE THE REMAINDER APPEARS
     *
     P10       H                        *START THIS SEGMENT
               ZA   MILES,BLD           *CLEAR TO ZEROS
               D    GALLON,BLD-6        *LOW ORDER OF DIVISOR ADDRESS
               CS   332                 *CLEAR PRINT BUFFER
               CS                       *CLEAR PRINT BUFFER
               MCW  @MILES DRIVEN @,213 *MOVE IN TITLE
               MCS  MILES,223           *MOVE IN DATA
               W                        *PRINT
               CS   332                 *CLEAR PRINT BUFFER
               CS                       *CLEAR PRINT BUFFER
               MCW  @GALLONS USED@,212  *MOVE IN TITLE
               MCS  GALLON,223          *MOVE IN DATA
               W                        *PRINT
               CS   332                 *CLEAR PRINT BUFFER
               CS                       *CLEAR PRINT BUFFER
               MCW  @MILES PER GALLON @,217 *MOVE IN TITLE
               MCS  BHD,223             *MOVE IN DATA
               MCW  @ AND @,229         *MOVE IN TITLE
               SW   BLD-2               *SET WM SO REMAINDER CAN BE EXTRACTED
               MCS  BLD,231             *MOVE IN DATA
               CW   BLD-2               *CLEAR THE WORD MARK
               MCW  @/@,232             *MOVE IN TEXT
               MCS  GALLON,234          *MOVE IN DATA
               W                        *PRINT 
               CS   332                 *CLEAR PRINT BUFFER
               CS                       *CLEAR PRINT BUFFER
               B    P11
     P11       H    P11
               NOP
               END  START



return to
main page