I want to create a subroutine like this:
- first time call: return 0
- second time call: return 1
- third time call: return 2
- ...
but we should not use register and memory to save the current number. we have to solve this by changing the code (self-modifying). Is there any way?
This is the solution which I found: