Instructions: Language of the

2023-01-23  本文已影响0人  刘东利2020

2.8 Supporting Procedures in Computer Hardware

这一节讲的是各种过程(procedures):

procedure A stored subroutine that performs a specific task based on the parameters with which it is provided.

这里的定义有点“套套逻辑” —— subroutine被翻译为“子程序”,但是如果查一查subroutine:

所以作者随后又打了个比方:

You can think of a procedure like a spy who leaves with a secret plan, acquires resources, performs the task, covers his or her tracks, and then returns to the point of origin with the desired result. Nothing else should be perturbed once the mission is complete. Moreover, a spy operates on only a “need to know” basis, so the spy can’t make assumptions about the spymaster.

对于这个比方,具象化来说就是六个步骤:

1. Put parameters in a place where the procedure can access them.

2. Transfer control to the procedure.

3. Acquire the storage resources needed for the procedure.

4. Perform the desired task.

5. Put the result value in a place where the calling program can access it.

6. Return control to the point of origin, since a procedure can be called from several points in a program.

上一篇下一篇

猜你喜欢

热点阅读