Skip to content

Commit

Permalink
add latest
Browse files Browse the repository at this point in the history
  • Loading branch information
vadixidav committed Apr 22, 2018
1 parent c37ba62 commit a74540d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ Any time we are in a loop, we are probably going to be working with registers. T

One of those things could be to push a set of registers onto the stack at the beginning of the loop in the order for processing. If these registers are overwritten during the course of the loop, that can be utilized to modify the values that enter in again at the beginning. This is similar to a fold/reduce expression in that accumulators, variables, and constant values come back in at the beginning. We can implement this using a special instruction that copies n registers from the beginning of memory onto the stack. Since the first register is the PC, this means that at the end of the loop one can just jump or branch back to this special instruction location, triggering the loop again. Since this instruction will need to have several variants for each number of registers to copy, it will take up several instruction slots.

If we use a dedicated loop instruction, we can make it so any time we move back to the beginning of the loop that the loop puts the registers on the stack. This is especially helpful because the first iteration of the loop gets the initial inputs, just as in the above solution, but even more useful because now we can automatically return to the beginning without specifically requiring the PC, which is more useful for branching paths conditionally exiting the loop or doing other things. This does make returning take an extra instruction to `unloop` the loop, which is not otherwise necessary since no loop stack or any special loop state exists.

### Rotate

0 comments on commit a74540d

Please sign in to comment.