You do it the same way the internal processor does. You must use call and ret to do this. Each instruction takes time to complete. This is called a loop. The more instructions you have, the more cycles it takes, so it takes more time to complete.
Inside, when the processor arrives at the call instruction in your code, this happens:
- The processor pops the IP register address after your call statement onto the stack.
- The processor changes the address of the
IP register to the address of your call code. - Execution in progress.
When the processor arrives at the ret statement in your code, this happens:
- The processor pops the 16-bit address from the stack and places it in the
IP register. - Fulfillment of Resume
Although it looks like many steps, these steps take place without power cycles because they are built into the processor hardware.
Icemanind
source share