コンピュータの基本: プリンター等のハードウエアに仕事をさせるのにメモリーの中はどうなっているの | ITセキュリティ

ITセキュリティ

事故のない社会に

コンピュータにふれあい初めて40年(新入社員の頃)、いつかはメモリーの中はどうなっていて人はどう操作するのか、まとめてみたくてうずうずしていました。
一時は私のライフワーク(完成まで6ケ月?)とも思っていたのですが、驚いたことにAIはほんの数分でやってくれました!AIの間違いを指摘し、解決してもらい数分で書ききりました。その時(2023年12月)は英語でないとAIに頼めないと思っていたので英語でプロンプトを書きました。

命題: ユニットアドレス(00e)に私の名前を10個印刷するプログラムを書いてください。

(ご安心ください、こんなこと知らなくてもコンピューターは使えます!)


Supervior mode と Program state mode

 

Supervisor State Block (SSB): When an interruption or exception occurs, the current state of the processor is saved in a Supervisor State Block (SSB) in central storage. The restart PSW may be stored in the SSB, allowing the interrupted program to be resumed from that point.

 

  1. Program Event Recording (PER) Buffer: In some cases, the restart PSW may be captured and stored in a Program Event Recording (PER) buffer. The PER buffer records information about system events and can be used for diagnostic and problem determination purposes.
  2. Checkpoint/Restart Facility: On some System/370 mainframes, a Checkpoint/Restart Facility may be available. This facility allows the system to take periodic snapshots of the execution state of a program and store it in a checkpoint dataset. In the event of an interruption or failure, the program can be restarted from the most recent checkpoint, including the restart PSW.
  3. Save Areas: In certain programming environments or when using specific programming techniques, the restart PSW may be stored in a save area. A save area is a designated area of storage allocated for saving and restoring the state of a program or subroutine. The save area can include various registers, including the PSW.

On IBM System/370 mainframes, the Program Status Word (PSW) is a 16-byte (128-bit) field that contains various control and status information about the currently executing program. The PSW includes the instruction address, condition code, control bits, and other relevant information.

The storage location for the restart PSW on an IBM System/370 depends on the specific context and purpose of the restart. There are several potential locations where the restart PSW can be stored:

Here is an example program that uses the START I/O instruction (opcode '9C00') to print nine occurrences of 'Hajime Kashiwagi' to a printer with unit address '00E':

assembly

         ORG    0

 

START    START  0

 

         PRINT  DC    C'Hajime Kashiwagi'

         DC    X'0A'    // Line feed character

 

         USING  *,15

 

         LA     0,PRINT    // Address of the data to print

         L     1,=X'00E'   // Unit address of the printer

         ST     1,8(0,1)   // Store unit address in channel control word

 

         CSW    DC    CL8'00000000'    // Channel Status Word

         CCW    DC    X'010C0000'      // CCW: Command = Write, Length = 12

 

         B      IODELAY             // Delay to ensure I/O has completed

 

IODELAY  CSW    DC    CL8'00000000'    // Channel Status Word

         CCW    DC    X'00000000'      // CCW: Command = No Operation (NOP)

 

         BCR    15,0              // Branch to address 0 to restart the program

 

         END    START

This program defines a single line of text to print, followed by a line feed character. It then sets up the necessary channel control word (CCW) and channel status word (CSW) to initiate the I/O operation. After the I/O operation is completed, it introduces a delay with a NOP instruction (IODELAY) to ensure the printer has finished printing before the program restarts. Finally, the program branches back to the beginning (address 0) to restart itself.

Please note that the exact details of setting up the channel control word (CCW) and channel status word (CSW) may depend on the specific operating system and I/O configuration of your System/370 system. It's essential to consult the documentation and references specific to your environment for accurate information regarding the programming and I/O setup.

I hope this guidance helps you in creating your program. If you have any further questions, please let me know!

In this continuation, the program introduces a loop labeled as LOOP. After the I/O operation is completed, the program branches back to the LOOP label, effectively restarting the printing process.

This updated program will continuously print the message 'Hajime Kashiwagi' to the printer with unit address '00E' until the program is interrupted or manually stopped.

Please keep in mind that the specific implementation and behavior of the I/O instructions, as well as the loop control mechanism, may depend on your system configuration, programming environment, and the operating system in use. Therefore, consulting the relevant documentation or programming references specific to your system is important for accurate and appropriate usage.


 

フォームの始まり

フォームの終わり