IBM 1401 Simulator
Online User Manual




 

TABLE OF CONTENTS
 
1.___What is an IBM 1401?
1.1___Historical Overview
1.2___Basic System Configuration
__Figure 1.2.1, Register Data-Flow Relationships
__Figure 1.2.2, IBM 1401 Control Panel
__Figure 1.2.3, Data Punchcard
__Figure 1.2.4, Typical IBM 1401 Installation
1.3___Simulator System-Configuration Options
1.4___User Input/Output
2.___Operations Technical Description
2.1___Memory-Storage Representations
__Figure 2.1.1, IBM 1401 Internal 8-Bit Storage Representation
__Table 2.1.1, Binary Character Representations
2.2___Addressing Memory-Storage Locations
__Table 2.2.1, Memory-Address Codes
2.3___Fetch/Execute Cycle Description
__Figure 2.3.1, IBM 1401 Fetch/Execute Cycle
3.___Simulator Graphical User Interface
3.1___Entering the Simulator
__Figure 3.1.1, IBM 1401 Simulator GUI
3.2___Mimic Bus
__Table 3.2.1, Mimic Bus Warning Lights
__Table 3.2.2, Mimic Bus System Status Lights
3.3___Control Panel
___Table 3.3.1, Simulator Controls
4.___Tutorial
4.1___Introduction to IBM 1401 Programming
4.2___Common Terms Used for the IBM 1401
__Figure 4.2.1, IBM 1401 Internal 8-Bit Storage Representation
4.3___Instructions
___Figure 4.3.1, General Form of an Instruction
4.4___Storage of Instructions
4.5___Programming Examples
__Example 1:__“Hello World”
__Example 2:__Arithmetic-Operations Program
4.6___Program Loading and Output Retrieval
4.7___Summary of Programing Principles
5.___Appendices
5.1___OpCode Tables
__Table 5.1.1, Arithmetic Instructions
__Table 5.1.2, Logic Instructions
__Table 5.1.3, Data-Moving Instructions
__Table 5.1.4, Miscellaneous Instructions
5.2___References
5.3___Glossary
 


1.___What is an IBM 1401?
 

1.1___Historical Overview

This User Manual describes how to use and program the IBM 1401 Computer Simulator, which can be accessed on the Internet via the following URL address: http://clem.mscd.edu/~Howerton. The IBM 1401 Computer was an early, general-purpose, business computer built and marketed in the 1960s. It was specifically designed to support commercial data processing. Its first installation was completed in 1960, and nearly 9000 units were sold and installed overall. Occasionally, the IBM 1401 was used as a satellite computer in a large-scale computer system, and acted in such an application primarily as an input-output editor and data organizer. When it was introduced, the IBM 1401 represented a significant step in computing technology available to business. It was both reliable and relatively fast by the standards of the early 1960s.
 

1.2___Basic System Configuration

The IBM 1401 used ferrite magnetic-core memory from 1400 to 16,000 alpha-numeric characters in natural binary-coded decimal (BCD). The central processing unit could have a maximum of 4000 alpha-numeric characters of storage, with any further additions to memory provided by a separate, IBM 1406 Storage Unit. Auxiliary storage in the form of magnetic tape drives and magnetic disk drives were also typically included in a system installation. The IBM 1401 used a synchronous timing system and was fully transistorized. Its internal arithmetic configuration was a serial, add-to-storage logic and did not include direct multiply/divide capability unless a special hardware option was installed to perform those functions. The IBM 1401 had 41 to 64 operation codes (opcodes) in its instruction set, depending on the various configuration options in an installation. The speed of the IBM 1401 was dependant on the type of instruction and the field length of the operands. The computer came with seven installed registers, three of which were 8-bit registers for storing single characters of data or opcodes, and the remaining four of which were 32-bit address registers. Figure 1.2.1 shows the data-flow paths between the registers and core storage.



Figure 1.2.1, IBM 1401 Register Relationships
 

Additional index registers were available as a special feature. All registers could be monitored on the IBM 1401's front control panel, depicted in Figure 1.2.2, which also provided controls for starting, stopping, and data-flow/error monitoring.



Figure 1.2.2, IBM 1401 Control Panel
 

An IBM 1401 installation could include several different input/output peripheral devices, including a card read/punch (read at 800 cps and punched at 250 cps), printer (printed 100 or 131 lines at 600 lpm), console typewriter, magnetic tape drives, paper tape, optical reader, and even audio response. Figure 1.2.3 depicts a data punchcard and guidelines for punching one out. Figure 1.2.4 depicts, from left to right respectively, a typical IBM 1401 installation with a card read/punch, the IBM 1401 computer, a printer, and a magnetic tape drive.



Figure 1.2.3, Data Punchcard
 


Figure 1.2.4, Typical IBM 1401 Installation
 

Additional information on the design and configuration beyond the discussion in this section is available from Reference 5.2.2.
 

1.3___Simulator System-Configuration Options

The simulator emulates the original computer in its performance for a user (visitor to the webpage), including the original instruction set and the relative computing speed (slow) as prescribed in Reference 5.2.1. The original machine was available with optional sizes of installed core-memory. This simulator is configured so that the maximum size of internal core-memory is installed for the IBM 1401, which corresponds to 4000 characters of storage. External memory options that can take the total available core-memory up to a maximum of 16,000 characters are not used. In addition, the original machine was available with or without an automatic multiply-divide device. This simulator includes the automatic multiply-divide device.

The original machine was available with multiple input/output (I/O) device options, including a card read/punch and a line-printer. This simulator for the equivalent of a card read/punch as follows: (1) A text window for user input (80-line records, with each line representing one input punchcard), which interfaces with the simulator just as a card reader would interface with an actual IBM 1401; and (2) A text window displays simulator output (80-line records, with each line representing one output punchcard), which interfaces with the simulator just as a card punch would interface with an actual IBM 1401. A 132-character-wide output line-printer emulation is also comprised of a text window. Figure 3.1.1, IBM 1401 Simulator GUI shows the orientation of the I/O device emulations.
 

1.4___User Input/Output

A user can write a program in their own text editor, following the format of an 80-character line per punchcard, then cut and paste it into the simulator's Input text window before actually starting the simulator processing. Likewise, a user is able to enter text directly into the Input text window if desired. The Input text window, while not a formal part of the simulator, highlights any non-supported characters and lines (“punchcards”) that exceed 80 characters in length. The simulator detects errors from a program pursuant to the original IBM 1401 specifications.
 
 

2.___Operations Technical Description
 

2.1___Memory-Storage Representations

The IBM 1401 was designed and created in the late 1950s. During this time period, computers were very expensive and the amount of internal memory available was both limited in size and expense. The IBM 1401 was sold in a variety of memory configurations ranging from 1400 characters of representation to 16,000 characters of representation. The number of storage locations between instructions and/or discrete data components are known as “words” of memory. To conserve memory as much as possible, the IBM 1401 had variable-length words. Conversely, the majority of computer systems today have fixed-length words for instructions and data. The size of an IBM 1401's variable-length word is one character or larger. The maximum length of an IBM 1401's word depends upon whether the word contains an instruction or data. Instructions have a maximum length of eight characters and data, theoretically, has a maximum length of whatever the size of internal memory is.

The structure of each 8-bit character representation in the IBM 1401 is shown in Figure 2.1.1:
 

Odd-
Parity
Zone Numeric Word
Mark
CB A8 42 1M
Figure 2.1.1, IBM 1401 Internal 8-Bit Storage Representation
 

The value of the decimal digit is the sum represented by the binary bits in the 8, 4, 2, and 1 Numeric bit positions, with the exception of zero, which is represented by a 10 (8 and 2 bit combination). The Zone bits are 1 and 1 for a signed, positive digit. For a negative digit, the Zone bits are 1 and 0. An unsigned digit (0 and 0) is considered to be positive.

The 8, 4, 2, and 1 Numeric bits facilitate the possible creation of 16 different values (that is, 24 values). For example, if the 8, 4, 2, and 1 Numeric bits contain "0101", respectively, there would be a "1" in the 4-column and a "1" in the 1-column, with zeros in both the 8-column and the 2-column. Summing all four bits together yields:

8-Col.4-Col. 2-Col. 1-Col.
010 1
0*231*22 0*21 1*205

The 8, 4, 2, and 1 Numeric bits by themselves can only represent 16 different values (24); therefore, the two Zone bits (A and B) are used in combination with the Numeric bits to represent upper-case alphabetic and special characters according to an internal table. With the addition of the two Zone bits, 64 unique combinations (26) are possible. There are a possible 64 characters (no lower-case) alpha-numeric characters notrepresented by the machine.

The Parity bit (C) is used for internal error control based on odd parity check. The odd-parity bit is a validation bit to ensure that the machine is working properly. If the machine is working properly, then the odd-parity bit should be on if the 8, 4, 2, 1, A, and B have a combined even number of bits on (that is, a value of "1"). An example is shown below:
 

Given:
B = 1, A = 1, 8_4_2_1 = 0010,

BA 8_4_2_1 = 11 0010,

odd number of "1"s,
 

Then: C (odd-parity bit)___=___0

and

CBA 8_4_2_1___=___011 0010

The characters available for representation in this simulator are listed in Table 2.1.1:

 

Table 2.1.1, Binary Character Representations
Character Bit Settings
CBA8421
Character Bit Settings
CBA8421
01001010 Q1101000
10000001 R0101001
20000010 S1010010
31000011 T001011
40000100 U1010100
51000101 V0010101
61000110 W0010110
70000111 X1010111
80001000 Y1011000
91001001 Z0011001
A0110001 &1110000
B0110010 .0111011
C1110011 ~
(subst. for
"" char.)
1111100
D0110100 -0100000
E1110101 $1101011
F1110110 *0101100
G0110111 /1010001
H0111000 ,1011011
I1001001 %0011100
J1100001 #0001011
K1100010 @1001100
L0100011 !0101010
M1100100 ?1111010
N0100101 ^
(subst. for
"¹" char.
0011010
O0100110 blank100000
P1100111 ----- -----
   

Because the IBM 1401 has variable-length words, it requires one bit per character to indicate if the character is the beginning or ending of a word. The wordmark is set at "1" to indicate the end of a word. In instruction fetch/execute cycles, the wordmark associated with the opcode of the next instruction signals the end of the fetch part of the cycle and the start of the execution part of the cycle.
 

2.2___Addressing Memory-Storage Locations

Each memory location in the IBM 1401 consists of eight ferrite cores to represent one alpha-numeric character. Each character in memory was addressable, even if the core memory is expanded to the maximum of 16,000 characters of storage. By using a combination of Zone and alpha-numeric bits over the hundreds position (the left-most character) and units position (the right-most character), any location in memory can be represented by using a three-character address. The combination of the three characters allows addressing of 262,144 (643) address spaces. In this IBM 1401 simulator, only 4000 memory addresses are available; therefore, only the codes for addresses 000 through 3999 are listed in Table 2.2.1:

 

Table 2.2.1, Memory-Address Codes
Memory-Address Ranges Code Ranges
000 to 999000 to 999
1000 to 1099=99 to =99
1100 to 1199/99 to /99
1200 to 1299S00 to S99
1300 to 1399T00 to T99
1400 to 1499U00 to U99
1500 to 1599V00 to V99
1600 to 1699W00 to W99
1700 to 1799X00 to X99
1800 to 1899Y00 to Y99
1900 to 1999Z00 to Z99
2000 to 2099!00 to !99
2100 to 2199J00 to J99
2200 to 2299K00 to K99
2300 to 2399L00 to L99
2400 to 2499M00 to M99
2500 to 2599N00 to N99
2600 to 2699O00 to O99
2700 to 2799P00 to P99
2800 to 2899Q00 to Q99
2900 to 2999R00 to R99
3000 to 3099?00 to ?99
3100 to 3199A00 to A99
3200 to 3299B00 to B99
3300 to 3399C00 to C99
3400 to 3499D00 to D99
3500 to 3599E00 to E99
3600 to 3699F00 to F99
3700 to 3799G00 to G99
3800 to 3899H00 to H99
3900 to 3999I00 to I99
   

2.3___Fetch/Execute Cycle Description

The IBM 1401 has seven primary registers and a variety of other logic registers. Three of the primary registers are 24-bit registers: Instruction-Address Register (I-Addr Reg), A-Address Register (A-Addr Reg), and B-Address Register (B-Addr Reg). Another 24-bit address register, the Storage Register, is not directly represented by this simulator. The remaining three primary registers are 8-bit registers: A-Register (A-Reg), B-Register (B-Reg), and OpCode Register (Op-Reg). None of the registers are available to a programmer for direct manipulation.

The primary registers facilitate the fetch/execute cycle of the IBM 1401, which is depicted in Figure 2.3.1.



Figure 2.3.1, IBM 1401 Fetch/Execute Cycle
 

To illustrate a typical fetch/execute cycle, an example of a Move operation is provided below:

Instruction:
M010110\

Assumptions:

M and \ both have a wordmark.

This instruction starts at address 500.
The I-Reg is pointing to 500.
The goal of this instruction is to move the contents at memory location 010 to the memory location starting at 110. The IBM 1401 processes instructions in two steps; first the fetch phase and then the execute phase.

During the fetch phase, the 1401 loads the character pointed to by the I-Addr Reg into the B-Reg, which is a single-character register. Then if this instruction has a wordmark, then the computer knows that the character is an opcode, in this case an "M" for "Move". Once this determination is made, the opcode is moved into the OP-Reg and the address stored in the I-Addr Reg is incremented by one. The computer now knows that the OP-Reg contains a Move instruction and that the Move instruction uses both a start address and an ending address. At this point, the computer begins to load the balance of the instruction.

The target addresses are loaded in a step-by-step process. The B-Reg loads a new character pointed to by the I-Addr Reg. This character is part of the A-address, so it is moved into the highest location in the A-Addr Reg, then the I-Addr Reg increments by one. This process continues until the A-address is completely loaded into the A-Addr Reg. The B-address is loaded into the B-Addr Reg in the same manner as the A-address was loaded into the A-Addr Reg. After the B-address is loaded, the final component of the instruction, "/", is loaded into the B-Reg. The computer checks this last character for a wordmark (as it had for each of the other characters loaded), and confirms that the character's wordmark bit is set to "1". This signals the end of the instruction to the computer and the beginning of the next instruction, which starts with the "/" opcode. The fetch phase of the instruction cycle is now complete.

The final portion of the instruction cycle is called the execute phase. The execute phase carries out what has been loaded into the registers. In this case, it's the move of the A-field (the data that starts at the address contained in the A-Addr Reg) to the block of memory that starts at the address contained in the B-Addr Reg. Once the execution cycle is complete, a new fetch/execute cycle starts and this process continues until the entire program is completed.
 
 

3.___Simulator Graphical User Interface
 

3.1___Entering the Simulator

The IBM 1401 Simulator begins with a Welcome Screen that provides links that allow a user to enter the actual simulator or access the Online User Manual. The user operates the simulator in accordance with Section 4. Figure 3.1.1 shows what the IBM 1401 control panel looks like to the user. To the immediate right of the control panel are the GUI emulations of a cardreader, cardpunch, and lineprinter. These three devices are used for simulator input/output.



Figure 3.1.1, IBM 1401 Simulator GUI
 

The control panel has two main sections: The upper section of the control panel (approximately 2/3 of the control panel), called the Mimic Bus. This section contains the lights and indicators that visually aid the user in watching the program execution. In addition, it contains lights which visually alert the user to problems with peripheral hardware devices. This section also contains a text area to display program output and error messages. The lower section of the panel provides the user with the ability to load and modify program actions.

The lower section of the control panel contains the IBM 1401 controls. This panel contains several key features for users to manipulate computer operations. The main power switches, manual storage address, and branching switches are just a few of the features of this section. On the right side of the computer controls is the Input text window, which is specifically used for accepting user program input. The Mimic Bus and Control Panel are described in greater detail below.
 

3.2___Mimic Bus

The Mimic Bus provides a graphical representation of data flow in the system. Its indications allow the user to see program processing and notify the user of problems and the current state of the system when an error occurs. Across the top of the Mimic Bus are group of warning lights, which are defined in Table 3.2.1.


Table 3.2.1, Mimic Bus Warning Lights 
LightDescription User Reset Action
PROCESSProcessing unit error Push Check/Reset Button
RAMACDisk file errorN/A
TAPETape errorN/A
EX I/OExternal I/O device errorN/A
READERError in reading punchcard Push Check/Reset Button
PUNCHCardpunch needs operator attentionN/A
OVERLAPOverlap operation error Push Check/Reset Button
PRINTERPrinter operation errorN/A
 

The remainder of the Mimic Bus displays lights and BCD data which indicate program activities, including register contents. Table 3.2.2 lists descriptions for these remaining items.
 

Table 3.2.2, Mimic Bus System Status Lights
LightDescription User Reset Action
STORAGEParity-check failed on character being read into storage-register Push Check/Reset Button
BParity-check failed on character being read into B-register Push Check/Reset Button
AParity-check failed on character being read into A-register Push Check/Reset Button
LOGIC Error on arithmetic operation and/or overflow condition. Also displays compare-operation results and sum of characters being added.Push Check/Reset Button
OPIncorrect/invalid opcode. Also displays opcode bits. N/A
INSTRUCTION LENGTH Displays character of the instruction that is being read during Instruction cycles. N/A
STORAGE ADDRESS Displays BCD bits representing the address stored in a selected register.N/A
   

3.3___Control Panel

The Control Panel is set by the user to initiate a program, or can be used to request register information and output. The top of the panel has a series of buttons, which are listed in Table 3.3.1.


Table 3.3.1, Simulator Controls 
ControlDescription
REGISTERSelects any of the registers to cause the contents of the selected register to be displayed.
MANUAL ADDRESS Allows user to dial in a storage-address location. The MODE Switch position will specify the action on the selected address.
MODE Switch Selects one of nine actions: RUN, ALTER, I/Ex, Single-Cycle Process, Single-Cycle Non-Process, Character Display, Storage Printout, Storage Scan, and Address Stop.
RUNAllows program to run normally.
ALTER Allows the contents of an address register to be changed:
(1)___Push ALTER button.

(2)___Use MANUAL ADDRESS to enter desired address.

(3)___Push applicable Register button.

(4)___Push START button.

I/Ex Allows step-through execution of a program. Executes one instruction every time the START button is pushed.
Single-Cycle Process Allows step-through each cycle. Executes one cycle every time the START button is pushed.
Single-Cycle
Non-Process
Same as Single-Cycle, except that the B-field is not destroyed in arithmetic operations.
Character DisplayDisplays the character in the address selected.
Storage Print-Out 100 character blocks of storage, selected by hundreds and thousands positions of MANUAL ADDRESS fields, are printed together with a line indicating wordmarks.
Storage Scan Allows user to step through each character in storage, starting at the MANUAL ADDRESS setting. The address increments every time the START button is pushed. The computer will halt at an invalid character and display its address in the B-Register. The invalid character can then be corrected using the ALTER mode.
Address StopDesignates an address at which the program will halt.
Start/ResetResets the system and turns off the illuminated Mimic Bus displays.
I/O Check Stop Halts program if pressed before starting the program and if an input or output error occurs. If not pushed, the I/O light on the Mimic Bus will illuminate, but program operations will continue.
EMERGENCY OFF Provides a means to shut off the computer completely in an emergency condition. The control panel becomes completely non-functional. In this situation, the user must go back to the Welcome Screen, and relaunch the simulator.
STARTInitiates the user-defined program.
CHECK/RESETResets the system after a process error.
STOPStops the computer at the completion of the current instruction.
POWER ONTurns on power to the simulator.
POWER OFFTurns off power to the simulator.
TAPE LOADLoads a record tape. (NOT used for this simulator.)
BACK STAGEBacks up a tape one space. (NOT used for this simulator.)
 
 
 

4.___Tutorial
 

4.1___Introduction to IBM 1401 Programming

Before getting into the complex task of writing programs in assembly language for the IBM 1401, it is important to first understand what a "program" is, how it is entered into the simulator, and how the results are represented. Once this understanding is gained, the user will be ready to attempt to write small programs and get a feel for what it was like to program the IBM 1401 in the early days.

Programming, like many disciplines, is not an easy subject to summarize or quickly discuss. It requires structure, organization, and a clear understanding of how to address the machine being used. In order to process data in a computer, the computer needs a set of program instructions. A computer instruction is a command to the machine, expressed in a coded combination of numbers and letters, to carry out some simple operation.

This tutorial discusses some simple instructions that can be applied to the user's own programs that can demonstrate the inner workings of the IBM 1401 and help to provide an understanding of the internal storage schemes of old-style computer systems such as the IBM 1401.
 

4.2___Common Terms Used for the IBM 1401

The "storage" of a computer (also called the memory) is the part of the machine where instructions must be placed before they can be executed and also where the data being processed by the instructions must be placed. By this definition, we refer to "internal storage." Instructions may only be executed from internal storage, and the data currently being processed must be put into internal storage before any processing can be done on it. When data in external storage (from simulated punchcards for this simulator) is to be processed, it must first be read into internal storage by the execution of instructions.

In working with punchcards, it is necessary to deal with groups of columns called "fields". In this simulation, each row of eighty characters represents a punchcard. Similarly, in working with the internal storage of a computer, we must work with groups of characters which are called “words”. A computer word may be defined as any collection of characters stored in memory that is treated as a unit. For example, if we store the number 3.212, the number 2, and the letter 'A' into memory, they can each represent words. An instruction is also considered to be a word. The IBM 1401 permits words of any length, from one character up to (in principle) the size of storage. For this reason, the IBM 1401 is considered to be a variable-length-word machine.

In any computer, it is necessary to be able to identify every location in storage where a word can be stored. For this purpose, an “address” is assigned to every character location in memory. The addresses start at zero and up to one less than the number of storage locations. Note carefully that addresses identify the word location, and not the word itself. For example, the address 593 in the 1401 refers to a place in which a character may be stored; it does not by itself tell what is stored there. A location that contains the character 'A' at one time may be used a moment later to store the digit 7. A careful distinction must be made between the address of a location and the word or character currently stored at the location identified by that address.

Each of the 4000 storage positions in the simulator is able to store any one of the 48 digits, letters, or special symbols. It is also possible to store 16 additional special symbols that have various meanings within the computer, depending on the computer's configuration. Thus, each of the 4000 character positions is able to hold any one of 64 different characters, which are defined in Table 2.1.1, Binary Character Representations. Figure 4.2.1 indicates the structure of one character of storage.
 

Odd-
Parity
Zone Numeric Word
Mark
C B A 8 4 2 1 M
Figure 4.2.1, IBM 1401 Internal 8-Bit Storage Representation
 

Each character representation has eight bits, as shown in Figure 4.2.1. The C bit is the Odd-Parity bit, which is used by the computer for error-checking. Six bits, two Zone bits and four Numeric bits, are used for defining character being stored. Finally, the wordmark bit is used to signal to the computer the beginning of a new word. Any character position in which the wordmark bit is set (that is, equal to “1”) is identified as being the high-order (left-most) position of a word. wordmark bits can be set (equal to “1”) or cleared (equal to “0”) by the execution of appropriate instructions.

When the computer references a data word, it is always by the address of its low-order (right-most) character position. The machine is built so that addresses increase as the character positions are taken from left to right, which means that the low-order character of a word has the largest address. In short, when a character position is addressed for data, the computer takes the character in that position and all higher-order (but lower-address) characters as comprising a word, until it reaches a character with the wordmark bit set. If the character position that is addressed has its wordmark bit set, the word will consist of just that one character.
 

4.3___Instructions

A computer instruction is an order to carry out some elementary operation, and there are three basic categories of instructions in the 1401. The first category of instructions call for information to be read into internal storage from an input device, such as a card-reader, or to be written out to an output device, such as a card-punch. The second category of instructions perform arithmetic and logic operations. The third and final category moves and arranges data within the computer.

All instructions have an operation code (opcode), which tells the machine what operation to perform. In most computers, each instruction also has a fixed number of address parts(or operands), which in most cases specify where in storage to obtain data or place results. There may also be other parts having special purposes in a particular machine.

In the IBM 1401, every instruction has a one-character opcode, which in few cases is the entire instruction. Most instructions also have one or two address parts, of three characters each, and some have a one-character d-modifier, which is a special modifier of an existing opcode. An instruction in the IBM 1401 may thus be one to eight characters long, making it a variable-instruction-length computer. The general form of a 1401 instruction is shown in Figure 4.3.1:
 

Op
Code
A-Address B-Address d
X X X X X X X X


Figure 4.3.1, General Form of an Instruction
 

Any parts that are not included on a particular instruction are simply omitted. Some instructions, for instance, consist of only one operation code and one address or an operation code and a d-modifier. As with data words, an instruction word is required to have a wordmark in its high-order position, which is always the operation code.

To see how the instruction parts fit together, consider the following typical instruction to move a word from one part of storage to another:

M234876

M, the operation code, means Move Characters to A or B wordmark. The 234 is called the A-address and the 876 is called the B-address. The instruction means to move the word starting at the B address, with length of the word moved being defined by the first wordmark to appear in either place. Furthermore, storage positions from which the word was moved are not affected when they are copied from. In the previous move statement, the contents in address 234 is copied into the storage at address 876, but the contents of 234 remain unchanged. Also, wordmarks are also unaffected by moves. However, once an address is written into, the information that it previously held is permanently lost. Thus, the storage in 876 in the above example is completely changed once it is over-written.

To move words within storage, it is necessary to clear and set wordmarks. This is done with the opcodes “~” (clear wordmark) and “,” (set wordmark). The “~” symbol is called a “lozenge”. Below is an example using clear and set wordmarks:

,809~802833

In the above example, the wordmark at address 809 is set, and the two wordmarks at 802 and 833 are cleared.

The reading of a punchcard is called by executing the Read-A-Card instruction (“1”). This instruction, which may or may not have a branching-address argument, causes a punchcard to be read into the information placed in storage in positions 1 to 80, which is the read-area. The character in column one is placed into position 1, the character in column two is placed into position two, etc., which makes it quite easy to work with the punchcard information when it has been read into storage. There is no way to read the punchcard information into any positions other than 1 to 80; as we shall see later, when an address is used on a Read-A-Card instruction, it does not refer to data. Reading a punchcard destroys any previous contents of positions 1 to 80, except that wordmarks are not affected.

The punching of a punchcard is done by the Punch-A-Card instruction (“4”), which has no address, because it causes whatever is in the punch-area (addresses 101 to 180), to be punched into a punchcard. Punching a punchcard does not affect the contents of the punch-card storage area.

It is often necessary to clear an area of storage. For instance, suppose that certain data and results are to be moved into the print area and printed. The words moved into the area will ordinarily not occupy every position, and we naturally erase the contents of the unused positions before printing to eliminate the unwanted characters. The Clear-Storage instruction (“/”) makes it possible to clear as many as 100 positions with one instruction, putting the “blank” character in all positions and clearing all wordmarks.

The Clear-Storage instruction is built to clear all positions from the one addressed down to and including the nearest hundreds position. So, if the instruction “/799” is executed, the positions 799, 798, 797, ..., 700 are all set to blank and all wordmarks are cleared. If the instruction “/400” is executed, only position 400 is cleared.
 

4.4___Storage of Instructions

Some instructions call for information to be read into internal storage from an input device, such as a card reader. The first and most important thing to realize is that the program of instructions must be prepared before the processing is done and that the program must be in storage before it is executed. The program is written, punched onto punchcards in a suitable format, then loaded into storage. The program instructions then control the machine without any further action on the user's part.

This means, among other things, that when the program is written, the programmer must must anticipate everything that the computer will have to do. The programmer must know, for instance, the maximum sizes of the fields that the computer will process, but cannot know the actual numbers that will be dealt with. The program instructions must be setup to any data of the general type that it is designed to handle. If something comes up that was not anticipated, the computer will still try to do what the instructions say to do (assuming no error conditions), even though the results may be meaningless. The fundamental consideration is that by the time the instructions are executed by the machine, the programmer is no longer in the picture.

Another consequence of the storage of instructions is that they must be capable of being stored in the same storage that is used for data and they must be set up so that the computer can determine where one ends and another begins. Since it is frequently necessary to repeat the execution of groups of instructions or to skip around in the program, the programmer must have some way to identify an instruction by its location in storage.

This brings us to a discussion of how instructions are stored within the computer, which is one of the most important topics in the entire study of programming. The crucial concept is that instructions are brought to the control unit for execution from the internal storage of the computer, where they are stored in the same way date is stored. Therefore, it can be said that instructions are stored in much the same way as data is stored.

In the IBM 1401, instructions are executed from consecutively higher-numbered storage locations, unless special action is taken to break the consecutive sequence. The operation code of every instruction must have a wordmark. Every character of each instruction is stored in a character position; an instruction is identified by the address of the operation code. Note that the operation code is the higher-order character of the instruction so that the addressing of the instruction words is opposite that of data words. Furthermore, instruction words are picked up from storage from left to right, whereas data words are picked up from right to left.

For an application of these ideas, consider the “Hello World” program that is presented in the next section. It could be stored in any location that does not conflict with the storage of data. It should be obvious that since the program is stored just as data is, the program storage must not overlap the data storage. A storage location can store either one character of an instruction of one character of data, but not both at the same time.
 

4.5___Programming Examples
 

Example 1:___“Hello World”

,008015,022029,036043,050054,055062,063065,066077/333/M0762502F1.HELLO WORLD
 

Program Description:

In this example, the characters “HELLO WORLD” are printed out to a line printer and then the computer halts its operation. The motivation of this small program was to try to get a useful (or at least meaningful) program onto one punchcard. Notice that there are 77 characters on this card; however, only 80 characters could possibly have been punched on a single punchcard. In steps, here is a brief explanation of how the program works:


  1. The punchcard is loaded into locations 001-080 of internal memory. This fills the part of memory that has been predetermined by the designers of the IBM 1401 to be the card-input region of memory. So, whenever information is read from a card, it is brought into addresses 001-080.


  2. The opcode “set wordmark” (,) is recognized by the computer, so it sets wordmarks of the next address or two that follow the opcode. Notice that there are several (,) in the program. Thus, wordmarks are placed at each address mentioned. There are wordmarks placed at addresses 008, 015, 022, 029, 036, 043, 050, 054, 055, 062, 063, 065, 066, and 077. Notice that the wordmarks correspond to the opcodes in the program, and to the last character in the punchcard. (See below.)

  3.  

    ,008015,022029,036043,050054,055062,063065,066077/333/M0762502F1.HELLO WORLD

    W______W______W______W______W______W______W______W___WW______WW_WW__________W

    So, in the above line, the opcodes have wordmarks (“W”) now placed underneath them (as does the last character in the card, signaling the end of the punchcard.

  4. Now, positions in memory from 333 to 300 are cleared (/333), which clears out the line-buffer memory space in the computer.


  5. Positions 299 to 200 are cleared (/) by chaining the command that just followed the last instruction (/333) executed.


  6. The letters “HELLO WORLD” are moved into memory space 250 (line-printer storage space) with the instruction “M076250”. That is, the computer is told to go to storage location 076, start copying characters to location 250, and then decrement the indexes of both addresses and copy again until a wordmark has been encountered.


  7. The line is written to the line printer by instruction “2” with “HELLO WORLD” in it.


  8. The printer's carriage is told to line-feed and carriage return with instruction “F1”.


  9. The computer is then halted with the “.” instruction.


Example 2:___Addition Operation

,008015,022029,036043,044047,051008A046050.3451273
 

Program Description:

In this example, the values 345 (A-field) and 1273 (B-field) are added together, then stored in the B-field. The '.' opcode halts the operation. The small program is contained on a single punchcard. The contents of memory and the register dumps during program execution can be monitored from the Java console. In many ways, it is not much different from the “Hello World”, as far as how the series of operqations are set up and how data is accessed. However, when performing any arithmetic operations (i.e., opcodes 'A', 'S', '?', '!', '@', or '%'), it is important that the programmer review the ways that the results of each operation are stored. In the case of multiplication ('@') and division ('%'), the resultant fields are stored starting in the B-field, but take up and overwrite sum of the lengths of the operands plus 1. This makes it important for the programmer to reserve enough working space in memory to account for such operations. The other arithmetic operations ('A', 'S', '?', and '!') store their result in the B-field as well, but don't change the size of the B-field. In the case of the addition operation above, the final storage locations look as follows ('W's indicate set wordmarks), where “1618” is the sum of 345 and 1273:

,008015,022029,036043,044047,051008A046050.3451618
W______W______W______W______W______W______WW__W___W

One other data-representation issue is worth noting here: If a negative value needs to be used, the programmer of an actual IBM 1401 would simply punch out the B-Zone bit of the low-order position of the value to be a negative representation. However, in this simulator, this is not possible for the string of characters that emulate a single punchcard. Therefore, the programmer has two options: (1) Use the symbol/alphabetic character that corresponds to both the numeric-bit and the zone-bit representation in the low-order position of the field in question; or (2) The programmer can add a '-' character after the low-order character of the field. (This second option artificially provides a more-intuitive solution for the programmer; however, the first option most closely reflects the original IBM 1401 system design.)

4.6___Program Loading and Output Retrieval

Now with some basic knowledge on how the program is supposed to work, the programmer still needs to enter the program into the IBM 1401 somehow. The loading of a program is accomplished via the GUI depicted in Figure 3.1.1, IBM 1401 Simulator GUI, as follows:

  1. Push (mouseclick) the POWER_ON button on the Control Panel. This resets the mimic bus and prepares the computer to begin reading punchcards.


  2. Type the program into whatever text-editor you prefer to use, ensuring that no single line exceeds 80 characters in length. (Each line of text is treated as the equivalent of a separate punchcard.)


  3. Highlight/select from and copy the text from the text-editor.


  4. Paste into the CARD READER text area.


  5. Push (mouseclick) the load stack button on the CARD READER to load and validate the program input.


  6. An advanced IBM 1401 programmer can set the sense switches to perform intricate branching operations. For a beginner, however, all Sense switches should be set to OFF.


  7. Set the MODE switch to ALTER, then set the Manual-Address dials to the desired starting address (which, to load a card, should be “0001”) on the Control Panel to 0001, as read left to right.


  8. Push (mouseclick) the START button. This will set the instruction address register to the manual address entered.


  9. Set the MODE switch on the Control Panel to the RUN position.


  10. Push (mouseclick) START to begin execution of the program.


  11. Select and copy the output from the simulator's CARD PUNCH and/or LINE PRINTER text area(s) to the text-editor of choice and save the output as a text file.
NOTE:___A programmer must remember to clear storage between programs in order to eliminate wordmarks from prior
programs. In addition, after every program, the programmer should depress CHECK/RESET to clear the Mimic Bus display and use ALTER to reset the Manual Address before attempting to execute the next program.

4.7___Summary of Programing Principles

 


5.___Appendices
 

5.1___OpCode Tables
 

Table 5.1.1, Arithmetic Instructions
Instruction Op Code A-address B-address Function
Add A XXX XXX The data in the A-field is added to the data in the B-field. The result is stored in the B-field.
Zero and Add ? XXX XXX This instruction adds the A-field to a zeroed B-field. Technically, this is accomplished by moving the A-field to the B-field. The high-order positions of the B-field are set to zero if the B-field is larger than the A-field. The data from the A-field moves directly from the A-register to storage. Zone bits are stripped from all positions except the units position. Blanks in the A-field are stored as blanks in the B-field.
Subtract S XXX XXX The numerical data in the A-field is subtracted from the numerical data in the B-field. The result is stored in the B-field.
Zero and
Subtract
! XXX XXX This instruction subtracts the A-field from a zeroed B-field. Technically, this is accomplished by moving the A-field to the B-field. The high-order positions of the B-field are set to zero if the B-field is larger than the A-field. The data from the A-field is moved directly from the A-register to the B-field. Zone bits are stripped from all but the sign (units) position.
 
 

Table 5.1.2, Logic Instructions
Instruction OpCode I-address B-address d-char
acter
Function
Branch
(Unconditional)
B XXX ------- ------- This instruction always causes the program to branch to the address specified by the I-address portion of the instruction. This address contains the Op code of some instruction.

This unconditional branch operation is used to interrupt normal program sequence and continue the program at some other point, without testing for specific conditions.

Branch if
Indicator On
B XXX ------- X The d-character specifies the indicator tested. If the indicator is on, the next instruction is taken from the I-address. If the indicator is off, the next sequential instruction is taken.
Branch if
Wordmark
and/or Zone
V XXX XXX X The single character at the B-address is examined for a particular bit configuration, as specified by the d-character. If the bit configuration is present as specified, the program branches to the I-address for the next instruction:

d-Character Conditions: 

  1. wordmark
  2. No zone (No-A, No-B-bit)
B___12-zone (AB-bits)

K___11-zone (B, No-A-bit)
S___Zero-zone (A, No-B-bit)
3___Either a wordmark, or no zone
C___Either a wordmark, or 12-zone
L___Either a wordmark, or 11-zone
T___Either a wordmark, or zero-zone
Compare C XXX XXX ------- The data in the A-field is compared to an equal number of characters in the B-field. The bit configuration (BA 8421) of each character in the two fields is compared. The comparison turns on an indicator that can be tested by a subsequent BRANCH IF INDICATOR ON instruction. The indicator is reset by the next 7-character COMPARE instruction.
 
 

Table 5.1.3, Data-Moving Instructions
Instruction Op Code A-address B-address Function
Move Character
to A or B Word
Mark (Two Fields)
M XXX XXX The data in the A-field is moved to the B-field.
Move Character
to A or B Word
Mark (One Field)
M XXX ------- This format of the move operation can be used when it is desired to move fields from the A-area and store them sequentially in the B-area. It saves program storage space and time, because the B-address is automatically taken from the b-address register, and does not have to be written or interpreted as part of the instruction.
Move Character
and Suppress
Zeros
Z XXX XXX The data in the A-field is moved to the B-fields. After the move, high-order zeros and commas are replaced by blanks in the b-field. Any character that is not a comma, hyphen, blank, significant digit, or zero causes zero suppression to begin again. The sign is removed from the units position of the data field.
Move Numeric D XXX XXX The numeric portion (8-4-2-1 bits) of the single character in the A-address is moved to the B-address. The zone portions (AB-bits are undisturbed at both addresses.
Move Zone Y XXX XXX Only the zone portion (AB-bits) is moved from the A-address to the B-address. The digit portions (8-4-2-1- bits) are undisturbed at both addresses.
Load Characters to A Wordmark (Two Fields) L XXX XXX This instruction is commonly used to load data into designated printer or punch output areas of storage, and also to transfer data or instructions from a designated read-in area to another storage area. The data and word mark from the A-field are transferred to the B-field, and all other word marks in the B-field are cleared.
Load Characters
to a Word
Mark (One Field)
L XXX ------- This format can be used when several A-fields (not necessarily in sequence) are to be loaded sequentially in the B-field. This instruction causes the A-field data and wordmark to be moved to the B-field. B-field wordmarks are cleared, up to the A-field wordmark.
 
 

Table 5.1.4, Miscellaneous Instructions
Instruction OpCode A-address B-address I-address Function
Clear Storage / XXX ------- ------- As many as 100 positions of core storage can be cleared of data and wordmarks when this instruction is executed. Clearing starts at the A-address and continues leftward to the nearest hundreds position. The cleared area is set to blanks.
Clear Storage
and Branch
/ ------- XXX XXX This is the same as the CLEAR STORAGE instruction, except that the clearing starts at the B-address. The I-address specifies the location of the next instruction.
Set Word
Mark (Two
Addresses)
, XXX XXX ------- A wordmark is set at each address specified in the instruction. The data at each address is undisturbed.
Set Wordmark
(One Address)
, XXX ------- ------- This format of the SET WORDMARK instruction causes a wordmark to be set at the A-address. Data at this address is undisturbed.
Clear Word
Mark (Two
Addresses)
< XXX XXX ------- This instruction clears wordmarks at the locations specified by the A- and B-addresses, without disturbing the data there.
Clear Word
Mark (One
Address)
< XXX ------- ------- This format of the CLEAR WORDMARK instruction causes the wordmark to be cleared at the A-address. Data at the A-address is not disturbed.
No Operation N ------- ------- ------- This code performs no operation. It can be substituted for the operation code of any instruction to make that instruction ineffective. It is commonly used in program modification to cause the machine to skip over specific instructions
Halt . ------- ------- ------- This instruction causes the machine to stop and the stop-key light to turn on. Pressing the start key causes the program to start at the next instruction in sequence.
Halt and Branch . ------- ------- XXX This is the same as HALT, except that the next instruction is at the I-address.
Move Characters and Edit E XXX XXX ------- The data field (A-field) is modified by the contents of the edit control field (B-field) and the result stored in the B-field. The data field and the control field are read from storage character-by character, under control of the wordmarks and the editing rules. Any sign in the units position of the data field is removed during the operation.
 

5.2___References


  1. McCracken, Daniel D. A Guide to IBM 1401 Programming. John Wiley & Sons, Inc. New York. 1963.

  2.  
  3. Davis, Gordon B. An Introduction to the IBM 1401 Computer. McGraw-Hill. New York. 1965.

  4.  
  5. Saxon, James A. and William S. Plette. PROGRAMMING THE IBM 1401: A Self-Instructional Programmed Manual. Prentice-Hall, Inc. Englewood Cliffs, New Jersey. 1965.

  6.  
  7. Loschetter, Richard F. Fundamentals of Machine Language and Autocoder Programming. Whitehall Co. Northbrook, IL. 1969.

  8.  
  9. IBM Systems Reference Library. System Operation Reference Manual: IBM 1401: Data Processing System, IBM 1460 Data Processing System. International Business Machines Corp. File No. 1401/1460-01. 1963.
 

5.3___Glossary

 
Term Definition
address A location of memory
arithmetic operation An addition or subtraction of one or two addresses
bit A single memory unit. Usually represented as 0 and 1 or Off and On.
card punch A device for creating information on cards by punching holes into them. An early method of input for programming and output for the program.
card reader A device for reading punched cards
carriage-return When typing devices used a carriage which moved the plate and paper with respect to the printing head(s), a carriage return is the returning of the carriage to the first column of the paper.
chaining commands A series of operations on consecutive storage locations that allows the operations on those storage locations to be performed faster. The data fields in the chain are operated on by the same opcode.
clear wordmark An instruction that will set the wordmark bit of a character in core-storage to “0”.
computer word A series of consecutive storage characters that comprise either a complete instruction or a data field.
execution The process of running a program or a command
external storage Storage that is not built in to the computer. Tape drives and floppy disks are examples of external storage.
fields A series of consecutive character-storage locations, whose values make up a discrete set of data.
high-order character In core-storage and in an address register, the high-order position of a field represents the most-significant BCD character, which is the left-most character in the field.
instruction A mnemonic that the computer understands
internal storage Storage that is built in to the computer. Random Access Memory (RAM) and Hard Disks are examples of internal storage.
line-feed When typing devices used a carriage which moved the platen and paper with respect to the printing head(s), a line feed is the moving of the paper to the next row.
low-order character In core-storage and in an address register, the low-order position of a field represents the least-significant BCD character, which is the right-most character in the field.
lozenge Special character on old IBM computers
mimic bus A graphical representation of the data-flow paths between various registers and core-storage, which is located on the front of the IBM 1401 Control Panel.
operation code (opcode) A mnemonic that the computer understands
parity bit By adding up the bits in a word, the parity bit represents an even or odd number of 0's or 1's.
partial chaining A series of operations on consecutive storage locations that allows the operations on those storage locations to be performed faster. With partial chaining, there can be multiple and various opcodes, but the A-fields must be in a consecutive series and the B-fields must also be in a consecutive series.
set wordmark An instruction that will set the wordmark bit of a character in core-storage to “1”.
variable-length word In the IBM 1401, the length of an instruction word can be from one to eight characters, and theoretically, the length of a data field can be from one to the size of installed core-storage.
wordmark bit The eigth binary bit in a character in storage that flags the beginning of an instruction or the end of a data field in core-storage.
words A section of memory addresses that correspond to a set of related characters.
 

Go back to top of document.