Skip to content

平成24年度 秋期 ITパスポート試験 問76

This question's explanation and your answers so far.

問76
頻出度★☆☆

コンピュータにおける命令の実行順序に関する次の記述中の a,b に入れる字句の適切な組合せはどれか。 コンピュータにおける命令の実行順序は, (1) プログラムカウンタの参照 (2) 命令の [a] (3) 次の命令の主記憶アドレスをプログラムカウンタにセットする。 (4) 命令の [b] (5) 命令に応じた処理を実行 (6) (1)へ戻る。 を繰り返す。

出典 平成24年度 秋期 ITパスポート試験 問76
解説

問 76

  • Incorrectア

    “a-decode, b-fetch” exactly reverses the correct order, so it is wrong. At stage (1), all that is known from the program counter is the main memory address where the instruction is placed; the content of the instruction is not yet inside the CPU. An instruction that is not at hand cannot be decoded, so decoding can never come before fetching. Moreover, with this arrangement, what is done immediately before (5), “execute the processing corresponding to the instruction,” would be fetching, which would mean executing without having judged what the instruction is, and that does not make sense.

  • Incorrectイ

    “b-decode” is correct, but “a-write” is wrong. What is done immediately after referencing the program counter in (1) is the action of reading the instruction at that address out of main memory into the CPU, not the action of writing something into main memory. The instruction execution cycle is a flow in which a program held in main memory is read and executed, and a stage of “writing an instruction” does not exist in it at all. Incidentally, if a write to main memory does occur, it is the case of storing data such as a computation result as the outcome of the execution in (5); it is not a matter of the fetch stage that comes before execution.

  • ウ

    正解 The correct answer is ウ “a-fetch, b-decode.” As long as the power is on, the CPU repeatedly takes machine-language instructions placed in main memory one at a time and executes them, and one round of this is called the instruction execution cycle (instruction cycle). Steps (1) to (6) in the question are simply that one round laid out in order. First, in (1), the program counter (instruction address register) is referenced. The program counter is the register that holds which main memory address the next instruction to be executed is at, so this step determines where the instruction to be taken lies. Next, in (2), the contents of that address are brought from main memory into the instruction register inside the CPU. This is fetching the instruction (taking out the instruction, the instruction fetch), so the word that goes into a is “fetch.” Once the instruction has been brought in, in (3) the program counter is updated to the main memory address of the next instruction. By doing this, after processing of the instruction just taken out finishes, the following instruction can be taken out directly on the next round. Then, in (4), the instruction decoder examines the instruction that has entered the instruction register, judges from the instruction part whether it is an addition, a transfer, or a branch, and obtains from the operand part where the target data is located. This is decoding the instruction, so the word that goes into b is “decode.” Only once it is known what the instruction is does (5), “execute the processing corresponding to the instruction,” become possible, with the control unit sending control signals to the arithmetic unit and the storage unit to carry the processing forward. Then (6) returns to (1). In short, the order is “take it out, then read what it says, and only after reading it, execute it,” so ウ, which has the combination a-fetch and b-decode, is the correct answer.

  • Incorrectエ

    “a-fetch” is correct, but “b-write” is wrong. Stage (4) is where the instruction decoder judges what the instruction that was read in is directing, and if this stage were made a write, the cycle would proceed to the execution in (5) without having judged the type of the instruction, so the processing to be performed could not be determined. Writing is an action that appears when the result of the execution in (5) is stored into main memory or a register, and its object is not the instruction itself but the processed data. The next action performed on an instruction that has been read in is decoding, not writing.

ここがポイント
  • The order of the instruction execution cycle — reference the program counter → fetch the instruction → update the program counter → decode the instruction → execute the instruction, repeated over and over. The program counter is the register that holds the main memory address of the next instruction to be executed, and it is updated to the address of the next instruction immediately after an instruction is taken out.
  • The devices and places responsible for each stage — an instruction is read from main memory into the instruction register, the instruction decoder decodes its instruction part to judge the type of the instruction, and the control unit sends control signals to the arithmetic unit and the storage unit to have it executed. The order of “take out, read what it says, execute” never changes places, and writing is the action of the situation where an execution result is stored as data.
用語

Your answers