일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 멀티프로세스
- 솔루션에프로젝트추가
- 프로젝트 여러개
- superbible
- interface block
- Qtspim
- 시작
- turingmachine
- shader
- glfw
- OpenGL
- vertexarrayobject
- 파일생성 명령어
- glDrawArrays
- 수리명제
- VAO
- git
- .sln
- vertex
- visualstudip
- 정의
- vertex sahder
- qtspim stack
- 튜링기계
- multi process
- Tutorial
- fetching
- fragment
- 하나의 솔루션
- 자동판결
- Today
- Total
공사중
Qtspim 과제 풀어보기 본문
우선 https://courses.cs.washington.edu/courses/cse378/08au/lectures/cse378-08au-lec04-2up.pdf 를 보면서 subroutine에 대한 내용을 깔끔하게 한 번 더 정리합니다.
이전 포스팅에서 많이 공부하고 넘어오니까 위 pdf tutorial이 완벽하게 이해됩니다.
문제1.
함수 내에서 선언된 local variable들이 왜 그 함수에서 return을 하고나면 없어지가? (여기 참고)
When you program in C or C++ or Java, you are used to calling functions with local variables. Each time you call a function, a new set of local variables is created. This is why recursive function calls work. Each recursive call has its own copy of local variables and parameters (unless the parameters are passed by reference). This makes it easier to write functions in procedural languages.
When you program in assembly language, there is only one set of registers used in the program. In effect, these registers act like global variables. It's very easy to make a subroutine call, and think that after the subroutine call is done, the registers have remain unchanged.
However, you would be wrong if you thought thatw. When you make a subroutine call, you have to assume that, unless convention dictates otherwise, the subroutine will clobber all the registers you are using (except the stack pointer). Thus, if you call a subroutine, any values you've stored in a register could be overwritten. After all, the subroutine being called needs to use registers too, and there's only one set to work with.
문제 2. factorial qtspim에서 돌려보기