FROM: Ralph Reinke (101520.3451@compuserve.com) TO: Paul Pierce (prp@teleport.com) DATE: 14th of August 1998 RE: Contribution to the 1401 Software Project ----------------------------------------------- AIM: --- Three 1401 machine programs are handed over to be saved for any present or future 1401 enthusiasts. One of the programs is a small storage print utility, the other two being card based assembler that were the programming tools of the time. Covered in this document is everything needed to study or really operate these programs. Also the manner in which the programs are stored in this package is explained. It is not intended to explain and describe the 1401 machine. A very few details about the machine are given as needed for understanding the operating procedures. 1401 CONFIGURATION: ------------------ The minimal configuration has been the CPU 1401 of any size, the combined card reader and punch unit 1402 and the printer 1403. The programs here delivered are meant for this basic configuration and do not need anything else. Core storage sizes are mentioned where needed. Of course the assemblers are able to build programs for any configuration including magnetic tapes and disks. STACKERS / SWITCHES / HALTS: --------------------------- The following few details about the 1401 are needed to be known as they always showed up in the operating procedures for programs of any complexity. * STACKERS The 1402 unit had the card punch on the left, the reader on the right and in between there were five adjacent compartments or 'stackers' to place the cards that had been read or punched. These stackers were named in the following manner: (Punch) N/P 4 8/2 1 N/R (Reader) If not ordered otherwise by program control all cards punched would go into N/P (Normal Punch) and all cards read into N/R (Normal Read). Cards punched could optionally be directed into 4 or 8/2 and cards read into 1 or 8/2. In this manner the card input and output could be split by sending them into different stackers. * SWITCHES On the main panel of the CPU a row of switches named A through G could be toggled up and down (ON and OFF) and the position of these switches could be sensed by program instructions. Hereby any number of different program behaviour could be offered and chosen. - Switch A had a special meaning: when set to ON it was sensed as ON only when the LAST CARD of the input batch had passed the reader. * HALTS A special instruction HALT when encountered during program flow would stop the CPU and the red STOP key on the panel lighted. The instruction was either coded with no operand, a number of choice or a valid branching address. Accordingly the following differing behaviour resulted: NO OPERAND: Instruction Register I shows address of the Next Sequential Instruction (NSI). Pressing START key starts the CPU on NSI. NSI identifies a HALT in case there is more than one HALT in a program. This is documented in the operating papers with its meaning. NUMBER: Register A for the A-Operand shows the number and thereby identifies a HALT. Pressing START starts the CPU on NSI. ADDRESS: On pressing START the CPU branches to the coded address. The HALT instruction may point to itself thereby locking the program totally. The display of NSI in the I-Register identifies the HALT. By combining stackers, switches and halts in a program it is possible to build any optional program behaviour. LOADING PROGRAMS: ---------------- The 1401 never had any Operating System however simple. While programs could reside on magnetic tape and be loaded from there the basic procedure was to have the programs as punched cards, the input data for the program also consisting of cards. The program cards followed by the input cards were placed into the reader and a lid on top of the last card to secure the proper feeding without damaging the last cards. On pressing the START key on the panel the CPU automatically started the card reader. The program cards were read into core storage and the last program card initiated program execution. The cards of the machine program had quite an involved structure which to explain would need to go into very much detail of the CPU's principles of operation. Some basic information about this will be given further down in connection with documenting one of the assemblers. FIXED STORAGE AREAS: ------------------- The 1401 had a few areas of low storage that were assigned to the following special purposes and addresses: * Card Input Area = 1 - 80 * Card Punch Area = 101 - 180 * Print Area = 201 - 332 Three Index Registers were incorporated as parts of main storage at the following addresses: X1 = 087 - 089, X2 = 092 - 094, X3 = 097 - 099 DEBUGGING OF PROGRAMS: --------------------- The debugging procedure for programs mainly consisted of printing the contents of the main storage after program crash and taking this 'storage dump' back to your desk for analysis. This printout could be effected in two ways: by hardware or by software. The panel of the CPU had switches and keys for effecting a trap for an instruction address, restarting the stopped CPU on any desired instruction address, single step mode of operation and last not least the choice of printing any desired 100 bytes of storage, named a 'Line' of storage. Printout was in a crude manner without any layout and any 'Line' had to be printed by separate handling of switches. The strength of this hardware approach was that no storage or register contents was altered by this method. By the way: storage consisted of those matrices of magnetized ferrite rings the magnetism of which held the stored data for any length of time after a program run even when the CPU was powered down and up again! The software approach of course was to have a utility program for printing storage. Such a program was started by START after crash of the faulty program and delivered a nicely made up 'storage dump' of the whole storage. The drawback was that the utility, though being small, by being loaded destroyed some contents beginning at address zero. Whenever these locations were of importance for the debugging case in question one simply 'dumped' the first lines by hardware and then loaded the utility. PROGRAM 1 of 3: STORAGE PRINT UTILITY: ===================================== The utility program consists of only 16 cards and is found in the file 'DUMP' in this package. The operating procedure is nothing more than starting the program by START. This program managed to only destroy the contents of the Card Input Area. The effected printout shows the following details: * Contents of Print Area * Contents of Index Registers * Contents of Punch Area * The following parts of storage are shown separated per Line with Line numbering, beginning with two printed lines as a scale for better reading, followed by the line with storage contents and a closing line of scattered blanks and '1' by which the current location of 'Word Marks' were shown. These Word Marks are an allimportant special feature of the 1401 that cannot here be explained in a few words. - In conclusion the actual settings of Switches A,B...G were given. Lines of storage containing spaces only are not displayed. As this program was delivered in Germany the following few German words appear in the printout and their English meaning is: LINIE = LINE, UMSCHALTER = SWITCH, EIN = ON, AUS = OFF. ASSEMBLERS FOR THE 1401: ----------------------- There were two different systems of assembly language. AUTOCODER was the more modern and progressive system offering a flexible input format and even macros and other prebuilt routines. The assembler and its library resided on magnetic tape. The assemblers in this package belonged to the 'Symbolic Programming System' or SPS, the more basic method restricted to punched cards as storage medium. No macro feature was available and a rigid input format had to be observed. The strength of the system was the fact that almost any poor hardware configuration was sufficient. The SPS showed up in two steps of evolution. The first came as SPS1 and SPS2, the second being called SSPS (probably meaning SUPER SPS). While SPS1 even worked on a CPU with only 1400 bytes of storage it was capable of building programs of no greater size than 4000 bytes. SPS2 needed a storage size of 4000 and could manage programs of the maximum size of 16000 bytes. SPS1 and SPS2 consisted of 5 programs each and the operating procedure was quite involved. SSPS in contrast needed at least 4000 bytes and was delivered tailor made for each existing storage size. It was composed of 2 programs only and offered a much simpler and quicker procedure. INPUT FORMAT FOR THESE ASSEMBLERS: --------------------------------- The layout for the input cards for SPS and SSPS - the symbolic program cards - is identical. The meaning of the 80 collumns is: * 01-05 = Card numbering without duplicates and in ascending order, best with gaps for insertions. * 06-07 = Count = number of characters, only used for definition of constants and areas. * 08-13 = Label if needed. * 14-16 = Operation Code. * 17-27 = A-Operand, subdivided as follows: * 17-22 = Address in form of a Label or expressly given as a number of 4 digits. * 23 = Optional Sign '+' or '-' for an Address Calculation, Blank can mean '+'. * 24-26 = Address Calculation, optional as a 3-digit number meaning an increment or decrement for Address. * 27 = Optionally chosen Index Register '1'/'2'/'3'. * 28-38 = B-Operand, subdivided like A-Operand. * 39 = Operation Supplement where needed. * 40-55 = Comments. * 56-75 = Unused. * 76-80 = Program Identification of free choice. PROGRAM 2 of 3: ASSEMBLER SPS2: ============================== This assembler comes in 5 parts which mean a logical unit but in a technical sense they are 5 separate machine programs. To a minor degree they can be used separately. These programs are found in the the following files: SPS2-1, SPS2-2, SPS2-3, SPS2-4 and SPS2-5. These names will also be used as an abbreviation in the folllowing explanations. The shortage of the very expensive core storage enforces a splitting of the assembly process and the following five steps result: PRELIST - ASSEMBLY PHASE 1 - ASSEMBLY PHASE 2 - POSTLIST - CONDENSE PRELIST: First it must be made sure the symbolic program cards do ------- not contain any formal errors for otherwise the assembly proper would never be possible. Therefore program SPS2-1 has to be started first, followed by these cards: 1) A special Control Card telling the assembler the storage size of the system used in this assembly and the storage size of the system the resulting machine program is meant for, which of course can and mostly will be identical. The layout for this card is: 14-16 = 'CTL' 17 = storage size of assembly machine 18 = storage size of target machine The sizes are given as the following numbers: 3 = 4.000 bytes 4 = 8.000 bytes 5 = 12.000 bytes 6 = 16.000 bytes 2) Another Control Card which is optional and can alter the Origin Address of the program in storage. If this card is missing Origin is automatically set to 333 (immediately following the Print Area). The Layout of the card is: 14-16 = 'ORG' 17-20 = Numerical Address in 4 digits. 3) The Symbolic Program cards following the SPS Layout. Switch A must be set to ON when STARTing the program. The run results in printing the PRELIST - meaning the list before the assembly process. The input cards are printed with header lines and the checking may reveal the following errors: ERR 1 = PAGE/LINE SEQUENCE Card numbering out of sequence or missing. ERR 2 = COUNT 1. Value in field is smaller 1 or greater 32. 2. Value in field is not numerical. ERR 3 = LABEL 1. First character is blank, numerical, % or # or @ 2. DS-Card without Label has no '*' in A-operand. ERR 4 = MNEMONIC OP CODE 1. Invalid Symbolic Operation Code. 2. Symbolic Operation missing. ERR 5 = A-OPERAND 1. Instruction has a B-Operand but no A-Operand. 2. A-Operand of a DCW-, DS-, DC- or DSA-Definition is empty or contains symbolic entry. 3. A-Operand of ORG-Card with no numerical address. 4. A-Operand of EX-Card or END-Card contains '*'. 5. Some formal error in A-Operand: 1. INDEX, col. 27 neither empty nor '1'/'2'/'3'. 2. ADDRESS CALCULATION, col. 24-26, value not numerical or not right justified. 3. SIGN, col. 23 not empty or '+'/'-'. 4. Empty position to the left of value. 5. Operand with %-character in most significant position has more than 3 positions and so does not mean an Input/Output Unit. 6. Left position of Operand is numerical while the others are not. 7. Numerical Address with less than 4 digits. 8. Numerical Address exceeds storage capacity given in col. 18 of CTL-Card. 9. A *-Address is not followed by spaces. ERR 6 = B-OPERAND Invalid B-Operand: 1. Col. 23 of a DCW- or DC-Card neither empty nor does it contain '+'/'-'. ERR 7 = COLS 56-74 NOT BLANK Card not empty in cols. 56-74 which may lead to faulty assembly. In conclusion the following messages are printed: * NO CONTROL CARD if CTL-Card is missing or not first card. * NO END CARD if END-Card is missing or not last card. * Total number of Labels. * Highest storage address used. * Number of input cards. The cards of machine program SPS2-1 are directed to stacker N/R, the symbolic program cards to stacker 1. Programmed HALTS for SPS2-1: Instruction Address Meaning 2376 Last Card, END OF JOB, pressing START lets the loaded program take a new run. ASSEMBLY: The assembly is effected by machine programs SPS2-2 and -------- SPS2-3 which belong together of necessity: SPS2-2 is an EX-phase. The symbolic cards input steered to stacker 1 by SPS2-1 must be inserted between SPS2-2 and SPS2-3 and STARTed, Switch A remain set to ON. The machine program cards of SPS2-2 go into stacker N/R, the symbolic program cards into stacker 1. While SPS2-3 still remains in the reader SPS2-2 is working on phase 1 of the assembly process which gives the following results: * Symbolic Operation Codes are translated into real ones. * Addresses in storage are calculated and areas in storage reserved for Instructions, Constants and Areas. * A symbol table is built in main storage holding the Labels and their real storage addresses calculated for this program. * Intermediate Cards are punched and directed to stacker 8. These cards hold information needed in phase 2 of the assembly process. Each symbolic card of the input is duplicated as an intermediate card and information added, for instance the instruction lenght is placed as COUNT into cols. 6-7. If necessary corrections from diagnostics have been left off or not been successful this phase 1 of assembly comes to a programmed stop, the incriminated card being the last one in stacker 1. Though there is a restart procedure for going on after such a card has been corrected on the key punch this is quite error prone and should be avoided in favour of getting a complete OK from the Prelist SPS2-1. Programmed HALTS for SPS2-2: Instruction Address Meaning 0409 Invalid Operation Code in card last read. Pressing START lets continue without incriminated card. If card is corrected and placed into reader as first one pressing START will include it. 1018 SPS2-2 or phase 1 is ended and card just read was not recognized as the first card of SPS2-3 or phase 2. SPS2-3 can be placed into reader and STARTed. As soon as the END-Card from the input has been read this phase 1 closes and SPS2-3 is loaded automatically from the reader. If SPS2-3 has not yet been placed into the reader the CPU is stopped showing the card read command '1' in the OP-Register on the panel. The Intermediate Cards of phase 1 are to be placed behind SPS2-3 as its input and the START key pressed. The cards of machine program SPS2-3 go into stacker N/R, the Inter= mediate Cards into stacker 8/2 and these are useless after this run and should be discarded. The result and output of the run are the newly punched cards in stacker N/P which now hold the following information: * Again all the information from the Intermediate Cards is copied. * The Symbolic Instruction is fully translated into the machine language and all symbolic addresses replaced by real addresses using the symbol table in storage, taking into consideration any Address Calculation and wanted Index Registers from the symbolic code. Instead of an Instruction the card could hold a Constant of course. * A LOAD instruction is tailored for the contents of the card and added in cols. 56-74. This makes the card a 'selfloading card'. On conclusion of the run the batch of cards in stacker N/P is the ready to use machine program. Some further remarks about the construction of this machine program will be in place: * Already at begin of phase 2 three additional cards have been generated. They are very important and must be seen as an integral part of the program though in a strictly technical sense they are two additional, separate programs themselves: * The first and second of the three cards are a stand alone program for completely clearing the main storage to blanks and removing all Word Marks. As the core storage holds all data from operation indefinitely this step is necessary to bring well defined conditions for a new program. The size of storage area to be cleared is taken from col. 18 of the CTL-Card. * The third card is the Bootstrap Card and needed for preparing and initiating the Load procedure for a program. * All of the following cards each hold one Instruction or one Definition of a Constant in machine language. * As an exception the last card is the END-Card marking the end of the machine program and it also holds the Start Address of the program. Now the process of Loading a program can be understood as as a sequence of the following steps: 1) The CLEAR STORAGE program sweeps the floor for the proper program execution. 2) The BOOTSTRAP program starts the following chain of LOAD Instructions: 3) A card of the machine program proper is read and if it is not the END-Card the LOAD Instruction in col. 56 is executed, the parameters of which which are: * Address and length of the piece of machine code in this card and * the designated core storage address for it. 4) If the END-Card was encountered program control is transferred to the Start Address of the program and execution begins. By this chain of LOADs the code fragments fly into place like the pieces of a puzzle. CAUTION: In order to make matters not too boring there can be a certain complication. If the storage size of the machine used for assembly is very restricted and/or the symbolic program is very big in the sense of holding a great number of Labels it can happen that the Symbol Table that has to fit in storage besides the assembler program is overflowed. This now does not mean that a program of this size cannot be assembled on such a small machine. It only means this cannot be done in one run. Surprisingly the assembly process of phase 1 plus phase 2 as described above can be repeated loopwise and the resolution of the symbolic addresses is done incrementally! This means that in all runs but the last the punched cards do not mean the completed machine program but Intermediate Cards which are the input for the next run and then discarded. - To judge whether an assembly run of phase 1 plus phase 2 is the only or concluding one there should be a message on the printer and also the three additional cards mentioned above are only punched in a concluding run. The following numbers show the limits for storage sizes versus number of Labels and that it is not a very like case to occur: Storage Size Maximum Number of Labels 4.000 260 8.000 660 12.000 1060 16.000 1460 Programmed HALTS for SPS2-3: Instruction Address Meaning 1197 END OF JOB. POSTLIST: The name of the list again refers to the assembly itself -------- and means a listing taken after assembly. The machine program produced by SPS2-2 plus SPS2-3 is used for input when running SPS2-4 to print the Postlist. There is no special operating procedure to be observed: switch A must as usual be set to ON and after placing SPS2-4 into the reader followed by the machine program START is pressed. The END-Card in input brings the run to a normal close. This listing in addition to the symbolic code also gives the resulting machine code for each statement. It is the document to be kept and stored away for any program. Rather unexpectedly this Postlist can reveal persisting errors in the machine program or - more probably - that a wrong deck of cards has been used for input. These are the possible error messages: * The special character 'lozenge' has been printed in a line close to the statement numbering and can mean one of the following cases: * A symbol in an A-Operand or B-Operand has not been defined as a Label. * The Operation Code for an Instruction is missing. * An address pointing into the Card Input Area has been assigned to the data to be loaded from a card. * The number of characters for a Constant exceeds 32. * The collumns for COUNT in a card hold spaces/zero. * On reading a card that does not contain machine code it gets the remark 'UNASSEMBLED CARD'. This happens with the wrong card deck as input or in case assembly has not yet been completed (missing repetition of run). * At last something can be wrong with the three special cards that are normally added in front of the program and the following messages can occur: FIRST CLEAR STORAGE CARD MISSING SECOND CLEAR STORAGE CARD MISSING NO BOOTSTRAP CARD Programmed HALTS for SPS2-4: Instruction Address Meaning 1322 Last Card, END OF JOB. Pressing START will let the loaded program take a new run. CONDENSE: As each card of the machine program as described up to now -------- contains all the symbolic code as well as the machine code of only one Instruction or Constant this offered - for the very unafraid - the possibility to further correct and patch a program on the key punch before running another assembly. Such practices were suggested by the very narrow time limits of having the machine free for testing. Normally a machine program of this kind when ripe for production would be too bulky to be handy. So the program SPS2-5 was the concluding step as it condensed the machine program from SPS2-3 by throwing out all symbolic code and compressing as many machine code pieces into one card as would go in. A new LOAD Instruction per card is formed and so the quality of the cards as 'selfloading' upheld. The process of program loading as described above remains unchanged. No special operating procedure is necessary: switch A must be set to ON, program SPS2-5, followed by the uncondensed machine program, placed into the reader and START pressed. The input cards are directed to stacker 1, the output cards to stacker N/P. Programmed HALTS: Instruction Address Meaning 1222 END-Card read, END OF JOB, Pressing START can start new run of loaded program with next card deck from reader. 1323 Card last read is not an assembled card. Pressing START will continue with next card. 1327 Value in field COUNT of card last read hold a value greater than 32 or smaller 1. Pressing START will continue with next card. PROGRAM 3 of 3: ASSEMBLER SSPS: ============================== SSPS is a much improved version of SPS consisting of only two parts here named SSPS-1 and SSPS-2. The operating procedure is much less involved and the Intermediate Cards of SPS are done away with. The steps of the assembly process as described for SPS are nevertheless basically the same and only partially covered by integration. SSPS assemblers were distributed as tailored for different storage sizes and so the CTL-Control Card does not exist. The specimen here given is meant for a machine with 8.000 bytes of storage. The internal Symbol Table for Labels now takes into account the varying length of Labels and so improves its working capacity. On the other hand there is no possibility of incrementally working off Labels in repeated runs - such cases are marked as ERROR 8 in the Prelist. The two parts or phases of SSPS belong to each other the first being an EX-Phase and do not make any sense separately. The machine program punched by phase 2 is always in condensed format. The operating procedure is to place the symbolic program between the two phases SSPS-1 and SSPS-2 sandwichlike, put this package into the card reader, set switch A to ON and to press START. The Prelist also informs about how many Labels have been stored and how many more would probably be possible. Programmed HALTS: Instruction Address Meaning 0574 Phase 1 has been loaded and is ready to work. Pressing START starts and a Prelist will be printed. Pressing START-RESET, then START will suppress the Prelist, only statements in error will be printed. 0825 Phase 2 has been loaded and is ready to work. Pressing START starts the assembly and prints the Postlist. Pressing START-RESET, then START starts the assembly without a Postlist. All statements in error will be printed anyway. The symbolic cards that have been read by phase 1 must be taken from stacker 1 and be placed into the reader again. The machine program punched is steered into stacker 4. 1356 END OF JOB. CAUTION: Before starting phase 2 there should always be checked for serious errors in phase 1 which do not justify a full assembly and may even crash phase 2. HOW THE DESCRIBED PROGRAMS ARE STORED IN THEIR FILES: ---------------------------------------------------- Three levels of usage can be forseen for these programs. The modest one will be to analyze them more or less for mere understanding. The more ambituous approach would be to have a simulator or emulator program for the 1401 and then the program files would have to be somehow prepared or transformed as input. In the very rare case that a real 1401 should be available the original punched cards would be needed and reproduced from these files. It has been tried to cover all three levels by the contents of the files and their structure must of course be well understood. The original punched cards from the 1401 environment were transferred to 9-track tape on a mainframe /360 and carried along to /370 and /390 for a long time, at last transferred to the PC. There must be clarity about the different code schemes. The 1401 had its data in BCD or Binary Coded Decimal. For any possible value there was a pattern of holes in the standard IBM punched card of 80 collumns and 12 rows. The following IBM mainframes use EBCDIC or Extended Binary Coded Decimal Interchange Code - not ASCII like the rest of the world! The denomination as Extended already says that BCD is a subset of EBCDIC. Accordingly the 1401 punched cards could be read and stored on tape without any problem and without being altered thereby. Nevertheless the 1401 used some special graphic characters that only showed up on the print chains of the 1403 and similar printers. So we have the problem that some values of importance in an assembly listing can no longer be shown in print by any typical printer - mainframe or PC. And then the PC files have to be in ASCII of course. To best solve or escape the problems the following has been done. In any of the program files of this package each original punched card is given as a sequence of 16 records of size 80 each. As an example all of the characters that can directly be input from a PC keybord have been turned into such a record group here: 1...5...10...15...20...25...30...35...40...45...50...55...60...65...70...75...80 ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 #&*,./<-% ()\@ CCCCCCCCCDDDDDDDDDEEEEEEEE4FFFFFFFFFF47556464664CDE74444444444444444444444444444 12345678912345678923456789001234567890B0CBB1C0C0000C0000000000000000000000000000 *********..............................*..*.*...*............................... .........*********......................*....*...*.............................. ..................********.*.............*.*..*.***............................. *........*..................*..............*.................................... .*........*.......*..........*....................*............................. ..*........*.......*..........*.......*..**..................................... ...*........*.......*..........*........*...*.*....*............................ ....*........*.......*..........*............................................... .....*........*.......*..........*.............................................. ......*........*.......*..........*............................................. .......*........*.......*..........*..*.***.*.*...**............................ ........*........*.......*..........*........................................... The contents and meaning of the 16 records is the following: * For better reading and separation each group begins with a scale showing the positions of the 80 collumns. * Next follows the original card contents turned to ASCII as best as possible. But be careful - this is only an approximation for the human reader! As said not all BCD values have their graphic equivalent in ASCII and these cases are simply seen - or rather not seen - as blank in this line. Also never to be forgotten: this is ASCII and it would be unreliable to translate by program from this line for any use by machine. * The following two records or lines give the original contents of the cards in HEXA. This is the reliable source where the preceeding record fails. The first of the two records gives the 80 ZONE parts of the 80 bytes X'* ' and the second of the two the 80 DIGIT parts of the 80 bytes X' *'. The proposed use of these two records is: * Whenever the human reader sees a BLANK in the second record he better makes sure whether a real BLANK is meant, namely X'40' in EBCDIC as HEXA in the third and fourth record. Any other HEXA value designates one of the queer 1401 BCD values that cannot be shown as ASCII graphically. * Whenever the programs shall be really used on a machine in whatever mode for execution they should be transformed from these two records of every group as the reliable data source. * The remaining 12 records of a group simulate the original hole pattern of the punched card, every '*' obviously meaning a hole. The first of these 12 records is 'row 12' of the card, the next 'row 11' and then 0 through 9. If the original cards are needed for a real 1401 they can be reproduced on a key punch by hand along this card image. As this would be an error prone and somewhat nerve-racking procedure perhaps the following idea can be helpful. There are ISA-Cards for PCs with relays for controlling external events by a PC program. For a person with some electronic experience it should not be difficult to somehow connect such relays to the keyboard of a key punch and so control it by PC. The ON/OFF nature of the card image given might be easy to use as input for this control task. --- FINIS ---