Simh/i1401 with COBOL on docker(1)

[Simh/i1401 with FortranIV on docker](https://qiita.com/suzanHud/items/85522c7a0af03d7671ad)ではFortranIVをターゲットにしました。
Simhの実行イメージができれば、それを使って応用できます。
次はCOBOLのプログラムを実行してみます。
使うテープイメージは[IBM 1401 COBOL e-mails](http://ibm-1401.info/COBOL-e-mails.html)で紹介されている
[i1401-Cobol-Generation.zip](http://ibm-1401.info/pictures/000COBOL/i1401-Cobol-Generation.zip)と
[i1401-Cobol.zip](http://ibm-1401.info/pictures/000COBOL/i1401-Cobol.zip)を使用します。
最初にCOBOLコンパイラのテープイメージを作成します。

i1401-Cobol-Generation.zipに含まれているCobol_Generation.iniはWindows向けですので、
Linux向けのものを用意します。

```Cobol_Generation_for_linux.ini
; Generates Cobol.tap (cobol compiler tape) and
; autocode.cobol.tap (Autocode to assemble compiler output)

SET CPU 16K

set CPU NEWCONVERSIONS
SET CDP BUSINESS
SET LPT BUSINESS

at mt1 adc00223_Cobol.mt1
at mt2 -n Cobol.tap
at mt3 -n Extraction.tap

Echo
Echo *** Extract cobol compiler tape and extraction tape from PID Cobol
echo *** distribution tape from IBM
Echo

boot mt1

Echo
Echo *** Now process extraction tape to ...

at mt1 Extraction.tap
det mt2
det mt3

boot mt1

Echo
Echo ... Print Cobol Phase Listings (Source code)
echo

at lpt -n Cobol_Source_Listing.txt
go

Echo
Echo ... Punch Cobol Subrutines and Sample Program
echo

; punch cards in staker4 (not in CDP device)
at stkr4 -n Extaction_cards.crd
go

; separate cards using identification numbers

! grep " 70001" Extaction_cards.crd > "Cobol_4k_subs.crd"
! grep " 70002" Extaction_cards.crd > "Cobol_4kp_subs.crd"
! grep " 70003" Extaction_cards.crd > "Cobol_Sample_Program.crd"

det stkr4
!rm Extaction_cards.crd
det lpt

echo
Echo *** Now Place Cobol Soubroutines in the Autocoder Library
echo

at mt1 Autocoder+IOCS.tap
at mt6 -n Autocoder.cobol.tap

at cdr Cobol_4kp_subs.crd

set lpt default

dep ssa 1
dep ssf 1

boot mt1

echo
quit
```
Simh実行用のDockerイメージを起動します。i1401-Cobol-Generation.zipを展開後、Cobol_Generation_for_linux.iniをコピーします。

```
C:\kazu>docker run -it kazu_simh:i1401
/ # cd /simh
/simh # wget http://ibm-1401.info/pictures/000COBOL/i1401-Cobol-Generation.zip
Connecting to ibm-1401.info (45.40.183.1:80)
i1401-Cobol-Generati 100% |****************************************************************| 1888k  0:00:00 ETA
/simh # unzip i1401-Cobol-Generation.zip
Archive:  i1401-Cobol-Generation.zip
   creating: generation/
  inflating: generation/adc00223_Cobol.mt1
  inflating: generation/Autocoder+IOCS.tap
  inflating: generation/Autocoder.cobol.tap
  inflating: generation/Cobol.tap
  inflating: generation/Cobol_4kp_subs.crd
  inflating: generation/Cobol_4k_subs.crd
  inflating: generation/Cobol_Generation.ini
  inflating: generation/Cobol_Sample_Program.crd
  inflating: generation/Cobol_Source_Listing.txt
  inflating: generation/Extraction.tap
  inflating: generation/run Cobol Generation.bat
/simh # cd generation/
/simh/generation # ls
Autocoder+IOCS.tap        Cobol_4k_subs.crd         Cobol_Sample_Program.crd  adc00223_Cobol.mt1
Autocoder.cobol.tap       Cobol_4kp_subs.crd        Cobol_Source_Listing.txt  run Cobol Generation.bat
Cobol.tap                 Cobol_Generation.ini      Extraction.tap
/simh/generation # cp ../Cobol_Generation_for_linux.ini .
```
では、コンパイラのテープイメージを作成します。

```
/simh/generation # i1401 Cobol_Generation_for_linux.ini

IBM 1401 simulator V4.0-0 Current        git commit id: 9e719822
/simh/generation/Cobol_Generation_for_linux.ini-11> at mt1 adc00223_Cobol.mt1
Tape Image 'adc00223_Cobol.mt1' scanned as SIMH format.
contains 4754130 bytes of tape data (3666 records, 7 tapemarks)
A potentially unreasonable number of record sizes(171) vs tape marks (7) have been found
The tape format (SIMH) might not be correct for the 'adc00223_Cobol.mt1' tape image
/simh/generation/Cobol_Generation_for_linux.ini-12> at mt2 -n Cobol.tap
MT: creating new file: Cobol.tap
/simh/generation/Cobol_Generation_for_linux.ini-13> at mt3 -n Extraction.tap
MT: creating new file: Extraction.tap

*** Extract cobol compiler tape and extraction tape from PID Cobol
*** distribution tape from IBM


HALT instruction, IS: 3686 (B 3681)

*** Now process extraction tape to ...

HALT instruction, IS: 364 (SWM 723)

... Print Cobol Phase Listings (Source code)

/simh/generation/Cobol_Generation_for_linux.ini-35> at lpt -n Cobol_Source_Listing.txt
LPT: creating new file: Cobol_Source_Listing.txt

HALT instruction, IS: 600 (B 697)

... Punch Cobol Subrutines and Sample Program

/simh/generation/Cobol_Generation_for_linux.ini-43> at stkr4 -n Extaction_cards.crd
STKR: creating new file: Extaction_cards.crd

HALT instruction, IS: 709 (B 702)

*** Now Place Cobol Soubroutines in the Autocoder Library

/simh/generation/Cobol_Generation_for_linux.ini-60> at mt1 Autocoder+IOCS.tap
Tape Image 'Autocoder+IOCS.tap' scanned as SIMH format.
contains 426122 bytes of tape data (4197 records, 3 tapemarks)
A potentially unreasonable number of record sizes(39) vs tape marks (3) have been found
The tape format (SIMH) might not be correct for the 'Autocoder+IOCS.tap' tape image
/simh/generation/Cobol_Generation_for_linux.ini-61> at mt6 -n Autocoder.cobol.tap
MT: creating new file: Autocoder.cobol.tap
                   1401 AUTOCODER - LIBRARY CHANGES                    PAGE   1
(省略)
  17  ZSPSV3 DCW   #3                  INDEX REGISTER 3 SAVED HERE

1401 AUTOCODER SYSTEM COPIED ON TAPE UNIT 6
HALT instruction, IS: 704 (B 1021)
Goodbye
/simh/generation #
```