1. IBM 1401 simulator usage

Date:

2015-03-31

Revision:

$Format:%H$

Copyright:

See LICENSE.txt for terms of use.

This memorandum documents the IBM 1401 simulator.

1.1. Simulator files

sim/
scp.h
sim_console.h
sim_defs.h
sim_fio.h
sim_rev.h
sim_sock.h
sim_tape.h
sim_timer.h
sim_tmxr.h
scp.c
sim_console.c
sim_fio.c
sim_sock.c
sim_tape.c
sim_timer.c
sim_tmxr.c
sim/i1401/
i1401_defs.h
i1401_dat.h
i1401_cpu.c
i1401_cd.c
i1401_iq.c
i1401_lp.c
i1401_dp.c
i1401_mt.c
i1401_sys.c

1.2. IBM 1401 features

The IBM 1401 simulator is configured as follows:

Device names

Simulates

CPU

IBM 1401 CPU with 16K of memory

CDR, CDP

IBM 1402 card reader/punch

LPT

IBM 1403 line printer

INQ

IBM 1407 inquiry terminal

DP

IBM 1311 disk pack with five drives

MT

IBM 729 7-track magnetic tape controller with six drives

The IBM 1401 simulator implements many unique stop conditions. On almost any kind of error the simulator stops:

  • Unimplemented opcode

  • Reference to non-existent memory

  • Reference to non-existent device

  • No word mark under opcode

  • Invalid A address

  • Invalid B address

  • Invalid instruction length

  • Invalid modifier character

  • Invalid branch address

  • Invalid magtape unit number

  • Invalid magtape record length

  • Write to locked magtape drive

  • Skip to unpunched carriage control tape channel

  • Card reader hopper empty

  • Address register wrap-around

  • I/O check with I/O stop switch set

  • Invalid disk drive

  • Invalid disk sector address

  • Invalid disk sector count

  • Invalid disk address compare

The LOAD command is used to load a line printer carriage-control tape. The DUMP command is not implemented.

1.2.1. CPU

The CPU options include a number of special features and the size of main memory. Note that the Modify Address special feature is always included when memory size is greater than 4K.

SET CPU XSA      Enable advanced programming special feature
SET CPU NOXSA    Disable advanced programming
SET CPU HLE      Enable high/low/equal special feature
SET CPU NOHLE    Disable high/low/equal
SET CPU BBE      Enable branch on bit equal special feature
SET CPU NOBBE    Disable branch on bit equal
SET CPU MR       Enable move record special feature
SET CPU NOMR     Disable move record
SET CPU EPE      Enable extended print edit special feature
SET CPU NOEPE    Disable extended print edit
SET CPU MDV      Enable multiply/divide special feature
SET CPU NOMDV    Disable multiply/divide
SET CPU 4K       Set memory size = 4K
SET CPU 8K       Set memory size = 8K
SET CPU 12K      Set memory size = 12K
SET CPU 16K      Set memory size = 16K

If memory size is being reduced, and the memory being truncated contains non-zero data, the simulator asks for confirmation. Data in the truncated portion of memory is lost. Initially, memory size is 16K, and all special features are enabled.

Memory is implemented as 7-bit BCD characters, as follows:

   6       5      4       3     2     1     0
   ╷       ╷      ╷       ╷     ╷     ╷     ╷
   │       B      A       8     4     2     1
   │      bit    bit      │     │     │     │
   │       ╘═══╤══╛       ╘═════╧══╤══╧═════╛
Word mark    Zone                Digit

In BCD, the decimal digits 0-9 are (octal) values 012, 001, 002, 003, 004, 005, 006, 007, 010, 011, respectively. Signs are encoded in the zone bits, with 00, 01, and 11 being positive, and 10 being negative.

CPU registers include the visible state of the processor. The 1401 has no interrupt system.

Name

Size

Comments

IS

14

Instruction storage address register (PC)

AS

14

A storage address register

BS

14

B storage address register

ASERR

1

AS invalid flag

BSERR

1

BS invalid flag

SSA

1

Sense switch A

SSB

1

Sense switch B

SSC

1

Sense switch C

SSD

1

Sense switch D

SSE

1

Sense switch E

SSF

1

Sense switch F

SSG

1

Sense switch G

EQU

1

Equal compare indicator

UNEQ

1

Unequal compare indicator

HIGH

1

High compare indicator

LOW

1

Low compare indicator

OVF

1

Overflow indicator

IOCHK

1

I/O check switch

PRCHK

1

Process check switch

ISQ[0:63]

14

IS prior to last branch; most recent IS change first

WRU

8

Interrupt character

The CPU can maintain a history of the most recently executed instructions. This is controlled by the SET CPU HISTORY and SHOW CPU HISTORY commands:

SET CPU HISTORY               Clear history buffer
SET CPU HISTORY=0             Disable history
SET CPU HISTORY=n             Enable history, length = n
SHOW CPU HISTORY              Print CPU history
SHOW CPU HISTORY=n            Print first 'n' entries of CPU history

The maximum length for the history is 65536 entries.

The original character encoding used by the 1401 simulator was revised to be compatible with the coding used by Paul Pierce’s 709X and 1401 simulators. The user can select between the original (old) and compatible (new) encodings, as follows:

SET CPU OLDCONVERSIONS        Use original character encoding
SET CPU NEWCONVERSIONS        Use compatible character encoding

NEWCONVERSIONS is the default.

1.2.2. 1402 card reader/punch (CDR, CDP, STKR)

The IBM 1402 card/reader punch is simulated as three independent devices: the card reader (CDR), the card punch (CDP), and the reader and punch stackers (STKR). STKR units 0, 1, 2, and 4 correspond to the reader normal stacker, reader stacker 1, shared stacker 2/8, and punch stacker 4, respectively.

Card punch and stacker units support both the business (1403 print chain A) and Fortran (1403 H chain) character sets:

SET CDP BUSINESS              Business character set
SET CDP FORTRAN               Fortran character set

The business character set is the default.

The card reader supports the BOOT command. BOOT CDR reads a card image into locations 1-80, sets a word mark under location 1, clears storage, and then transfers control to location 1.

The card reader normally reads data from disk files, while the punch and stackers write data to disk files. Text cards are simulated as ASCII text lines with terminating newlines; column binary cards are simulated as ASCII text lines with adjacent characters supplying half of the 12b column code. For each unit, the POS register specifies the number of the next data item to be read or written. Thus, by changing POS, the user can backspace or advance these devices.

As a convenience for testing, the simulator supports entering cards from the console keyboard. To enable and disable default input from the keyboard:

SET CDR DEFAULT               Default to keyboard if no file attached
SET CDP NODEFAULT             Always take input from an attached file

The card reader signals its readiness to read a card by typing:

[ENTER CARD]

Input is terminated by a carriage return. Backspace (rubout) will erase the previously entered character and echo backslash (\). ^E will interrupt the wait loop and return control to the simulator control package. While taking input from the keyboard, the card reader’s “last card” logic is disabled.

The card reader registers are:

Name

Size

Comments

LAST

1

Last card indicator

ERR

1

Error indicator

S1

1

Stacker 1 select flag

S2

1

Stacker 2 select flag

POS

32

Position in reader input file

TIME

24

Delay window for stacker select

BUF[0:79]

8

Reader buffer

The card punch registers are:

Name

Size

Comments

ERR

1

Error indicator

S4

1

Stacker 4 select flag

S8

1

Stacker 8 select flag

POS

32

Position in punch output file

The stacker registers are:

Name

Size

Comments

POS0

32

Position, normal reader stack

POS1

32

Position, reader stacker 1

POS2

32

Position, shared stacker 2/8

POS4

32

Position, punch stacker 4

Error handling is as follows:

Device

Error

Processed as

Reader

End-of-file

If SSA set, set LAST indicator on next read, report error and stop

Reader punch

Not attached

Report error and stop

OS I/O error

Print error message if IOCHK set, report error and stop otherwise, set ERR indicator.

Stacker

Not attached

Ignored

OS I/O

Error print error message if IOCHK set, report error and stop

1.2.3. 1403 line printer (LPT)

The IBM 1403 line printer (LPT) writes its data, converted to ASCII, to a disk file. The POS register specifies the number of the next data item to be read or written. Thus, by changing POS, the user can backspace or advance the printer.

The line printer implements both 48- and 64-character print chains:

SET LPT 64                    64-character print chain
SET LPT 48                    48-character print chain

The line printer also implements both the business (1403 print chain A) and Fortran (1403 H chain) character sets:

SET LPT BUSINESS              Business print character set
SET LPT FORTRAN               Fortran character set

The default is the 64-character print chain with the business set.

The line printer can be set to output to the console window if no file is attached:

SET LPT DEFAULT               Default output to console if not attached
SET LPT NODEFAULT             Always output to a file

In addition, the line printer can be programmed with a carriage control tape. The LOAD command loads a new carriage control tape:

LOAD <file>                   Load carriage control tape file

The format of a carriage control tape consists of multiple lines. Each line contains an optional repeat count, enclosed in parentheses, optionally followed by a series of column numbers separated by commas. Column numbers must be between 1 and 12; a column number of zero denotes top of form. The following are all legal carriage control specifications:

<blank line>

No punch

(5)

5 lines with no punches

1,5,7,8

Columns 1, 5, 7, 8 punched

(10)2

10 lines with column 2 punched

1,0

Column 1 punched; top of form

The default form is 66 lines long, with column 1 and the top of form mark on line 1, and the rest blank.

The line printer registers are:

Name

Size

Comments

LINES

8

Number of newlines after next print

LFLAG

1

Carriage control flag (1 = skip, 0 = space)

CCTP

8

Carriage control tape pointer

CCTL

8

Carriage control tape length (read-only)

ERR

1

Error indicator

POS

32

Position in the output file

CCT[0:131]

32

Carriage control tape array

Error handling is as follows:

Error

Processed as

Not attached

Report error and stop

OS I/O error

Print error message if IOCHK set, report error and stop otherwise, set ERR indicator

1.2.4. 1407 inquiry terminal (INQ)

The IBM 1407 inquiry terminal (INQ) is a half-duplex console. It polls the console keyboard periodically for inquiry requests.

The inquiry terminal supports both the business (1403 print chain A) and Fortran (1403 H chain) character sets for output:

SET INQ BUSINESS              Business character set
SET INQ FORTRAN               Fortran character set

The business character set is the default.

The inquiry terminal registers are:

Name

Size

Comments

INQC

7

Inquiry request character (initially ESC)

INR

1

Inquiry request indicator

INC

1

Inquiry cleared indicator

TIME

24

Polling interval

When the 1401 CPU requests input from the keyboard, the message [Enter] is printed out, followed by a newline. The CPU hangs waiting for input until either the return/enter key is pressed, or the inquiry request character is typed in. The latter cancels the type-in and sets INC.

The inquiry terminal has no errors.

1.2.5. 1311 disk pack (DP)

The disk pack controller supports 5 drives, numbered 0 through 4. Disk pack options include the ability to enable address writing (formatting).

SET DPn ADDROFF               Set unit 'n' address enable off
SET DPn ADDRON                Set unit 'n' address enable on

Units can also be set ENABLED or DISABLED.

Unlike most simulated disks, the 1311 includes explicit representation for sector addresses. This is to support non-standard formats, such as the inclusion of the drive number in the sector address. As a result, 1311 sectors are 106 characters long: 6 address characters and 100 data characters. If the 1311 has not been formatted, the addresses are blanks and are synthesized, if needed, based on the sector number.

The 1311 also supports two modes of operation: move mode and load mode. In move mode, word marks are ignored on writes and left untouched on reads, and sectors hold 100 characters. In load mode, word marks are included on writes and stored on reads, and sectors hold 90 characters. No attempt is made to deal with sectors written in load mode and read in move mode, or vice versa; on a real 1401, this causes a fatal parity error.

The disk pack controller implements these registers:

Name

Size

Comments

ACC

1

Access error indicator

PWC

1

Parity or write check error indicator

WLR

1

Wrong length record error indicator

UNA

1

Unequal address compare error indicator

DSK

1

Any disk error indicator

BSY

1

Disk access busy indicator

LASTF

3

Most recent function

TIME

24

Seek time

The 1311 has a primitive overlapped seek capability. If TIME is set non-zero, the 1311 will report itself busy for the specified amount of time following a seek. This allows programs to utilize the seek time for processing.

Error handling is as follows:

Error

Processed as

Not attached

Set DSK indicator if IOCHK set, report error and stop.

1311 data files are buffered in memory; therefore, end-of-file and OS I/O errors cannot occur.

1.2.6. 729 magnetic tape (MT)

The magnetic tape controller supports six drives, numbered 1 through 6. Magnetic tape options include the ability to make units write enabled or write locked.

SET MTn LOCKED                Set unit 'n' write locked
SET MTn WRITEENABLED          Set unit 'n' write enabled

Magnetic tape units can be set to a specific reel capacity in MB, or to unlimited capacity:

SET MTn CAPAC=m               Set unit 'n' capacity to 'm' MB (0 = unlimited)
SHOW MTn CAPAC                Show unit 'n' capacity in MB

Units can also be set ENABLED or DISABLED.

The magnetic tape simulator supports the BOOT command. BOOT MT reads the first record off tape, starting at location 1, and then branches to it. BOOT -N MT reads the next record off tape, without rewinding, starting at location 1, and then branches to it.

The magnetic tape controller implements these registers:

Name

Size

Comments

END

1

End-of-file indicator

ERR

1

Error indicator

PAR

1

Parity error indicator

POS1..POS6

32

Position, drives 1 to 6

Error handling is as follows:

Error

Processed as

Not attached

Report error and stop

End-of-file

Set error indicator

OS I/O error

Print error message, set error indicator if IOCHK set, report error and stop

1.3. Symbolic display and input

The IBM 1401 simulator implements symbolic display and input. Display is controlled by command-line switches:

-c

Display as single character (BCD for CPU and MT, ASCII for others)

-s

Display as wordmark terminated BCD string (CPU only)

-m

Display instruction mnemonics (CPU only)

-d

Display 50 characters per line, with word marks denoted by “1” on the line below

In a CPU character display, word marks are denoted by `. Input parsing is controlled by the first character typed in or by command-line switches:

' or ", -c or -s

Characters (BCD for CPU and MT, ASCII for others)

Alphabetic

Instruction mnemonic

Numeric

Octal number

Instruction input is free format, with spaces separating fields. There are six instruction formats: 1, 2, 4, 5, 7, and 8 characters:

1 character

opcode

2 character

opcode 'modifier

4 character

opcode address

5 character

opcode address 'modifier

7 character

opcode address address

8 character

opcode address address 'modifier

Addresses are always decimal, except for special I/O addresses in the A field, which may be specified as %xy, where x denotes the device and y the unit number.

For the CPU, string input may encompass multiple characters. A word mark is denoted by ` and must precede the character to be marked. All other devices can only accept single character input, without word marks.

1.4. Character sets

The IBM 1401 uses a 6b character code called BCD (binary-coded decimal). Some of the characters have no equivalent in ASCII and require different representations:

BCD code

representation

character

chains

00

space

01

1

02

2

03

3

04

4

05

5

06

6

07

7

10

8

11

9

12

0

13

# or =

= in H chain

14

@ or '

' in H chain

15

:

blank in A, H chains

16

>

blank in A, H chains

17

{

tape mark

blank in A, H chains

20

^

alternate blank

blank in A, H chains

21

/

22

S

23

T

24

U

25

V

26

W

27

X

30

Y

31

Z

32

|

record mark

33

,

34

% or (

( in H chain

35

~

word mark

blank in A, H chains

36

\

blank in A, H chains

37

"

blank in A, H chains

40

-

41

J

42

K

43

L

44

M

45

N

46

O

47

P

50

Q

51

R

52

!

53

$

54

*

55

]

blank in A, H chains

56

;

blank in A, H chains

57

_

delta

blank in A, H chains

60

&

61

A

62

B

63

C

64

D

65

E

66

F

67

G

70

H

71

I

72

?

73

.

74

)

lozenge

75

[

blank in A, H chains

76

<

blank in A, H chains

77

}

group mark

blank in A, H chains

1.4.1. Old conversions

Starting with V3.5-1, the 1401 simulator was changed to use the same character set as the SIMH 7094 (and other 7094 simulators). This involved the following changes:

Code

V3.5-0 or earlier

V3.5-1 or later

13

#

# or = on input

14

@

@ or ' on input

17

(

{

32

'

|

34

%

% or ( on input

35

=

~

37

+

"

60

&

& or + on input

77

"

}

In addition, the word mark indicator was changed from ~ to `.

The 1401 simulator can be set to operate with either set of conventions:

SET CPU OLDCONVERSIONS
SET CPU NEWCONVERSIONS

The default is NEWCONVERSIONS.