프로시저, Procedure

신승준·2022년 5월 7일
0

프로시저, Procedure

함수 혹은 프로시저를 처리하는 6단계

  1. Main routine(caller) places parameters(arguments) in a place where the procedure(callee) can access them
    호출되는 함수인 callee가 접근할 수 있는 공간에, 호출하는 함수인 caller가 parameters(arguments)를 가져나 놓는다. 이러한 인자를 위해 4개의 레지스터가 사용될 수 있다.

  2. Caller transfers control to the callee
    caller가 callee에게 control을 넘긴다. 즉 callee가 실행된다.

  3. Callee acquires the storage resources needed
    callee가 필요한 메모리를 할당 받게 된다. 보통 stack이라는 공간에 메모리를 할당 받게 된다.

  4. performs the desired task
    callee는 자기가 해야 할 일을 수행한다.

  5. Callee places the result value in a place where the caller can access it
    callee가 할 일이 끝나면, caller가 접근할 수 있는 곳에 return value를 가져다 놓는다. return 값을 위해 2개의 레지스터가 사용된다.

  6. Callee returns control to the caller
    callee가 caller에게 control을 넘긴다. 즉 caller가 다시 실행된다.

profile
메타몽 닮음 :) email: alohajune22@gmail.com

0개의 댓글